Skip to content

Commit 4651a02

Browse files
sylvioalveskartben
authored andcommitted
twister: reset ESP32 via RTS/DTR to capture early boot logs
When testing ESP32-based platforms in CI, early boot logs can be missed if the serial connection isn't reset properly. This patch applies the standard RTS/DTR toggle sequence to reset the ESP32 after flashing, ensuring consistent log capture from the very beginning. The logic is applied conditionally when the runner is "esp32". Signed-off-by: Sylvio Alves <[email protected]>
1 parent 15744c2 commit 4651a02

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

scripts/pylib/twister/twisterlib/handlers.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,27 @@ def handle(self, harness):
829829
ser_pty_process = self._start_serial_pty(serial_pty, ser_pty_master)
830830
logger.debug(f"Attach serial device {serial_device} @ {hardware.baud} baud")
831831
ser.port = serial_device
832-
ser.open()
832+
833+
# Apply ESP32-specific RTS/DTR reset logic
834+
if runner == "esp32":
835+
logger.debug("Applying ESP32 RTS/DTR reset sequence")
836+
837+
# Prepare: IO0=HIGH (DTR=True), EN=HIGH (RTS=False)
838+
ser.dtr = True
839+
ser.rts = False
840+
841+
ser.open()
842+
843+
# Reset pulse: IO0=LOW (DTR=False), EN=LOW (RTS=True)
844+
ser.dtr = False
845+
ser.rts = True
846+
time.sleep(0.01)
847+
848+
# Return to normal boot
849+
ser.rts = False
850+
else:
851+
ser.open()
852+
833853
except serial.SerialException as e:
834854
self._handle_serial_exception(e, hardware, serial_pty, ser_pty_process)
835855
return

0 commit comments

Comments
 (0)