Skip to content

Commit dea949e

Browse files
Josverldpgeorge
authored andcommitted
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 micropython#9659 (comment) 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 <[email protected]>
1 parent 4ba626a commit dea949e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/mpremote/mpremote/transport_serial.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
from .console import VT_ENABLED
4141
from .transport import TransportError, TransportExecError, Transport
4242

43+
VID_ESPRESSIF = 0x303A # Espressif Incorporated
44+
4345

4446
class SerialTransport(Transport):
4547
fs_hook_mount = "/remote" # MUST match the mount point in fs_hook_code
@@ -71,7 +73,10 @@ def __init__(self, device, baudrate=115200, wait=0, exclusive=True, timeout=None
7173
self.serial = serial.Serial(**serial_kwargs)
7274
self.serial.port = device
7375
portinfo = list(serial.tools.list_ports.grep(device)) # type: ignore
74-
if portinfo and portinfo[0].manufacturer != "Microsoft":
76+
if portinfo and (
77+
getattr(portinfo[0], "vid", 0) == VID_ESPRESSIF
78+
or getattr(portinfo[0], "manufacturer", "") != "Microsoft"
79+
):
7580
# ESP8266/ESP32 boards use RTS/CTS for flashing and boot mode selection.
7681
# DTR False: to avoid using the reset button will hang the MCU in bootloader mode
7782
# RTS False: to prevent pulses on rts on serial.close() that would POWERON_RESET an ESPxx

0 commit comments

Comments
 (0)