1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +03:00

Make upload.py compatible with existing FS upload (#6788)

* Make upload.py compatible with existing FS upload

PR #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.
This commit is contained in:
Earle F. Philhower, III 2019-11-17 15:05:43 -07:00 committed by Develo
parent 01e9d948c7
commit dabf4c53d4
2 changed files with 12 additions and 13 deletions

View File

@ -149,7 +149,7 @@ tools.esptool.upload.params.quiet=
# First, potentially perform an erase or nothing # First, potentially perform an erase or nothing
# Next, do the binary upload # Next, do the binary upload
# Combined in one rule because Arduino doesn't suport upload.1.pattern/upload.3.pattern # Combined in one rule because Arduino doesn't suport upload.1.pattern/upload.3.pattern
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" 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"
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" 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"

View File

@ -22,6 +22,7 @@ except:
cmdline = [] cmdline = []
write_option = '' write_option = ''
write_addr = '0x0'
erase_addr = '' erase_addr = ''
erase_len = '' erase_len = ''
@ -38,28 +39,26 @@ while len(sys.argv):
# https://github.com/esp8266/Arduino/issues/6755#issuecomment-553208688 # https://github.com/esp8266/Arduino/issues/6755#issuecomment-553208688
if thisarg == "erase_flash": if thisarg == "erase_flash":
write_option = '--erase-all' write_option = '--erase-all'
thisarg = '' elif thisarg == 'erase_region':
if thisarg == 'erase_region':
erase_addr = sys.argv.pop(0) erase_addr = sys.argv.pop(0)
erase_len = sys.argv.pop(0) erase_len = sys.argv.pop(0)
thisarg = '' elif thisarg == '--end':
# Backwards compatibility with fs upload tools, eat --end
if os.path.isfile(thisarg): pass
binary = thisarg elif thisarg == 'write_flash':
thisarg = '' write_addr = sys.argv.pop(0)
binary = sys.argv.pop(0)
if len(thisarg): elif len(thisarg):
cmdline = cmdline + [thisarg] cmdline = cmdline + [thisarg]
cmdline = cmdline + ['write_flash'] cmdline = cmdline + ['write_flash']
if len(write_option): if len(write_option):
cmdline = cmdline + [write_option] cmdline = cmdline + [write_option]
cmdline = cmdline + ['0x0', binary] cmdline = cmdline + [write_addr, binary]
erase_file = '' erase_file = ''
if len(erase_addr): if len(erase_addr):
# generate temporary empty (0xff) file # Generate temporary empty (0xff) file
eraser = tempfile.mkstemp() eraser = tempfile.mkstemp()
erase_file = eraser[1] erase_file = eraser[1]
os.write(eraser[0], bytearray([255] * int(erase_len, 0))) os.write(eraser[0], bytearray([255] * int(erase_len, 0)))