RTOS & Firmware Stacks
MCUboot A/B image swap and rollback testing in CI
Flash combined bootloader plus slot-0 and slot-1 images into a board twin and prove bad OTA updates revert cleanly.
OTA bootloaders fail in the field when power drops mid-swap or an unconfirmed image crashes before calling boot_set_confirmed(). Testing rollback manually requires repeated JTAG reflashing.
CircuitTwin models internal MCU Flash and external SPI NOR Flash (W25Q128JV) erase/program semantics, letting CI test corrupted trailers, bad ECDSA signatures and watchdog-triggered slot reverts automatically.
MCUboot CI test cases
| Scenario | Fault / Condition | Expected boot result |
|---|---|---|
Valid test upgrade | Slot 1 signed image, not confirmed | Boots slot 1 once, then reverts to slot 0 after reset |
Bad signature | Flip 1 byte in slot 1 TLV payload | MCUboot rejects slot 1 and boots slot 0 |
Confirmed upgrade | App calls boot_set_confirmed() | Slot 1 stays permanent across power cycles |
Local CLI workflow
Shell - run MCUboot swap and rollback suite
ct test run --json --junit results/mcuboot.xml tests/mcuboot-rollback.suite.yamlSuite & fault configuration
tests/mcuboot-rollback.suite.yaml
version: 1
board: nucleo-f767zi
firmware: build/merged_mcuboot_ab.hex
tests:
- name: unconfirmed-image-reverts-on-reset
timeout_ms: 5000
expect:
console_contains: "REVERTED_TO_SLOT0"
exit_code: 0CI pipeline integration
.github/workflows/mcuboot-ci.yml
name: MCUboot OTA Rollback CI
on: [push, pull_request]
jobs:
mcuboot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./scripts/build_mcuboot_ab.sh
- uses: circuittwin/action@v1
with:
suite: tests/mcuboot-rollback.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| Bootloader jumps to wrong application reset address | Verify SCB->VTOR relocation and --header-size alignment match imgtool sign parameters. |
| External SPI flash swap fails on erase | Confirm W25Q128JV 4 KB sector erase alignment matches BOOT_MAX_IMG_SECTORS. |
Frequently asked questions
| Question | Answer |
|---|---|
| Can CircuitTwin load merged Intel HEX images containing bootloader plus two slots? | Yes. Pass merged .hex or multi-image flash maps to ct run and verify the full reset-to-application handoff. |