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

LayerVerified behaviorFailure caught
Boot & frozen main.pyREPL banner and startup script executionSyntaxError or MemoryError during boot
C user modulesMemory layout and FFI register callsHardFault or GC pointer corruption
machine.I2C / SPIReal register reads from attached twinsUnhandled 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.elf

Suite & 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: 0

CI 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.yaml

Troubleshooting checklist

SymptomFix
REPL prompt never appears on consoleConfirm MICROPY_HW_UART_REPL matches the board VCP UART (USART3 on NUCLEO-F767ZI).
OSError ENODEV when scanning I2C busVerify the twin address matches your Python driver (0x76 vs 0x77 on BME280).

Frequently asked questions

QuestionAnswer
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.

Related boards & component twins

More in RTOS & Firmware Stacks