esp32sim
github.com/mikroverk/esp32sim- Category
- Developer Tools
- Rank
- No. 1043Tools index
- Pricing
- Open Source
- Type
- TOOL
- Use case
- Software Testing & Quality
- Interfaces
- Web
- GitHub
- 1.3k stars
- Latest release
- v0.4.0
- Date
About
esp32sim is an open-source ESP32 emulator written in Rust that boots the real mask ROM, bootloader and unmodified application images for the ESP32, S3, C3 and C6 chips. It runs locally or in the browser through WebAssembly and includes a virtual WiFi access point, so firmware can be tested without hardware.
What it does
An instruction-level emulator for Espressif microcontrollers. It executes the chip's factory boot code, the second-stage loader and your application exactly as built, with each peripheral modelled register by register and the board around the chip (screens, touch panels, LED rings, audio codecs, cameras) modelled as devices that react to pin activity. Firmware sees a virtual network with DHCP, DNS and time sync, and a user-space relay carries its traffic to the real internet with no root access or tunnel device. Runs produce console logs, captured audio, display screenshots and waveform traces, and the same engine compiles to WebAssembly for a browser version.
Why it's ranked here
The S3 support goes far past booting a hello-world. Documented end-to-end runs include a Linux 6.11 login shell, a WPA2 join followed by HTTPS fetches, an LVGL touch panel at 480x480, and an esp-dl pedestrian detector running on the emulated SIMD unit. Correctness has machinery behind it: a disassembler differential over real binaries, golden-output regression tests, an interpreter that must match the JIT output exactly, and JTAG lock-step comparison against a physical S3. MIT licensed, pure Rust, no third-party emulator code. The project itself labels the other three chips draft or early, so this verdict is about the S3.
What's good
Unmodified means unmodified. Instead of shimming Espressif's WiFi API, the project models the radio MAC registers, so the closed WiFi library walks its own state machine to connected and the binary under test is the binary that ships. The SHA, AES and RSA accelerators are modelled because TLS and WPA2 silently hang without them, and each was checked against published test vectors. Speed is real: on the S3 a block cache plus an ARM64 JIT reach roughly 150 to 240 million instructions a second, about 30 times real time on hello world. The design notes record dozens of silicon gotchas worth reading even if you never run it.
Tradeoffs
Depth is uneven. Only the S3 is marked mature; the C3 is console only on a plain interpreter, and the C6 and classic ESP32 are draft or early. The JIT emits ARM64 code only, so other hosts run the slower block interpreter. Espressif's mask ROMs are not in the repository and must be fetched before anything boots. Timing is one instruction per cycle with no cache timing, and the radio baseband is faked, so RF calibration, analog accuracy and cycle-exact performance are out of scope. Several S3 blocks are partial or absent: no SPI3, TWAI (CAN bus), SD card or USB OTG, and I2S and RMT receive are not modelled.
How to use it well
Best fit: ESP32-S3 firmware teams who want repeatable regression runs without a board farm. Boot the real image, drive buttons, touch, serial input and ADC voltages from a timed script, then compare the console, captured audio and screenshot against known-good output. The debugging surface (breakpoints, watchpoints, per-function profiles, coverage, VCD waveforms, forcing a function to return a fixed value) reaches places a hardware debugger makes painful. Use the C3 and C6 for smoke tests only. Keep real hardware for RF, power, analog accuracy and timing-critical code. Boards are fixed models, so supporting a new one means writing its model in Rust.
Technical notes+
Cargo.toml declares a twelve-crate workspace (emu-core, esp-periph, esp-soc, xtensa-lx7, esp32s3, cli, wasm, wasm-jit, riscv-rv32, esp32c3, esp32c6, esp32) at version 0.2.0, MIT, with a release profile of fat LTO and one codegen unit. cli/src/main.rs is a single call to esp32sim::run_cli("s3"); the chip is chosen by flag and the C3/C6 binaries are aliases (docs/cli.md). emu-core/src/lib.rs defines the Bus, Core, Trap and ClockTree contracts with no dependencies and compiles the AArch64 encoder (jit_a64) only on aarch64 macOS/Linux. xtensa-lx7/src/lib.rs exposes decode, exec, block, jit and the PIE modules; per docs/architecture.md a block is up to 32 pre-decoded instructions validated by per-256-byte-page write versions behind a 512-entry software TLB of 64 KiB pages, and the JIT calls back into exec_insn for FPU, PIE, MAC16 and special-register instructions, with --no-jit as the oracle. Peripherals are declared once per chip in a device_set! table that generates dispatch, interrupt sources and tick delivery. esp32/src/lib.rs covers the classic chip with ble, wifi, i2s, ledc, rmt, spi and crypto modules. docs/decisions.md records the RSA 0x818 idle-status bug that deadlocked interrupt-driven modexp, I2S rate derivation from clock registers after a hard-coded 44.1 kHz played tunes at double tempo, and moving NAT socket polling to a 500 microsecond emulated cadence for a 3x WiFi speedup. docs/peripherals.md marks SPI3, TWAI, SDMMC and USB-OTG unmodelled and GDMA, I2S, RMT, LCD_CAM partial. docs/testing-plan.md requires cargo test --workspace to run hermetically and lists Phase 3 (checked-in binary suite) and Phase 6 (conformance firmware) as open. docs/boards.md defines the BoardModel trait new boards implement.
Observed
- License
- MIT (workspace manifest and README)
- Language
- Rust, twelve-crate Cargo workspace
- Interfaces
- Command-line binary for every chip, plus a WebAssembly build driven from a browser page
- Chip support
- ESP32-S3 marked mature; ESP32-C3 and ESP32-C6 draft; classic ESP32 early
- Native JIT
- AArch64 on macOS and Linux only; other hosts use the block interpreter
- Mask ROMs
- Not in the repository; fetched by a script or taken from an ESP-IDF install
- Unmodelled S3 peripherals
- SPI3, TWAI, SDMMC, USB-OTG, WiFi baseband and RF (docs/peripherals.md)
- Test approach
- Hermetic cargo test suite, golden-output regressions, JTAG lock-step against real S3 (docs/testing-plan.md)
Read from README.md, Cargo.toml, docs/architecture.md, docs/getting-started.md, docs/cli.md, docs/boards.md, docs/decisions.md, docs/peripherals.md, cli/src/main.rs, emu-core/src/lib.rs, xtensa-lx7/src/lib.rs, esp32/src/lib.rs, docs/testing-plan.md.
Similar tools
Tags
Tech Stack
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.