diff --git a/tools/upload.py b/tools/upload.py index 0f5cb78352..3567e0af21 100755 --- a/tools/upload.py +++ b/tools/upload.py @@ -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 @@ -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): @@ -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)