fix(tools): Detect serial port matching the project target

Auto-detect used to pick the first Espressif device, even when it did
not match IDF_TARGET. With several boards attached, flash/monitor could
talk to the wrong chip.

Pass the project target into esptool so unmatched ports are skipped.
Resolve the port after ensure_build_directory() so the target is known.
For monitor on an unconfigured project, probe the connected chip and
pass it directly to idf_monitor without configuring the project.
This commit is contained in:
Vojtech Piroch
2026-09-02 17:18:57 +08:00
committed by BOT
parent c5517c21f1
commit 19676ffa46
5 changed files with 347 additions and 51 deletions
+7
View File
@@ -241,6 +241,13 @@ The ROM ELF file is automatically loaded from a location based on the ``IDF_PATH
Set environment variable ``ESP_MONITOR_DECODE`` to ``0`` or call esp_idf_monitor with specific command line option: ``python -m esp_idf_monitor --disable-address-decoding`` to disable address decoding.
.. _idf-monitor-target-detection:
Automatic Target Detection
~~~~~~~~~~~~~~~~~~~~~~~~~~
By default, ``idf.py monitor`` connects to the target that has been set for the project. However, on an unbuilt project where no target has been configured, it can connect to any target — it will automatically detect the chip on the default serial port and pass it to the monitor. This allows running ``idf.py monitor`` on a clean project without having to call ``idf.py set-target`` first.
Target Reset on Connection
~~~~~~~~~~~~~~~~~~~~~~~~~~