idf_monitor: support to re-flash with the using port

This commit make idf_monitor overwrite the ESPPORT environment variable
with the port it's using, and re-run make with the modified environment
variable. In this way, the make invoked will inherit the idf_monitor's
port.

Closes https://github.com/espressif/esp-idf/issues/4591
pull/5106/head
michael 2020-04-07 01:44:23 +08:00
rodzic 862fa815ff
commit 8aafb6b513
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -649,7 +649,7 @@ class Monitor(object):
else:
popen_args = [self.make, target]
yellow_print("Running %s..." % " ".join(popen_args))
p = subprocess.Popen(popen_args)
p = subprocess.Popen(popen_args, env=os.environ)
try:
p.wait()
except KeyboardInterrupt:
@ -967,6 +967,13 @@ def main():
except KeyError:
pass # not running a make jobserver
# Pass the actual used port to callee of idf_monitor (e.g. make) through `ESPPORT` environment
# variable
# To make sure the key as well as the value are str type, by the requirements of subprocess
espport_key = str("ESPPORT")
espport_val = str(args.port)
os.environ.update({espport_key: espport_val})
monitor = Monitor(serial_instance, args.elf_file.name, args.print_filter, args.make, args.encrypted,
args.toolchain_prefix, args.eol,
args.decode_coredumps)