Back to resources
HIL
Testing
CI
Firmware

STM32 Hardware-in-the-Loop Testing in CI: Flash, Power and Assert on a Real Board

Flash an STM32 over SWD from CI, power-cycle it, read its UART and check its pins on every commit with a BenchPod and pytest. Tested on a NUCLEO-F446RE, works across the STM32 families.

Edward Viaene · November 23, 2026 · 2 min read

Unit tests and an emulator tell you the logic is right. They don't tell you that the build still boots on the chip, that the UART prints what it should, or that a GPIO changes when it should. For an STM32 project that check is cheap to automate: a BenchPod flashes the board over SWD, powers it, and lets a pytest assert on what it does.

What is tested, and what is supported

We run this on a NUCLEO-F446RE on our own bench. It is flashed in our hardware tests over the local network and through the cloud, and it is the board behind most of our examples. That makes the STM32F4 Tested.

The rest of the STM32 range (F0, F1, F3, F7, G0, G4, H7, L0, L4, U5, WB and more) uses the same flash path, with a different OpenOCD target file. Those are Supported: if one does not work on your board, tell us which board and what you see, and we make it work. What supported means explains why we can do that.

Wiring

The pod needs four things from the board: SWDIO, SWCLK and the reset line (so it can connect even when your firmware turns SWD off), the UART TX and RX for a console, and at least two grounds. Everything runs at 1.8 or 3.3 V. The SWD page has the details per family.

A test that flashes and boots

import pytest

@pytest.mark.hardware
def test_firmware_boots(benchpod, wiring, firmware):
    assert benchpod.flash(
        file=firmware, target="target/stm32f4x.cfg",
        swclk=wiring.swclk, swdio=wiring.swdio,
        target_power=wiring.efuse,
    ).ok

    benchpod.power_off(wiring.efuse)
    benchpod.power_on(wiring.efuse, delay=1.5)
    with benchpod.open_uart(rx=wiring.uart_rx, tx=wiring.uart_tx) as uart:
        assert uart.read_until(r"APP_OK", timeout=12), uart.text

For another family, change the target file: target/stm32h7x.cfg, target/stm32l4x.cfg, and so on. Nothing else in the test changes.

Run it on every commit

The same test runs from GitHub Actions against a pod on your bench or in the cloud, so a pull request fails when the firmware no longer boots. From there you can add I2C and SPI register checks, timing measurements and power-loss tests to the same job.

Next steps