Skip to content

Commit dabf4c5

Browse files
earlephilhowerdevyte
authored andcommitted
Make upload.py compatible with existing FS upload (esp8266#6788)
* Make upload.py compatible with existing FS upload PR esp8266#6765 introduced an incompatibility with the existing Java uploaders for SPIFFS and LittleFS, breaking them because of the upload.py parameter format change to support single stage erase/upload. Add in patch to silently eat the single --end and to parse the write address and filename properly as generated by calls from the plugins, while retaining compatibility with the current IDE changes. * Clean upload.py, make platform use write_flash Make upload.py more concise and pythonic. Use the "write_flash" argument in platform.txt for uploads instead of assuming anything that is a file is the bin to upload.
1 parent 01e9d94 commit dabf4c5

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

platform.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ tools.esptool.upload.params.quiet=
149149
# First, potentially perform an erase or nothing
150150
# Next, do the binary upload
151151
# Combined in one rule because Arduino doesn't suport upload.1.pattern/upload.3.pattern
152-
tools.esptool.upload.pattern="{cmd}" "{runtime.platform.path}/tools/upload.py" --chip esp8266 --port "{serial.port}" --baud "{upload.speed}" "{upload.verbose}" {upload.erase_cmd} {upload.resetmethod} "{build.path}/{build.project_name}.bin"
152+
tools.esptool.upload.pattern="{cmd}" "{runtime.platform.path}/tools/upload.py" --chip esp8266 --port "{serial.port}" --baud "{upload.speed}" "{upload.verbose}" {upload.erase_cmd} {upload.resetmethod} write_flash 0x0 "{build.path}/{build.project_name}.bin"
153153

154154
tools.esptool.upload.network_pattern="{network_cmd}" "{runtime.platform.path}/tools/espota.py" -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
155155

tools/upload.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
cmdline = []
2424
write_option = ''
25+
write_addr = '0x0'
2526
erase_addr = ''
2627
erase_len = ''
2728

@@ -38,28 +39,26 @@
3839
# https://github.com/esp8266/Arduino/issues/6755#issuecomment-553208688
3940
if thisarg == "erase_flash":
4041
write_option = '--erase-all'
41-
thisarg = ''
42-
43-
if thisarg == 'erase_region':
42+
elif thisarg == 'erase_region':
4443
erase_addr = sys.argv.pop(0)
4544
erase_len = sys.argv.pop(0)
46-
thisarg = ''
47-
48-
if os.path.isfile(thisarg):
49-
binary = thisarg
50-
thisarg = ''
51-
52-
if len(thisarg):
45+
elif thisarg == '--end':
46+
# Backwards compatibility with fs upload tools, eat --end
47+
pass
48+
elif thisarg == 'write_flash':
49+
write_addr = sys.argv.pop(0)
50+
binary = sys.argv.pop(0)
51+
elif len(thisarg):
5352
cmdline = cmdline + [thisarg]
5453

5554
cmdline = cmdline + ['write_flash']
5655
if len(write_option):
5756
cmdline = cmdline + [write_option]
58-
cmdline = cmdline + ['0x0', binary]
57+
cmdline = cmdline + [write_addr, binary]
5958

6059
erase_file = ''
6160
if len(erase_addr):
62-
# generate temporary empty (0xff) file
61+
# Generate temporary empty (0xff) file
6362
eraser = tempfile.mkstemp()
6463
erase_file = eraser[1]
6564
os.write(eraser[0], bytearray([255] * int(erase_len, 0)))

0 commit comments

Comments
 (0)