Almost every microcontroller decides how to start from a pin it reads at reset. STM32 parts look at BOOT0, an ESP32 looks at GPIO0, plenty of custom boards add a strap for "factory mode" or "recovery". Those paths matter (they're how you recover a bricked device in the field), and they're usually tested by someone moving a jumper, pressing reset and squinting at a terminal.
That doesn't run in CI. So we put the strap pin and the reset line on the BenchPod and made it a test.
What's on the wires
Nothing special. The pod has 14 generic channels, and any of them can be a GPIO. For a strap test you need two signals and a console. In the code below the channels go by the names in the bench's wiring profile (BOOT0, uart_rx); channel numbers work too.
| Signal | Board | BenchPod |
|---|---|---|
| Strap pin | BOOT0, GPIO0, your recovery strap | an LA channel as GPIO |
| Reset | NRST | the pod's dedicated reset pin |
| Console | the bootloader's UART | two LA channels as UART |
The reset pin is its own line on the pod (rev 3 boards), so it doesn't use up a channel. There's no dedicated "boot pin" feature, and there doesn't need to be: a strap pin is a GPIO that has to hold still while the chip comes out of reset.
Open-drain or push-pull: check which way the strap goes
This is the one thing to get right. A GPIO channel on the pod runs in three modes: output (push-pull), open_drain (0 pulls low, 1 lets go) and input.
- Active-low straps (an ESP32's GPIO0, most "hold low for recovery" pins) want open-drain. Release it and the board's own pull-up keeps the normal boot; pull it low and you get the other mode. The pod never fights the board's resistor.
- Active-high straps (STM32 BOOT0, which has a pull-down on most boards) need push-pull. Open-drain can't drive a pin high; "released" would just leave the pull-down in charge and you'd never reach the bootloader.
Set the pod's LA voltage to the board's I/O voltage (1.8 V or 3.3 V) before you drive anything; the pod refuses UART and captures until it's set. And mark the board's own outputs in the wiring profile: the pod won't drive a pin your wiring says the board drives.
An STM32 into its system bootloader
STM32 parts have a ROM bootloader. Hold BOOT0 high through reset and the chip starts it instead of your firmware. On its UART it waits for a 0x7F byte, and answers 0x79 (an ACK) when it's ready. 0x79 happens to be the ASCII letter y, which makes it easy to read back. Which USART the bootloader listens on depends on the part; ST's AN2606 has the table.
from embeddedci.benchpod import BenchPod
with BenchPod("192.168.1.150", la_voltage=3.3) as bp:
boot0 = bp.gpio("BOOT0", "output", level=0) # push-pull: BOOT0 is active-high
# Normal boot: BOOT0 low, pulse reset, the application prints its banner.
with bp.open_uart(rx="uart_rx", tx="uart_tx", baud=115200) as uart:
bp.reset_target(pulse=0.05)
assert uart.read_until("APP_OK", timeout=3) is not None
# Bootloader: hold BOOT0 high through reset, then talk to the ROM.
boot0.high()
bp.reset_target(pulse=0.05)
with bp.open_uart(rx="uart_rx", tx="uart_tx", baud=115200) as uart:
uart.write(b"\x7f") # autobaud byte
assert uart.read_until("y", timeout=1) is not None # 0x79 = ACK
boot0.low()
bp.reset_target(pulse=0.05) # leave the board running its app
boot0.release()reset_target pulses the line for the time you give it (up to a second) and returns when the board is running again. If you need the board held in reset while you set up a capture, bp.set_reset(True) holds it and bp.set_reset(False) lets go.
One detail on the system bootloader: it talks 8 data bits with even parity, and the pod's UART runs 8N1. For this handshake that doesn't matter. Both 0x7F and 0x79 have an even-parity bit of 1, which looks exactly like a stop bit, so the 8N1 port sends and reads them correctly. Going further than the ACK (reading the chip ID, flashing over UART) needs a port that does even parity.
An ESP32 into download mode
The ESP32 is the active-low case. GPIO0 low at reset means download mode, and the ROM says so on UART0 at 115200 baud before the application would have printed anything:
with BenchPod("192.168.1.150", la_voltage=3.3) as bp:
gpio0 = bp.gpio("GPIO0", "open_drain") # starts released: the board's pull-up wins
gpio0.low()
with bp.open_uart(rx="uart_rx", tx="uart_tx", baud=115200) as uart:
bp.reset_target(pulse=0.05)
boot = uart.read_until("waiting for download", timeout=2)
assert boot is not None and "DOWNLOAD" in boot
gpio0.high() # release, normal boot
with bp.open_uart(rx="uart_rx", tx="uart_tx", baud=115200) as uart:
bp.reset_target(pulse=0.05)
assert uart.read_until("APP_OK", timeout=5) is not NoneThe ROM's boot:0x.. line spells out what it sampled on the strap pins, so the same capture also catches a strap that's wired wrong on a new board revision.
Two straps at once
Some parts read more than one pin, and some boards have a strap plus an enable. gpio_pins claims a group in one command: either all of them become GPIO or none do, so a conflict on one channel doesn't leave half the group claimed.
boot0, recovery = bp.gpio_pins(["BOOT0", "RECOVERY"], "open_drain")
bp.set_gpio(["BOOT0", "RECOVERY"], 0) # both low at onceWhy this belongs in CI
The tests above take a few seconds. What they catch:
- A bootloader that stopped answering. Option bytes, a security setting or a flash layout change can disable the ROM bootloader. You find out from the test, not from a returned unit.
- A recovery path that broke. Your own "hold this pin for factory reset" code runs once in the life of most devices. That's the one that's never tested.
- A strap that moved on a new board revision. The hardware team swapped a resistor, the default boot mode changed, and the first sign is a board that won't start your app.
- Firmware that drives a strap pin too early. If the application uses BOOT0's pin as a GPIO after boot, check that a reset still samples the level you expect.
A normal-boot test and a bootloader test side by side cover both branches of the reset path, and they're the same few lines on every board.
Where to go next
The pin modes, la_dir and the reset calls are in the pytest docs, and the MCP server has the same calls as tools (gpio_mode, gpio_write, reset_target), so you can ask an agent to "put the board in its bootloader and read the chip ID". For the boot path after the strap, see Catching Boot Regressions, and to cut power in the middle of an update instead, see Power Sequencing and Brown-Out Testing.