idf.py: Fix 'idf.py monitor' build & flash targets
This commit is contained in:
parent
48c3ad37f1
commit
8453806a8c
27
tools/idf.py
27
tools/idf.py
|
@ -267,9 +267,13 @@ def monitor(action, args):
|
||||||
monitor_args += [ "-p", args.port ]
|
monitor_args += [ "-p", args.port ]
|
||||||
monitor_args += [ "-b", project_desc["monitor_baud"] ]
|
monitor_args += [ "-b", project_desc["monitor_baud"] ]
|
||||||
monitor_args += [ elf_file ]
|
monitor_args += [ elf_file ]
|
||||||
|
|
||||||
|
idf_py = [ PYTHON ] + get_commandline_options() # commands to re-run idf.py
|
||||||
|
monitor_args += [ "-m", " ".join("'%s'" % a for a in idf_py) ]
|
||||||
|
|
||||||
if "MSYSTEM" is os.environ:
|
if "MSYSTEM" is os.environ:
|
||||||
monitor_args = [ "winpty" ] + monitor_args
|
monitor_args = [ "winpty" ] + monitor_args
|
||||||
_run_tool("idf_monitor", monitor_args, args.build_dir)
|
_run_tool("idf_monitor", monitor_args, args.project_dir)
|
||||||
|
|
||||||
|
|
||||||
def clean(action, args):
|
def clean(action, args):
|
||||||
|
@ -311,16 +315,16 @@ ACTIONS = {
|
||||||
"build": ( "all", [], [] ), # build is same as 'all' target
|
"build": ( "all", [], [] ), # build is same as 'all' target
|
||||||
"clean": ( clean, [], [ "fullclean" ] ),
|
"clean": ( clean, [], [ "fullclean" ] ),
|
||||||
"fullclean": ( fullclean, [], [] ),
|
"fullclean": ( fullclean, [], [] ),
|
||||||
"reconfigure": ( reconfigure, [], [] ),
|
"reconfigure": ( reconfigure, [], [ "menuconfig" ] ),
|
||||||
"menuconfig": ( build_target, [], [] ),
|
"menuconfig": ( build_target, [], [] ),
|
||||||
"size": ( build_target, [], [ "app" ] ),
|
"size": ( build_target, [ "app" ], [] ),
|
||||||
"size-components": ( build_target, [], [ "app" ] ),
|
"size-components": ( build_target, [ "app" ], [] ),
|
||||||
"size-files": ( build_target, [], [ "app" ] ),
|
"size-files": ( build_target, [ "app" ], [] ),
|
||||||
"bootloader": ( build_target, [], [] ),
|
"bootloader": ( build_target, [], [] ),
|
||||||
"bootloader-clean": ( build_target, [], [] ),
|
"bootloader-clean": ( build_target, [], [] ),
|
||||||
"bootloader-flash": ( flash, [ "bootloader" ], [] ),
|
"bootloader-flash": ( flash, [ "bootloader" ], [] ),
|
||||||
"app": ( build_target, [], [ "clean", "fullclean", "reconfigure" ] ),
|
"app": ( build_target, [], [ "clean", "fullclean", "reconfigure" ] ),
|
||||||
"app-flash": ( flash, [], [ "app" ]),
|
"app-flash": ( flash, [ "app" ], []),
|
||||||
"partition_table": ( build_target, [], [ "reconfigure" ] ),
|
"partition_table": ( build_target, [], [ "reconfigure" ] ),
|
||||||
"partition_table-flash": ( flash, [ "partition_table" ], []),
|
"partition_table-flash": ( flash, [ "partition_table" ], []),
|
||||||
"flash": ( flash, [ "all" ], [ ] ),
|
"flash": ( flash, [ "all" ], [ ] ),
|
||||||
|
@ -329,6 +333,17 @@ ACTIONS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_commandline_options():
|
||||||
|
""" Return all the command line options up to but not including the action """
|
||||||
|
result = []
|
||||||
|
for a in sys.argv:
|
||||||
|
if a in ACTIONS.keys():
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
result.append(a)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='ESP-IDF build management tool')
|
parser = argparse.ArgumentParser(description='ESP-IDF build management tool')
|
||||||
parser.add_argument('-p', '--port', help="Serial port", default=None)
|
parser.add_argument('-p', '--port', help="Serial port", default=None)
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
# esp-idf serial output monitor tool. Does some helpful things:
|
# esp-idf serial output monitor tool. Does some helpful things:
|
||||||
# - Looks up hex addresses in ELF file with addr2line
|
# - Looks up hex addresses in ELF file with addr2line
|
||||||
# - Reset ESP32 via serial RTS line (Ctrl-T Ctrl-R)
|
# - Reset ESP32 via serial RTS line (Ctrl-T Ctrl-R)
|
||||||
# - Run "make flash" (Ctrl-T Ctrl-F)
|
# - Run "make/idf.py flash" (Ctrl-T Ctrl-F)
|
||||||
# - Run "make app-flash" (Ctrl-T Ctrl-A)
|
# - Run "make/idf.py app-flash" (Ctrl-T Ctrl-A)
|
||||||
# - If gdbstub output is detected, gdb is automatically loaded
|
# - If gdbstub output is detected, gdb is automatically loaded
|
||||||
#
|
#
|
||||||
# Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
# Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||||
|
@ -37,6 +37,7 @@ try:
|
||||||
import queue
|
import queue
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import Queue as queue
|
import Queue as queue
|
||||||
|
import shlex
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import serial
|
import serial
|
||||||
|
@ -243,7 +244,10 @@ class Monitor(object):
|
||||||
self.console_reader = ConsoleReader(self.console, self.event_queue)
|
self.console_reader = ConsoleReader(self.console, self.event_queue)
|
||||||
self.serial_reader = SerialReader(self.serial, self.event_queue)
|
self.serial_reader = SerialReader(self.serial, self.event_queue)
|
||||||
self.elf_file = elf_file
|
self.elf_file = elf_file
|
||||||
self.make = make
|
if not os.path.exists(make):
|
||||||
|
self.make = shlex.split(make) # allow for possibility the "make" arg is a list of arguments (for idf.py)
|
||||||
|
else:
|
||||||
|
self.make = make
|
||||||
self.toolchain_prefix = toolchain_prefix
|
self.toolchain_prefix = toolchain_prefix
|
||||||
self.menu_key = CTRL_T
|
self.menu_key = CTRL_T
|
||||||
self.exit_key = CTRL_RBRACKET
|
self.exit_key = CTRL_RBRACKET
|
||||||
|
@ -355,19 +359,18 @@ class Monitor(object):
|
||||||
--- {menu:7} Send the menu character itself to remote
|
--- {menu:7} Send the menu character itself to remote
|
||||||
--- {exit:7} Send the exit character itself to remote
|
--- {exit:7} Send the exit character itself to remote
|
||||||
--- {reset:7} Reset target board via RTS line
|
--- {reset:7} Reset target board via RTS line
|
||||||
--- {make:7} Run 'make flash' to build & flash
|
--- {makecmd:7} Build & flash project
|
||||||
--- {appmake:7} Run 'make app-flash to build & flash app
|
--- {appmake:7} Build & flash app only
|
||||||
--- {output:7} Toggle output display
|
--- {output:7} Toggle output display
|
||||||
--- {pause:7} Reset target into bootloader to pause app via RTS line
|
--- {pause:7} Reset target into bootloader to pause app via RTS line
|
||||||
""".format(version=__version__,
|
""".format(version=__version__,
|
||||||
exit=key_description(self.exit_key),
|
exit=key_description(self.exit_key),
|
||||||
menu=key_description(self.menu_key),
|
menu=key_description(self.menu_key),
|
||||||
reset=key_description(CTRL_R),
|
reset=key_description(CTRL_R),
|
||||||
make=key_description(CTRL_F),
|
makecmd=key_description(CTRL_F),
|
||||||
appmake=key_description(CTRL_A),
|
appmake=key_description(CTRL_A),
|
||||||
output=key_description(CTRL_Y),
|
output=key_description(CTRL_Y),
|
||||||
pause=key_description(CTRL_P),
|
pause=key_description(CTRL_P) )
|
||||||
)
|
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
""" Use 'with self' to temporarily disable monitoring behaviour """
|
""" Use 'with self' to temporarily disable monitoring behaviour """
|
||||||
|
@ -385,12 +388,12 @@ class Monitor(object):
|
||||||
red_print("""
|
red_print("""
|
||||||
--- {}
|
--- {}
|
||||||
--- Press {} to exit monitor.
|
--- Press {} to exit monitor.
|
||||||
--- Press {} to run 'make flash'.
|
--- Press {} to build & flash project.
|
||||||
--- Press {} to run 'make app-flash'.
|
--- Press {} to build & flash app.
|
||||||
--- Press any other key to resume monitor (resets target).""".format(reason,
|
--- Press any other key to resume monitor (resets target).""".format(reason,
|
||||||
key_description(self.exit_key),
|
key_description(self.exit_key),
|
||||||
key_description(CTRL_F),
|
key_description(CTRL_F),
|
||||||
key_description(CTRL_A)))
|
key_description(CTRL_A) ))
|
||||||
k = CTRL_T # ignore CTRL-T here, so people can muscle-memory Ctrl-T Ctrl-F, etc.
|
k = CTRL_T # ignore CTRL-T here, so people can muscle-memory Ctrl-T Ctrl-F, etc.
|
||||||
while k == CTRL_T:
|
while k == CTRL_T:
|
||||||
k = self.console.getkey()
|
k = self.console.getkey()
|
||||||
|
@ -404,9 +407,12 @@ class Monitor(object):
|
||||||
|
|
||||||
def run_make(self, target):
|
def run_make(self, target):
|
||||||
with self:
|
with self:
|
||||||
yellow_print("Running make %s..." % target)
|
if isinstance(self.make, list):
|
||||||
p = subprocess.Popen([self.make,
|
popen_args = self.make + [ target ]
|
||||||
target ])
|
else:
|
||||||
|
popen_args = [ self.make, target ]
|
||||||
|
yellow_print("Running %s..." % " ".join(popen_args))
|
||||||
|
p = subprocess.Popen(popen_args)
|
||||||
try:
|
try:
|
||||||
p.wait()
|
p.wait()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
Loading…
Reference in a new issue