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

ScenarioFault / ConditionExpected boot result
Valid test upgradeSlot 1 signed image, not confirmedBoots slot 1 once, then reverts to slot 0 after reset
Bad signatureFlip 1 byte in slot 1 TLV payloadMCUboot rejects slot 1 and boots slot 0
Confirmed upgradeApp 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.yaml

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

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

Troubleshooting checklist

SymptomFix
Bootloader jumps to wrong application reset addressVerify SCB->VTOR relocation and --header-size alignment match imgtool sign parameters.
External SPI flash swap fails on eraseConfirm W25Q128JV 4 KB sector erase alignment matches BOOT_MAX_IMG_SECTORS.

Frequently asked questions

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

Related boards & component twins

More in RTOS & Firmware Stacks