RTOS & Firmware Stacks

Rust Embassy async firmware CI without boards

Test real Embassy async executors, WFI sleep loops and DMA futures on STM32, nRF52840 and RP2040 board twins.

Host unit tests cannot exercise Embassy interrupt wakers or peripheral register traits. Your code compiles cleanly on x86, yet deadlocks on hardware when an interrupt flag stays uncleared.

CircuitTwin runs the thumbv7em-none-eabihf or thumbv6m-none-eabi ELF directly from cargo build. Async tasks wake on virtual-time timer ticks and DMA completion IRQs, so CI catches stuck futures and I2C NACK timeouts on every commit.

Embassy subsystems verified on board twins

Embassy crateWhat runs on the twinBug caught before silicon
embassy-executorWFE/WFI sleep and PendSV task wakeupsMissing NVIC interrupt enable stalling an async task forever
embassy-timeHardware TIM / RTC compare alarmsClock tree mismatch shifting Timer::after_millis()
embassy-stm32I2C/SPI/USART async DMA transfersWrong DMA channel or stuck NACK without timeout
defmt / RTTConsole output and panic captureSilent unwrap() panic inside an async driver loop

Local CLI workflow

Shell - build and run Rust Embassy ELF
cargo build --release --target thumbv7em-none-eabihf
ct run --json --board nucleo-f767zi target/thumbv7em-none-eabihf/release/app
ct test run --json --junit results/embassy.xml tests/embassy.suite.yaml

Suite & fault configuration

tests/embassy.suite.yaml
version: 1
board: nucleo-f767zi
firmware: target/thumbv7em-none-eabihf/release/app
tests:
  - name: embassy-i2c-timeout-recovery
    timeout_ms: 2500
    faults:
      - at_ms: 80
        bus: I2C1
        kind: nack
        address: 0x44
        count: 3
    expect:
      console_contains: "I2C_RECOVERED"
      exit_code: 0

CI pipeline integration

.github/workflows/rust-embassy-ci.yml
name: Rust Embassy Twin CI
on: [push, pull_request]
jobs:
  embassy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: thumbv7em-none-eabihf
      - run: cargo build --release --target thumbv7em-none-eabihf
      - uses: circuittwin/action@v1
        with:
          suite: tests/embassy.suite.yaml
          junit-out: results/embassy.xml

Troubleshooting checklist

SymptomFix
Async future hangs on first awaitVerify bind_interrupts! maps the exact peripheral IRQ vector used by your board twin.
defmt logs do not appear in stdoutEnable UART logging or capture the RTT control block via ct run --rtt.
Exit code 4 on unused RCC clock bitCheck the JSON diagnostic register name and match Embassy RCC config to the board HSE clock.

Frequently asked questions

QuestionAnswer
Does CircuitTwin require modifying Cargo.toml or Embassy HAL traits?No. Build your normal embedded Rust ELF with cargo build and pass the compiled binary path directly to ct run.
Can CI catch Embassy executor deadlocks when a sensor NACKs?Yes. Inject an I2C NACK fault at a fixed timestamp and set timeout_ms in suite.yaml so a hung await fails the pull request deterministically.

Related boards & component twins

More in RTOS & Firmware Stacks