Skip to content

Commit 9e521e4

Browse files
committed
Merge branch 'release/v2.0.2'
2 parents 23e5eaa + fe8446b commit 9e521e4

File tree

4 files changed

+89
-61
lines changed

4 files changed

+89
-61
lines changed

boards/d1_mini_pro.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"f_cpu": "80000000L",
66
"f_flash": "40000000L",
77
"flash_mode": "dio",
8-
"ldscript": "eagle.flash.16m.ld",
8+
"ldscript": "eagle.flash.16m14m.ld",
99
"mcu": "esp8266",
1010
"variant": "d1_mini"
1111
},

builder/main.py

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# pylint: disable=redefined-outer-name
1616

1717
import re
18-
import socket
18+
import sys
1919
from os.path import join
2020

2121

@@ -150,29 +150,6 @@ def _update_max_upload_size(env):
150150
"framework-arduinoespressif8266"),
151151
SDK_ESP8266_DIR=platform.get_package_dir("sdk-esp8266"),
152152

153-
#
154-
# Upload
155-
#
156-
157-
UPLOADER="esptool",
158-
UPLOADEROTA=join(platform.get_package_dir("tool-espotapy") or "",
159-
"espota.py"),
160-
161-
UPLOADERFLAGS=[
162-
"-cd", "$UPLOAD_RESETMETHOD",
163-
"-cb", "$UPLOAD_SPEED",
164-
"-cp", '"$UPLOAD_PORT"'
165-
],
166-
UPLOADEROTAFLAGS=[
167-
"--debug",
168-
"--progress",
169-
"-i", "$UPLOAD_PORT",
170-
"$UPLOAD_FLAGS"
171-
],
172-
173-
UPLOADCMD='$UPLOADER $UPLOADERFLAGS -cf $SOURCE',
174-
UPLOADOTACMD='"$PYTHONEXE" "$UPLOADEROTA" $UPLOADEROTAFLAGS -f $SOURCE',
175-
176153
#
177154
# Misc
178155
#
@@ -227,11 +204,6 @@ def _update_max_upload_size(env):
227204
)
228205
)
229206

230-
if "uploadfs" in COMMAND_LINE_TARGETS:
231-
env.Append(
232-
UPLOADERFLAGS=["-ca", "${hex(SPIFFS_START)}"],
233-
UPLOADEROTAFLAGS=["-s"]
234-
)
235207

236208
#
237209
# Framework and SDK specific configuration
@@ -264,17 +236,6 @@ def _update_max_upload_size(env):
264236
)
265237
)
266238
)
267-
268-
# Handle uploading via OTA
269-
ota_port = None
270-
if env.get("UPLOAD_PORT"):
271-
try:
272-
ota_port = socket.gethostbyname(env.get("UPLOAD_PORT"))
273-
except socket.error:
274-
pass
275-
if ota_port:
276-
env.Replace(UPLOADCMD="$UPLOADOTACMD")
277-
278239
else:
279240
# ESP8266 RTOS SDK and Native SDK common configuration
280241
env.Append(
@@ -300,20 +261,6 @@ def _update_max_upload_size(env):
300261
)
301262
)
302263

303-
env.Replace(
304-
UPLOADERFLAGS=[
305-
"-vv",
306-
"-cd", "$UPLOAD_RESETMETHOD",
307-
"-cb", "$UPLOAD_SPEED",
308-
"-cp", '"$UPLOAD_PORT"',
309-
"-ca", "0x00000",
310-
"-cf", "${SOURCES[0]}",
311-
"-ca", "$UPLOAD_ADDRESS",
312-
"-cf", "${SOURCES[1]}"
313-
],
314-
UPLOADCMD='$UPLOADER $UPLOADERFLAGS',
315-
)
316-
317264
if not env.get("PIOFRAMEWORK"):
318265
env.SConscript("frameworks/_bare.py", exports="env")
319266

@@ -376,11 +323,74 @@ def _update_max_upload_size(env):
376323
# Target: Upload firmware or SPIFFS image
377324
#
378325

379-
target_upload = env.Alias(
380-
["upload", "uploadfs"], target_firm,
381-
[env.VerboseAction(env.AutodetectUploadPort, "Looking for upload port..."),
382-
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")])
383-
env.AlwaysBuild(target_upload)
326+
upload_protocol = env.subst("$UPLOAD_PROTOCOL")
327+
upload_actions = []
328+
329+
# Compatibility with old OTA configurations
330+
if (upload_protocol != "espota"
331+
and re.match(r"\"?((([0-9]{1,3}\.){3}[0-9]{1,3})|[^\\/]+\.local)\"?$",
332+
env.get("UPLOAD_PORT", ""))):
333+
upload_protocol = "espota"
334+
sys.stderr.write(
335+
"Warning! We have just detected `upload_port` as IP address or host "
336+
"name of ESP device. `upload_protocol` is switched to `espota`.\n"
337+
"Please specify `upload_protocol = espota` in `platformio.ini` "
338+
"project configuration file.\n")
339+
340+
if upload_protocol == "espota":
341+
if not env.subst("$UPLOAD_PORT"):
342+
sys.stderr.write(
343+
"Error: Please specify IP address or host name of ESP device "
344+
"using `upload_port` for build environment or use "
345+
"global `--upload-port` option.\n"
346+
"See https://docs.platformio.org/page/platforms/"
347+
"espressif8266.html#over-the-air-ota-update\n")
348+
env.Replace(
349+
UPLOADER=join(
350+
platform.get_package_dir("tool-espotapy") or "", "espota.py"),
351+
UPLOADERFLAGS=["--debug", "--progress", "-i", "$UPLOAD_PORT"],
352+
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS -f $SOURCE'
353+
)
354+
if "uploadfs" in COMMAND_LINE_TARGETS:
355+
env.Append(UPLOADERFLAGS=["-s"])
356+
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]
357+
358+
elif upload_protocol == "esptool":
359+
env.Replace(
360+
UPLOADER="esptool",
361+
UPLOADERFLAGS=[
362+
"-cd", "$UPLOAD_RESETMETHOD",
363+
"-cb", "$UPLOAD_SPEED",
364+
"-cp", '"$UPLOAD_PORT"'
365+
],
366+
UPLOADCMD='$UPLOADER $UPLOADERFLAGS -cf $SOURCE',
367+
)
368+
if env.subst("$PIOFRAMEWORK") not in ("arduino", "simba"): # SDK
369+
env.Append(
370+
UPLOADERFLAGS=[
371+
"-ca", "0x00000",
372+
"-cf", "${SOURCES[0]}",
373+
"-ca", "$UPLOAD_ADDRESS",
374+
"-cf", "${SOURCES[1]}"
375+
]
376+
)
377+
env.Replace(UPLOADCMD="$UPLOADER $UPLOADERFLAGS")
378+
elif "uploadfs" in COMMAND_LINE_TARGETS:
379+
env.Append(UPLOADERFLAGS=["-ca", "${hex(SPIFFS_START)}"])
380+
upload_actions = [
381+
env.VerboseAction(
382+
env.AutodetectUploadPort, "Looking for upload port..."),
383+
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")
384+
]
385+
386+
# custom upload tool
387+
elif upload_protocol == "custom":
388+
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]
389+
390+
else:
391+
sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol)
392+
393+
env.AlwaysBuild(env.Alias(["upload", "uploadfs"], target_firm, upload_actions))
384394

385395
#
386396
# Target: Erase Flash

platform.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"type": "git",
1313
"url": "https://github.com/platformio/platform-espressif8266.git"
1414
},
15-
"version": "2.0.1",
15+
"version": "2.0.2",
1616
"packageRepositories": [
1717
"https://dl.bintray.com/platformio/dl-packages/manifest.json",
1818
"http://dl.platformio.org/packages/manifest.json",

platform.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,21 @@ def configure_default_packages(self, variables, targets):
2525
self.packages['tool-mkspiffs']['optional'] = False
2626
return PlatformBase.configure_default_packages(
2727
self, variables, targets)
28+
29+
def get_boards(self, id_=None):
30+
result = PlatformBase.get_boards(self, id_)
31+
if not result:
32+
return result
33+
if id_:
34+
return self._add_upload_protocols(result)
35+
else:
36+
for key, value in result.items():
37+
result[key] = self._add_upload_protocols(result[key])
38+
return result
39+
40+
def _add_upload_protocols(self, board):
41+
if not board.get("upload.protocols", []):
42+
board.manifest['upload']['protocols'] = ["esptool", "espota"]
43+
if not board.get("upload.protocol", ""):
44+
board.manifest['upload']['protocol'] = "esptool"
45+
return board

0 commit comments

Comments
 (0)