Zephyr on ESP32 in QEMU: prototype firmware before the board arrives
Editorial illustration; schematic only, not a project photograph.
Zephyr on an ESP32 normally means waiting for a board. A September 15 Espressif tutorial removes the wait for the first part of the work: boot a firmware image and debug it under emulation, on four different chips, before anything arrives from a distributor.
What happened
The tutorial runs Zephyr on ESP32, ESP32-S3, ESP32-C3 and ESP32-C6 using Espressif's QEMU fork. It walks through samples/hello_world on all four targets under both Simple Boot and MCUboot/sysbuild, then attaches GDB through debugserver.
Why the stock QEMU will not do
The QEMU shipped with the Zephyr SDK — and with most Linux distributions — does not model these chips. Neither does a generic install picked up from a package manager. The Espressif fork is a hard requirement, not a convenience.
The fork also splits by architecture, and the two packages are not interchangeable:
| Target | Emulator package |
|---|---|
| ESP32, ESP32-S3 | qemu-system-xtensa (Xtensa softmmu) |
| ESP32-C3, ESP32-C6 | qemu-system-riscv32 |
Mixing those up is the most common way a first attempt fails silently, because the build succeeds and the emulator simply rejects the image.
What the emulator actually models
The fork covers enough of each SoC for a normal bring-up path: ROM and bootloader hand-off, SPI flash, the UART console, eFuse and revision readout, timers, and several on-chip peripherals.
It does not cover the radios. Wi-Fi and Bluetooth workloads, and peripherals or reset paths the emulator has not implemented — triggering the external 32 kHz XT watchdog callback is the example the tutorial gives — still need real hardware.
The flash-size trap
Espressif QEMU only accepts SPI flash images padded to 2, 4, 8 or 16 MB. The merged image follows the board's zephyr,flash size from the devicetree, so a board definition or overlay with any other flash size produces an image the emulator will not boot.
The DevKitC examples in the tutorial already satisfy that constraint. A custom board port usually does not, and this is the first place to look when an image builds cleanly and then does nothing.
What you can actually test
hello_world is the starting point, not the limit. The tutorial lists samples and tests already run on the /qemu board targets: the crypto driver sample and the hardware AES/SHA tests, the watchdog sample using the Timer Group watchdog, the memory layout test under both Simple Boot and MCUboot/sysbuild, the clock control API tests on ESP32, ESP32-S3 and ESP32-C3, the retained memory API test, the interrupt test on Xtensa targets, and the SPIRAM test for QPI or octal PSRAM on ESP32 and ESP32-S3.
The PSRAM case has a condition attached: QEMU has to be started with a matching memory size, or the test does not describe the board you think it does.
That list is a useful map of what this workflow is good for. Anything that lives in the core, the timer block, the crypto engine or the flash layout can be exercised without hardware. Anything that needs a radio, a real sensor bus or accurate timing against a physical peripheral cannot.
Before you start
Two prerequisites that are easy to miss. You need a working Zephyr installation — a west workspace plus the Zephyr SDK — and the ability to build hello_world for an Espressif board already; this tutorial is not an introduction to Zephyr. And this is the Zephyr-side setup, not the ESP-IDF one: if you have run ESP-IDF under QEMU before, the emulator will feel familiar and the build system will not.
No hardware was tested for this article. Every constraint above is stated in the tutorial.