From c02c0cc9b79a43f19fbe7963b289d6370f9f0403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ga=C5=88o?= Date: Tue, 10 May 2022 14:19:37 +0200 Subject: [PATCH] Tools: Add --no-reset option for IDF Monitor in order to avoid resetting the chip target upon connection Closes https://github.com/espressif/esp-idf/issues/8889 Closes IDFGH-7189, IDFGH-7301, IDFGH-5963 Closes https://github.com/espressif/esp-idf/issues/7651 Merges https://github.com/espressif/esp-idf/pull/8788 --- docs/en/api-guides/tools/idf-monitor.rst | 9 +++++++++ tools/idf_monitor_base/argument_parser.py | 3 +-- tools/idf_monitor_base/serial_handler.py | 1 - tools/idf_py_actions/serial_ext.py | 6 ++++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/en/api-guides/tools/idf-monitor.rst b/docs/en/api-guides/tools/idf-monitor.rst index e256248949..b289b36d19 100644 --- a/docs/en/api-guides/tools/idf-monitor.rst +++ b/docs/en/api-guides/tools/idf-monitor.rst @@ -184,6 +184,15 @@ To decode each address, IDF Monitor runs the following command in the background Set environment variable ``ESP_MONITOR_DECODE`` to ``0`` or call idf_monitor.py with specific command line option: ``idf_monitor.py --disable-address-decoding`` to disable address decoding. +Reset of the chip target on connect +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The reset of the target chip is performed using DTR and RTS serial lines. For preventing the reset of the target on idf monitor startup call idf_monitor.py with specific command line option: ``idf_monitor.py --no-reset``. + +.. note:: + + The same behavior can be achieved using ``idf.py monitor`` interface with specific command line option: ``--no-reset``. To prevent the reset on startup is required to call the command with explicitly set port ``idf.py monitor --no-reset -p [PORT]`` + + Launching GDB with GDBStub ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tools/idf_monitor_base/argument_parser.py b/tools/idf_monitor_base/argument_parser.py index 937231596e..b0233bcc4e 100644 --- a/tools/idf_monitor_base/argument_parser.py +++ b/tools/idf_monitor_base/argument_parser.py @@ -18,9 +18,8 @@ def get_parser(): # type: () -> argparse.ArgumentParser ) parser.add_argument( - '--no-reset', '-R', + '--no-reset', help='Do not reset the chip on monitor startup', - default=False, action='store_true' ) diff --git a/tools/idf_monitor_base/serial_handler.py b/tools/idf_monitor_base/serial_handler.py index 2fcdb41917..b3a71f64a2 100644 --- a/tools/idf_monitor_base/serial_handler.py +++ b/tools/idf_monitor_base/serial_handler.py @@ -193,7 +193,6 @@ class SerialHandler: console_reader.stop() serial_reader.stop() elif cmd == CMD_RESET: - self.serial_instance.setDTR(high) # IO0=HIGH, default state self.serial_instance.setRTS(low) # EN=LOW, chip in reset self.serial_instance.setDTR(self.serial_instance.dtr) # usbser.sys workaround time.sleep(reset_delay) diff --git a/tools/idf_py_actions/serial_ext.py b/tools/idf_py_actions/serial_ext.py index a51ef69ea4..fbfafd79df 100644 --- a/tools/idf_py_actions/serial_ext.py +++ b/tools/idf_py_actions/serial_ext.py @@ -95,7 +95,9 @@ def action_extensions(base_actions, project_path): if project_desc['target'] != 'linux': if no_reset and args.port is None: - sys.stderr.write('WARNING: --no-reset is ignored. Please specify the port with the --port argument in order to use this option.\n') + msg = ('WARNING: --no-reset is ignored. ' + 'Please specify the port with the --port argument in order to use this option.') + yellow_print(msg) no_reset = False esp_port = args.port or _get_default_serial_port(args) @@ -269,7 +271,7 @@ def action_extensions(base_actions, project_path): 'if this option is set. This option is set by default if IDF Monitor was invoked ' 'together with encrypted-flash or encrypted-app-flash target.'), }, { - 'names': ['--no-reset', '-R'], + 'names': ['--no-reset'], 'is_flag': True, 'help': ('Disable reset on monitor startup. ' 'IDF Monitor will not reset the MCU target by toggling DTR/RTS lines on startup '