Skip to content

Make upload.py compatible with existing FS upload #6788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ tools.esptool.upload.params.quiet=
# First, potentially perform an erase or nothing
# Next, do the binary upload
# 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"

Expand Down
23 changes: 11 additions & 12 deletions tools/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

cmdline = []
write_option = ''
write_addr = '0x0'
erase_addr = ''
erase_len = ''

Expand All @@ -38,28 +39,26 @@
# https://github.com/esp8266/Arduino/issues/6755#issuecomment-553208688
if thisarg == "erase_flash":
write_option = '--erase-all'
thisarg = ''

if thisarg == 'erase_region':
elif thisarg == 'erase_region':
erase_addr = sys.argv.pop(0)
erase_len = sys.argv.pop(0)
thisarg = ''

if os.path.isfile(thisarg):
binary = thisarg
thisarg = ''

if len(thisarg):
elif thisarg == '--end':
# Backwards compatibility with fs upload tools, eat --end
pass
elif thisarg == 'write_flash':
write_addr = sys.argv.pop(0)
binary = sys.argv.pop(0)
elif len(thisarg):
cmdline = cmdline + [thisarg]

cmdline = cmdline + ['write_flash']
if len(write_option):
cmdline = cmdline + [write_option]
cmdline = cmdline + ['0x0', binary]
cmdline = cmdline + [write_addr, binary]

erase_file = ''
if len(erase_addr):
# generate temporary empty (0xff) file
# Generate temporary empty (0xff) file
eraser = tempfile.mkstemp()
erase_file = eraser[1]
os.write(eraser[0], bytearray([255] * int(erase_len, 0)))
Expand Down