Skip to content

Commit 9f74ffb

Browse files
Josverldpgeorge
authored andcommitted
tools/pyboard.py: Fix ESPxx boards hanging in bootloader after reset.
This is a follow up to d263438, 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>
1 parent 783ddfc commit 9f74ffb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/pyboard.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,15 @@ def __init__(
287287
for attempt in range(wait + 1):
288288
try:
289289
if os.name == "nt":
290-
# Windows does not set DTR or RTS by default
291290
self.serial = serial.Serial(**serial_kwargs)
292-
self.serial.dtr = True
293-
self.serial.rts = False
294291
self.serial.port = device
292+
portinfo = list(serial.tools.list_ports.grep(device)) # type: ignore
293+
if portinfo and portinfo[0].manufacturer != "Microsoft":
294+
# ESP8266/ESP32 boards use RTS/CTS for flashing and boot mode selection.
295+
# DTR False: to avoid using the reset button will hang the MCU in bootloader mode
296+
# RTS False: to prevent pulses on rts on serial.close() that would POWERON_RESET an ESPxx
297+
self.serial.dtr = False # DTR False = gpio0 High = Normal boot
298+
self.serial.rts = False # RTS False = EN High = MCU enabled
295299
self.serial.open()
296300
else:
297301
self.serial = serial.Serial(device, **serial_kwargs)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy