Skip to content
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

Update upload.py #6781

Closed
wants to merge 2 commits into from
Closed
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
39 changes: 35 additions & 4 deletions tools/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@
write_option = ''
erase_addr = ''
erase_len = ''
compatibility = False

while len(sys.argv):
arg_counter = len(sys.argv)-1
while (arg_counter):
if sys.argv[arg_counter] == '--end':
compatibility = True
break
arg_counter -= 1


while len(sys.argv) and not compatibility:
thisarg = sys.argv.pop(0)

# We silently replace the 921kbaud setting with 460k to enable backward
Expand All @@ -52,10 +61,14 @@
if len(thisarg):
cmdline = cmdline + [thisarg]

cmdline = cmdline + ['write_flash']
if not compatibility:
cmdline = cmdline + ['write_flash']

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

if not compatibility:
cmdline = cmdline + ['0x0', binary]

erase_file = ''
if len(erase_addr):
Expand All @@ -66,7 +79,25 @@
os.close(eraser[0])
cmdline = cmdline + [ erase_addr, erase_file ]

esptool.main(cmdline)
if not compatibility:
#sys.stderr.write("\ncmdline:" + str(cmdline) + "\n")
esptool.main(cmdline)

while len(sys.argv) and compatibility:
if sys.argv[0] == '--end':
#sys.stderr.write("\ncmdline:" + str(cmdline) + " in compatibility mode\n")
esptool.main(cmdline)
sys.argv.pop(0) # Remove --end
cmdline = []
else:
# We silently replace the 921kbaud setting with 460k to enable backward
# compatibility with the old esptool-ck.exe. Esptool.py doesn't seem
# work reliably at 921k, but is still significantly faster at 460kbaud.
thisarg = sys.argv.pop(0)
if thisarg == "921600":
thisarg = "460800"
cmdline = cmdline + [thisarg]


if len(erase_file):
os.remove(erase_file)