RTOS & Firmware Stacks
MicroPython firmware and C-module CI
Boot compiled MicroPython firmware.elf images on board twins, drive REPL scripts over UART and inject real bus faults.
Custom MicroPython builds bundle native C modules and frozen bytecode that break silently when heap limits shrink or machine.I2C raises OSError. Testing on the unix port skips every real bus driver.
Running the cross-compiled firmware.elf on an STM32, RP2040 or ESP32-C3 board twin exercises the real C binding, REPL UART framing and attached sensor registers in CI.
MicroPython CI checks on twins
| Layer | Verified behavior | Failure caught |
|---|---|---|
Boot & frozen main.py | REPL banner and startup script execution | SyntaxError or MemoryError during boot |
C user modules | Memory layout and FFI register calls | HardFault or GC pointer corruption |
machine.I2C / SPI | Real register reads from attached twins | Unhandled OSError(ENODEV) on sensor NACK |
Local CLI workflow
Shell - run MicroPython ELF with sensor twin
make -C ports/stm32 BOARD=NUCLEO_F767ZI USER_C_MODULES=../../../modules/micropython.cmake
ct run --json --board nucleo-f767zi --device bme280 ports/stm32/build-NUCLEO_F767ZI/firmware.elfSuite & fault configuration
tests/micropython.suite.yaml
version: 1
board: nucleo-f767zi
firmware: ports/stm32/build-NUCLEO_F767ZI/firmware.elf
tests:
- name: repl-sensor-read-and-nack
timeout_ms: 4000
faults:
- at_ms: 1200
bus: I2C1
kind: nack
address: 0x76
count: 2
expect:
console_contains: "SENSOR_OK"
exit_code: 0CI pipeline integration
.github/workflows/micropython-ci.yml
name: MicroPython Twin CI
on: [push, pull_request]
jobs:
mpy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make -C ports/stm32 BOARD=NUCLEO_F767ZI
- uses: circuittwin/action@v1
with:
suite: tests/micropython.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| REPL prompt never appears on console | Confirm MICROPY_HW_UART_REPL matches the board VCP UART (USART3 on NUCLEO-F767ZI). |
| OSError ENODEV when scanning I2C bus | Verify the twin address matches your Python driver (0x76 vs 0x77 on BME280). |
Frequently asked questions
| Question | Answer |
|---|---|
| Why test MicroPython on an MCU twin instead of the MicroPython unix port? | The unix port lacks real STM32/RP2040/ESP32 machine.I2C, machine.SPI and DMA peripherals and cannot catch C-module memory faults or bus error handling. |