RTOS & Firmware Stacks

# ESP-IDF CI simulation for ESP32, S3 & C3

Test ESP-IDF peripheral drivers, FreeRTOS tasks and sensor error paths inside Docker CI without physical devkits.

ESP-IDF projects combine FreeRTOS, vendor HAL drivers and custom sensor or telemetry logic. Running the compiled ELF inside the official espressif/idf Docker image paired with CircuitTwin lets every pull request verify UART, SPI, I2C and application state machines deterministically.

Remember the explicit boundary: native Wi-Fi and BLE radio stacks are not modelled in CircuitTwin today. Isolate Wi-Fi/BLE transport behind an interface or use an ESP-AT UART twin so hardware-level peripheral tests stay clean and never hit exit code 4.

## ESP-IDF targets in board-dashboard.json

| Board slug      | IDF target | CPU core        |
| --------------- | ---------- | --------------- |
| esp32-devkitc   | esp32      | Xtensa LX6      |
| esp32s3-devkitc | esp32s3    | Xtensa LX7      |
| esp32c3-devkitm | esp32c3    | RISC-V RV32IMC  |
| esp32c6-devkitc | esp32c6    | RISC-V RV32IMAC |

## Local CLI workflow

Shell — build & simulate ESP-IDF target

```
idf.py set-target esp32s3 && idf.py build
ct run --json --board esp32s3-devkitc build/app.elf
```

## Suite & fault configuration

tests/esp-idf.suite.yaml

```
version: 1
board: esp32s3-devkitc
firmware: build/app.elf
tests:
  - name: i2c-driver-boot-check
    timeout_ms: 3000
    expect:
      console_contains: "SENSORS_INIT_DONE"
      exit_code: 0
  - name: i2c-stuck-sensor-recovery
    faults:
      - at_ms: 120
        bus: I2C0
        kind: nack
        address: 0x76
        count: 4
    expect:
      console_contains: "I2C_BUS_RESET_OK"
```

## CI pipeline integration

.gitlab-ci.yml — ESP-IDF matrix

```
esp-idf-twin-ci:
  image: espressif/idf:v5.3
  parallel:
    matrix:
      - TARGET: [esp32, esp32s3, esp32c3]
  script:
    - idf.py set-target $TARGET && idf.py build
    - ct test run --json tests/esp-idf.suite.yaml
```

## ESP-IDF v5 peripheral driver CI without devkits

Test ESP-IDF v5 i2c\_master, spi\_master and UART driver migrations inside espressif/idf Docker containers.

ESP-IDF v5 replaced the legacy driver/i2c.h API with driver/i2c\_master.h and tightened interrupt allocation rules. Porting drivers across ESP32, S3 and C3 routinely introduces timeout and pull-up bugs.

CircuitTwin runs the compiled Xtensa LX6/LX7 or RISC-V RV32IMC ELF directly in CI while keeping radio boundaries clear: native Wi-Fi and BLE RF stacks are not modelled, so test bus drivers and application logic cleanly without RF mocks.

### ESP-IDF v5 targets in CI

| Board slug      | SoC / ISA                  | Verified cross-vendor buses                           |
| --------------- | -------------------------- | ----------------------------------------------------- |
| esp32c3-devkitm | ESP32-C3 (RV32IMC)         | I2C BME280, SPI W25Q, I2C EEPROM, UART passing        |
| esp32s3-devkitc | ESP32-S3 (Xtensa LX7)      | 3,334/3,372 silicon reset-register match on Qualia S3 |
| esp32-devkitc   | ESP32-D0WD-V3 (Xtensa LX6) | UART, SPI, I2C, TWAI and FreeRTOS kernel              |

Shell - build in ESP-IDF v5 and run on twin

```
idf.py set-target esp32c3 && idf.py build
ct run --json --board esp32c3-devkitm --device bme280 build/app.elf
```

tests/espidf-v5.suite.yaml

```
version: 1
board: esp32c3-devkitm
firmware: build/app.elf
tests:
  - name: i2c-master-v5-nack-retry
    timeout_ms: 3000
    faults:
      - at_ms: 200
        bus: I2C0
        kind: nack
        address: 0x76
        count: 2
    expect:
      console_contains: "I2C_V5_RECOVERY_OK"
      exit_code: 0
```

## Troubleshooting checklist

| Symptom                                           | Fix                                                                                                               |
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| Boot stalls waiting on flash encryption / eFuse   | Use a development sdkconfig.ci overlay with flash encryption disabled for headless logic runs.                    |
| Exit code 4 inside Wi-Fi/BLE init                 | Compile CI peripheral suite with CONFIG\_TEST\_OFFLINE\_TRANSPORT=y so RF baseband registers are skipped.         |
| I2C master timeout in IDF v5.x new driver         | Check pull-up configuration and timeout\_ms in i2c\_master\_transmit\_receive().                                  |
| Task WDT fires during startup                     | Increase timeout\_ms or check for tight busy-wait loops on unconfigured GPIO pins.                                |
| Exit code 4 inside esp\_wifi\_init()              | Native Wi-Fi/BLE PHY is not modelled; guard Wi-Fi init behind a build flag or test with an ESP-AT UART transport. |
| i2c\_master\_transmit() returns ESP\_ERR\_TIMEOUT | Verify SCL/SDA GPIO matrix routing matches the board twin pins.                                                   |

## Frequently asked questions

| Question                                                    | Answer                                                                                                                                         |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| Does CircuitTwin simulate ESP32 Wi-Fi or BLE radio packets? | No. Native ESP32 Wi-Fi and BLE RF stacks are not modelled. Use CircuitTwin for ESP32 CPU, FreeRTOS, I2C, SPI, UART, TWAI and sensor driver CI. |

## Related boards & component twins

[Board: esp32-devkitc](https://circuittwin.ai/boards/esp32-devkitc) [Board: esp32s3-devkitc](https://circuittwin.ai/boards/esp32s3-devkitc) [Board: esp32c3-devkitm](https://circuittwin.ai/boards/esp32c3-devkitm) [Board: esp32c6-devkitc](https://circuittwin.ai/boards/esp32c6-devkitc) [Twin: BME680](https://circuittwin.ai/twins/bme680) [Twin: ADS1115](https://circuittwin.ai/twins/ads1115) [Twin: SX1276](https://circuittwin.ai/twins/sx1276) [Twin: BME280](https://circuittwin.ai/twins/bme280) [Twin: W25Q128JV](https://circuittwin.ai/twins/w25q128jv) [Twin: ST7789](https://circuittwin.ai/twins/st7789) [Compare ESP32 tools (vs Wokwi)](https://circuittwin.ai/compare/wokwi) [CI reference](https://circuittwin.ai/docs/ci) [ESP-IDF CI overview](https://circuittwin.ai/guides/esp-idf-ci-simulation)

## 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) [PX4 Pixhawk 6C simulation on real ARM ELF](https://circuittwin.ai/guides/px4-pixhawk-6c-simulation) [Marlin 3D printer firmware testing in CI](https://circuittwin.ai/guides/marlin-firmware-testing-ci)

> ## 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)
