Skip to content

Commit

Permalink
tools: fix unnecessary port detection for multiple targets
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
fhrbata committed Jan 11, 2023
1 parent 1d2469f commit 8934233
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions tools/idf_py_actions/debug_ext.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions tools/idf_py_actions/serial_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8934233

Please sign in to comment.