From e894d66826606da03be9324b5bd45d43ccce070c Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 17 Jul 2024 05:15:08 +0200 Subject: [PATCH] feat: Also set ESPTOOL_RETRY_OPEN_SERIAL when --retry-open is set This is needed in order to properly invoke esptool with --retry-open-serial through idf.py (with a patch coming later on) --- esp_idf_monitor/base/constants.py | 1 + esp_idf_monitor/idf_monitor.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/esp_idf_monitor/base/constants.py b/esp_idf_monitor/base/constants.py index d85d343..8ccda8d 100644 --- a/esp_idf_monitor/base/constants.py +++ b/esp_idf_monitor/base/constants.py @@ -45,6 +45,7 @@ EVENT_QUEUE_TIMEOUT = 0.03 # timeout before raising queue.Empty exception in case of empty event queue ESPPORT_ENVIRON = str('ESPPORT') +ESPTOOL_RETRY_OPEN_SERIAL_ENVIRON = str('ESPTOOL_RETRY_OPEN_SERIAL') MAKEFLAGS_ENVIRON = 'MAKEFLAGS' GDB_UART_CONTINUE_COMMAND = '+$c#63' diff --git a/esp_idf_monitor/idf_monitor.py b/esp_idf_monitor/idf_monitor.py index 1227eb6..f575c54 100644 --- a/esp_idf_monitor/idf_monitor.py +++ b/esp_idf_monitor/idf_monitor.py @@ -44,6 +44,7 @@ DEFAULT_TARGET_RESET, DEFAULT_TOOLCHAIN_PREFIX, ESPPORT_ENVIRON, + ESPTOOL_RETRY_OPEN_SERIAL_ENVIRON, EVENT_QUEUE_TIMEOUT, GDB_EXIT_TIMEOUT, GDB_UART_CONTINUE_COMMAND, @@ -90,7 +91,7 @@ def __init__( make='make', # type: str encrypted=False, # type: bool reset=DEFAULT_TARGET_RESET, # type: bool - retry_open=False, # type: bool + retry_open=False, # type: bool toolchain_prefix=DEFAULT_TOOLCHAIN_PREFIX, # type: str eol='CRLF', # type: str decode_coredumps=COREDUMP_DECODE_INFO, # type: str @@ -398,7 +399,8 @@ def main() -> None: # has a check for this). # To make sure the key as well as the value are str type, by the requirements of subprocess espport_val = str(args.port) - os.environ.update({ESPPORT_ENVIRON: espport_val}) + retryopen_val = str(args.retry_open) + os.environ.update({ESPPORT_ENVIRON: espport_val, ESPTOOL_RETRY_OPEN_SERIAL_ENVIRON: retryopen_val}) cls = SerialMonitor yellow_print('--- esp-idf-monitor {v} on {p.name} {p.baudrate} ---'.format(v=__version__, p=serial_instance))