MCU Testing & CI

# STM32F4 firmware testing without hardware

Run your STM32F4 Cortex-M4F ELF across NUCLEO-F446RE, NUCLEO-F411RE, Black Pill and STM32F4-Discovery twins in under three seconds per suite.

STM32F4 parts power motor drives, sensor hubs and legacy industrial controllers. Physical F4 benches drift over time: loose jumper wires, browned-out USB hubs and flaky ST-LINK firmware turn CI jobs red for the wrong reason.

CircuitTwin runs the Cortex-M4F binary deterministically with fixed virtual clocks, verified against the ARMv7E-M FPv4 differential suite and HAL ADC oracle on STM32F4-Discovery.

## STM32F4 board twins

| Board slug        | MCU & Clock           | Key use case                                     |
| ----------------- | --------------------- | ------------------------------------------------ |
| stm32f4-discovery | STM32F407VG @ 168 MHz | Full-feature F407 with bxCAN, DMA, ADC oracle    |
| nucleo-f446re     | STM32F446RE @ 180 MHz | Dual bxCAN and high-speed SPI motor/sensor nodes |
| nucleo-f411re     | STM32F411RE @ 100 MHz | Low-power sensor fusion and I2C/SPI controllers  |
| black-pill-f411ce | STM32F411CE @ 100 MHz | Compact carrier modules and 3D printer boards    |

## Local CLI workflow

Shell — run STM32F4 test matrix

```
ct run --json --board stm32f4-discovery build/f407.elf
ct test matrix run --json tests/f4-fault-matrix.yaml
```

## Suite & fault configuration

tests/f4-fault-matrix.yaml

```
version: 1
board: nucleo-f446re
firmware: build/f446.elf
matrix:
  - name: i2c-pullup-drop
    faults:
      - at_ms: 50
        bus: I2C1
        kind: nack
        address: 0x40
        count: 2
  - name: spi-sensor-disconnect
    faults:
      - at_ms: 100
        part: lis3dh
        kind: bus_disconnect
        duration_ms: 30
```

## CI pipeline integration

.gitlab-ci.yml — STM32F4 job

```
stm32f4-twin-test:
  image: ubuntu:24.04
  script:
    - make -j BOARD=nucleo_f446re
    - ct test run --json --junit f446-junit.xml tests/f4-fault-matrix.yaml
  artifacts:
    reports:
      junit: f446-junit.xml
```

## Troubleshooting checklist

| Symptom                                  | Fix                                                                                        |
| ---------------------------------------- | ------------------------------------------------------------------------------------------ |
| ADC conversion hangs waiting on EOC flag | Verify RCC\_APB2ENR.ADC1EN and channel sequence length ADC\_SQR1.L match your HAL init.    |
| USART2 prints garbage at 115200 bps      | Check APB1 prescaler (42 MHz on F407, 45 MHz on F446) in the UART Baud Calculator.         |
| bxCAN stays stuck in INAK mode           | Confirm CAN1 clock is enabled before CAN2 (CAN2 is slave to CAN1 filter banks on STM32F4). |
| ISR misses flag clear and loops forever  | Run with --record trace/ and inspect repeated IRQ entry timestamps in the JSONL trace.     |

## Related boards & component twins

[Board: stm32f4-discovery](https://circuittwin.ai/boards/stm32f4-discovery) [Board: nucleo-f446re](https://circuittwin.ai/boards/nucleo-f446re) [Board: nucleo-f411re](https://circuittwin.ai/boards/nucleo-f411re) [Board: black-pill-f411ce](https://circuittwin.ai/boards/black-pill-f411ce) [Twin: LIS3DH](https://circuittwin.ai/twins/lis3dh) [Twin: MPU-6050](https://circuittwin.ai/twins/mpu-6050) [Twin: INA219](https://circuittwin.ai/twins/ina219) [Test suites & fault matrices](https://circuittwin.ai/docs/testing) [Accuracy report](https://circuittwin.ai/docs/accuracy)

## More in MCU Testing & CI

[STM32F7 firmware CI without a bench](https://circuittwin.ai/guides/stm32f7-firmware-ci) [STM32H7 digital twin CI for H743 & H747](https://circuittwin.ai/guides/stm32h7-digital-twin-ci) [STM32F103 Blue Pill & NUCLEO-F103RB simulation](https://circuittwin.ai/guides/stm32f103-bluepill-simulation) [Nordic nRF52840 firmware CI without hardware](https://circuittwin.ai/guides/nrf52840-firmware-ci)

> ## Run this workflow on your own ELF
>
> Start free on CircuitTwin to run local board twins, fault matrices and CI checks with zero per-run credits.
>
> [Start now](https://app.circuittwin.ai/try) [Read the quickstart](https://circuittwin.ai/docs/quickstart) [Connect a coding agent](https://circuittwin.ai/docs/agents)
