From 8934233b0b6eed6f2e626b1f789dacf580495942 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Wed, 11 Jan 2023 13:52:37 +0100 Subject: [PATCH] tools: fix unnecessary port detection for multiple targets When multiple targets are specified, e.g. idf.py flash monitor, the automatic port detection is performed twice. Keep the port value in args.port and avoid multiple calls to get_default_serial_port(). Signed-off-by: Frantisek Hrbata --- tools/idf_py_actions/debug_ext.py | 6 +++--- tools/idf_py_actions/serial_ext.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/idf_py_actions/debug_ext.py b/tools/idf_py_actions/debug_ext.py index a2617e08def..71e59c846e1 100644 --- a/tools/idf_py_actions/debug_ext.py +++ b/tools/idf_py_actions/debug_ext.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 import json import os @@ -149,11 +149,11 @@ def _get_espcoredump_instance(ctx: Context, coredump_to_flash = coredump_to_flash_config.rstrip().endswith('y') if coredump_to_flash_config else False prog = os.path.join(project_desc['build_dir'], project_desc['app_elf']) - esp_port = args.port or get_default_serial_port() + args.port = args.port or get_default_serial_port() espcoredump_kwargs = dict() - espcoredump_kwargs['port'] = esp_port + espcoredump_kwargs['port'] = args.port espcoredump_kwargs['baud'] = args.baud espcoredump_kwargs['gdb_timeout_sec'] = gdb_timeout_sec diff --git a/tools/idf_py_actions/serial_ext.py b/tools/idf_py_actions/serial_ext.py index 92c36701cff..d7c5e71c7ff 100644 --- a/tools/idf_py_actions/serial_ext.py +++ b/tools/idf_py_actions/serial_ext.py @@ -95,8 +95,8 @@ def monitor(action: str, ctx: click.core.Context, args: PropertyDict, print_filt yellow_print(msg) no_reset = False - esp_port = args.port or get_default_serial_port() - monitor_args += ['-p', esp_port] + args.port = args.port or get_default_serial_port() + monitor_args += ['-p', args.port] baud = monitor_baud or os.getenv('IDF_MONITOR_BAUD') or os.getenv('MONITORBAUD') @@ -163,8 +163,8 @@ def flash(action: str, ctx: click.core.Context, args: PropertyDict) -> None: yellow_print('skipping flash since running on linux...') return - esp_port = args.port or get_default_serial_port() - run_target(action, args, {'ESPBAUD': str(args.baud), 'ESPPORT': esp_port}) + args.port = args.port or get_default_serial_port() + run_target(action, args, {'ESPBAUD': str(args.baud), 'ESPPORT': args.port}) def erase_flash(action: str, ctx: click.core.Context, args: PropertyDict) -> None: ensure_build_directory(args, ctx.info_name)