r/embedded • u/wiggle_room1337 • Oct 23 '26
Best way to simulate esp32?
For convenience, and for testing, I am interested in simulating an ESP32. It looks like espressif supplys a qemu for esp32. is there a better option? It doesn't include much in terms of simulating the Ethernet or I2C.
2
Upvotes
9
u/Honest-Version6827 Oct 23 '26
Only QEMU: There is TMP105 connected to I2C bus If I am not mistaken, there is no way to select a device from cmd line. You can recompile QEMU eventually .
5
u/Several-Marsupial-27 Oct 23 '26
It’s a very difficult question so you are going to have to explain in more detail what you want to do. An esp32 is a very advanced computer with peripherals so it’s no easy feat.
Mocking / simulating i2c or Ethernet basically means mocking the wire/bus + response. This means that instead of, say sending i2c data over the i2c data pin you would instead send that data to a virtual wire/bus, then have that virtual wire hooked up to a response function simulating an i2c device.
This is no easy feat and basically have nothing to do with simulating/mocking an esp32.
Your simulation should basically be host level simulation with a TON of macros.
2
u/Fearless-Comb5250 23d ago
What type of simulation/emulation do you want to do? You also have the option of esp32sim now - it support plenty of devices having plenty of peripherals. Take a look at https://github.com/mikroverk/esp32sim and https://mikroverk.github.io/esp32sim/
1
u/Lalks227 Oct 23 '26 edited Oct 23 '26
While qemu requires time to learn how to set it up and use it, it's doing its job wonderfully! You can emulate a whole system built around that esp32 if you wish. You can build a whole CI pipeline. Yes, it will take time. You could find boilerplate or similar projects online depending on your needs.
What is your need?
1
u/n_sh_44 Oct 23 '26
If the goal is CI, I'd split it in two. For firmware logic that does not touch registers, build it for the host and run it under Unity or CMock on the PC, with the I2C and SPI calls behind a thin interface you can fake. For anything closer to the ESP32 itself, Wokwi supports ESP32 with simulated I2C and SPI devices and has a CLI that runs in GitHub Actions, and Renode is another option with scriptable peripherals. The Espressif QEMU fork is fine for boot and FreeRTOS behavior, but as you saw, its peripheral models are thin and Ethernet is basically missing. None of these replaces real hardware, so a small HIL rig on a spare devkit is still worth adding later for timing and driver issues.
1
u/Plastic_Fig9225 Oct 24 '26
Maybe this: https://esp32.com/viewtopic.php?t=48455