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 crate    | What runs on the twin                 | Bug caught before silicon                                    |
| ---------------- | ------------------------------------- | ------------------------------------------------------------ |
| embassy-executor | WFE/WFI sleep and PendSV task wakeups | Missing NVIC interrupt enable stalling an async task forever |
| embassy-time     | Hardware TIM / RTC compare alarms     | Clock tree mismatch shifting Timer::after\_millis()          |
| embassy-stm32    | I2C/SPI/USART async DMA transfers     | Wrong DMA channel or stuck NACK without timeout              |
| defmt / RTT      | Console output and panic capture      | Silent 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

| Symptom                             | Fix                                                                                          |
| ----------------------------------- | -------------------------------------------------------------------------------------------- |
| Async future hangs on first await   | Verify bind\_interrupts! maps the exact peripheral IRQ vector used by your board twin.       |
| defmt logs do not appear in stdout  | Enable UART logging or capture the RTT control block via ct run --rtt.                       |
| Exit code 4 on unused RCC clock bit | Check the JSON diagnostic register name and match Embassy RCC config to the board HSE clock. |

## Frequently asked questions

| Question                                                             | Answer                                                                                                                                         |
| -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| 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

[Board: nucleo-f767zi](https://circuittwin.ai/boards/nucleo-f767zi) [Board: nrf52840-dk](https://circuittwin.ai/boards/nrf52840-dk) [Board: rpi-pico](https://circuittwin.ai/boards/rpi-pico) [Board: rpi-pico2](https://circuittwin.ai/boards/rpi-pico2) [Twin: SHT40](https://circuittwin.ai/twins/sht40) [Twin: BME280](https://circuittwin.ai/twins/bme280) [Twin: LSM6DSO](https://circuittwin.ai/twins/lsm6dso) [ct CLI reference](https://circuittwin.ai/docs/cli) [Suite & fault reference](https://circuittwin.ai/docs/testing)

## More in RTOS & Firmware Stacks

[Zephyr RTOS CI without hardware benches](https://circuittwin.ai/guides/zephyr-rtos-ci-without-hardware) [FreeRTOS headless testing in CI](https://circuittwin.ai/guides/freertos-headless-testing) [ESP-IDF CI simulation for ESP32, S3 & C3](https://circuittwin.ai/guides/esp-idf-ci-simulation) [PX4 Pixhawk 6C simulation on real ARM ELF](https://circuittwin.ai/guides/px4-pixhawk-6c-simulation)

> ## Run this workflow on your own ELF
>
> Start free on CircuitTwin to run local board twins, fault matrices and CI checks with zero per-run credits.
>
> [Start now](https://app.circuittwin.ai/try) [Read the quickstart](https://circuittwin.ai/docs/quickstart) [Connect a coding agent](https://circuittwin.ai/docs/agents)
