diff options
author | Jos Verlinde <jos_verlinde@hotmail.com> | 2023-03-19 21:42:56 +0000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-04-04 13:30:05 +1000 |
commit | 9f74ffb6eb8a65206bc7a31240e07054b19d7afc (patch) | |
tree | 66845bf5cf716d999f52fcfc0760051815390db9 /tools | |
parent | 783ddfc264c8c36253a4279ef501f02f8cac1200 (diff) | |
download | micropython-9f74ffb6eb8a65206bc7a31240e07054b19d7afc.tar.gz micropython-9f74ffb6eb8a65206bc7a31240e07054b19d7afc.zip |
tools/pyboard.py: Fix ESPxx boards hanging in bootloader after reset.
This is a follow up to d263438a6e365d3199494498a9b734cda29dde52, which
solved one problem (reset on disconnect) but introduced a second one (hang
in bootloader).
To solve both probles, False/False is needed for DTR/RTS for ESPxx, but
that would then block stm32 and others. Any unconditional combination of
DTR/RTS ends up blocking normal operation on some type of board or another.
A simple overview (for windows only):
DTR CTS ESP8266/ESP32 STM32/SAMD51/RP2040
unspecified unspecified Reset on disconnect OK
True False Hang in bootloader OK
False False OK No Repl
True True Reset on disconnect No Repl
False True Reset on disconnect No Repl
serial.manufacturer: wch.cn/Silicon Labs Microsoft
serial.description: USB-SERIAL CH340 / USB Serial Device
CP210x USB to UART
Bridge
The updated logic will only set the DTR/RTS signals for boards that do not
use standard Microsoft drivers (based on the manufacturer). It would also
be possible to check against a list of known driver manufactures (like
wch.cn or Silicon Labs) but this would require a list of known drivers for
all ports.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/pyboard.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/pyboard.py b/tools/pyboard.py index 29af27f02b..c0bb778a32 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -287,11 +287,15 @@ class Pyboard: for attempt in range(wait + 1): try: if os.name == "nt": - # Windows does not set DTR or RTS by default self.serial = serial.Serial(**serial_kwargs) - self.serial.dtr = True - self.serial.rts = False self.serial.port = device + portinfo = list(serial.tools.list_ports.grep(device)) # type: ignore + if portinfo and 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 + self.serial.dtr = False # DTR False = gpio0 High = Normal boot + self.serial.rts = False # RTS False = EN High = MCU enabled self.serial.open() else: self.serial = serial.Serial(device, **serial_kwargs) |