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>
This commit is contained in:
committed by
Damien George
parent
4ba626ab5a
commit
dea949e860
@@ -40,6 +40,8 @@ from errno import EPERM
|
|||||||
from .console import VT_ENABLED
|
from .console import VT_ENABLED
|
||||||
from .transport import TransportError, TransportExecError, Transport
|
from .transport import TransportError, TransportExecError, Transport
|
||||||
|
|
||||||
|
VID_ESPRESSIF = 0x303A # Espressif Incorporated
|
||||||
|
|
||||||
|
|
||||||
class SerialTransport(Transport):
|
class SerialTransport(Transport):
|
||||||
fs_hook_mount = "/remote" # MUST match the mount point in fs_hook_code
|
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 = serial.Serial(**serial_kwargs)
|
||||||
self.serial.port = device
|
self.serial.port = device
|
||||||
portinfo = list(serial.tools.list_ports.grep(device)) # type: ignore
|
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.
|
# 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
|
# 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
|
# RTS False: to prevent pulses on rts on serial.close() that would POWERON_RESET an ESPxx
|
||||||
|
|||||||
Reference in New Issue
Block a user