diff options
author | Jos Verlinde <Jos_Verlinde@hotmail.com> | 2025-07-28 16:52:11 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-08-01 14:58:20 +1000 |
commit | dea949e860c0adc615171d25c7df79b59639f8ed (patch) | |
tree | 98fdec625f33ffc3cb4cb195ad68c2a82ac00fa3 | |
parent | 4ba626ab5a6c47588d25c40ac1dc20d59e33760d (diff) |
tools/mpremote: Update ESPxxx detection for USB-CDC ports.
Detection of ESP-XX devices was based on just the names of the USB driver
name, and did not account for the switch of the newer ESP-xx devices to
USB-CDC. On Windows this caused unwanted/unneeded resets as the DTR/RTS
signals are also used for automatic device reset over USB-CDC. See
https://github.com/micropython/micropython/issues/9659#issuecomment-3124704572
This commit uses the Espressif registered VID 0x303A to detect USB-CDC
ports, to enable the same DTR/RTS settings as used on the UART-USB
connection.
Also improved the robustness of the code using `getattr()`.
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
-rw-r--r-- | tools/mpremote/mpremote/transport_serial.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/mpremote/mpremote/transport_serial.py b/tools/mpremote/mpremote/transport_serial.py index 53fc48553..daeff02b5 100644 --- a/tools/mpremote/mpremote/transport_serial.py +++ b/tools/mpremote/mpremote/transport_serial.py @@ -40,6 +40,8 @@ from errno import EPERM from .console import VT_ENABLED from .transport import TransportError, TransportExecError, Transport +VID_ESPRESSIF = 0x303A # Espressif Incorporated + class SerialTransport(Transport): fs_hook_mount = "/remote" # MUST match the mount point in fs_hook_code @@ -71,7 +73,10 @@ class SerialTransport(Transport): self.serial = serial.Serial(**serial_kwargs) self.serial.port = device portinfo = list(serial.tools.list_ports.grep(device)) # type: ignore - if portinfo and portinfo[0].manufacturer != "Microsoft": + if portinfo and ( + getattr(portinfo[0], "vid", 0) == VID_ESPRESSIF + or getattr(portinfo[0], "manufacturer", "") != "Microsoft" + ): # ESP8266/ESP32 boards use RTS/CTS for flashing and boot mode selection. # DTR False: to avoid using the reset button will hang the MCU in bootloader mode # RTS False: to prevent pulses on rts on serial.close() that would POWERON_RESET an ESPxx |