Repository navigation
esp-emu 1.3.0
This release adds the original ESP32 as the eighth chip, the Event Task Matrix, USB-OTG slave mode, a USB host over co-simulation, and continuous ADC on ESP32-S31. The emulator is also faster on every chip.
New chip: ESP32
- ESP32 (dual-core Xtensa LX6):
--chip esp32runs ESP-IDF firmware for the original ESP32. It boots through the real mask ROM (rev 3) and the IDF bootloader toapp_mainon both cores. Wi-Fi station on 2.4 GHz, BLE with NimBLE, Ethernet, an SD card on the SDMMC host, I2C, NVS and flash access, and the SHA, AES and RSA accelerators work.esptoolandespefusework over--uart-tcp. Not modelled yet on ESP32: LEDC, RMT, PCNT, I2S, MCPWM, the SAR ADC, TWAI and Wi-Fi CSI. - Flash encryption and Secure Boot V2 on ESP32: flash encryption works, including the first boot that makes the key and encrypts the flash in place. The mask ROM checks a Secure Boot V2 bootloader as a real chip does. Secure Boot V1 is not modelled.
- External RAM on ESP32:
CONFIG_SPIRAMfirmware finds a 4 MB PSRAM, as on a WROVER module.--psram-sizeselects2M,4Mor8M, or0for a board with no PSRAM.
Peripherals
- Event Task Matrix (ETM) on ESP32-C5, C6, H2, P4 and S31: an ETM channel now carries its event to its task. Before, a channel connected and enabled with
ESP_OKand then did nothing. Events that work: GPTimer alarms, GPIO edges, MCPWM timer and comparator events, and the DMA end-of-frame events thatesp_async_memcpyuses. Tasks that work: GPIO set, clear and toggle, and GPTimer start, stop, alarm enable, reload and capture. Other events and tasks are not modelled yet. GH #58 - USB-OTG slave (FIFO) mode on ESP32-S3, P4 and S31: USB device firmware that does not use buffer DMA now enumerates. This is TinyUSB's default mode and the one the Arduino core uses, so an Arduino TinyUSB CDC console works, and so does
esp_tinyusbwithCONFIG_TINYUSB_MODE_SLAVE. On ESP32-S3 the ROM's USB CDC console (CONFIG_ESP_CONSOLE_USB_CDC) works too. GH #74 - Continuous ADC on ESP32-S31:
adc_continuousnow delivers frames. Before, it returnedESP_OKand no frame arrived. ESP-IDF'scontinuous_readexample runs. GH #56 - Continuous ADC follows its input inside a frame: each sample of a frame is now read from the pad's voltage at that sample's own time, on every chip with continuous ADC. Before, all samples of a channel in one frame had the same value, so a fast signal from a part looked like steps. GH #56
- UART timing and flow control: UART1 and higher send bytes at the baud rate the firmware set, instead of all at once. Software flow control (XON/XOFF) and hardware flow control (RTS/CTS) work. Automatic baud rate detection measures the incoming signal. A UART whose TX is routed to its own RX pad (one-wire mode, loopback tests) receives what it sends.
- GPIO wake-up from sleep on ESP32-C3: deep sleep with
esp_deep_sleep_enable_gpio_wakeupand light sleep withgpio_wakeup_enablenow wake when the pin reaches its wake level. Before, such a sleep never ended.test_apps/gpio_deep_sleepshows it with a button part. GH #75 - Second DMA controller on ESP32-S31: channels made with
gdma_new_lp_ahb_channelnow move data. Before, they connected and nothing moved. - SM2 curve in the ECC accelerator: SM2 operations on ESP32-C5 and S31 now use the SM2 curve. Before, they ran with the P-256 curve and gave wrong results.
- Fixed: UART2 and higher on ESP32-P4, S31 and S3:
uart_driver_install()on these ports hung until the interrupt watchdog fired. They now work. - Fixed: UART register behaviour: UART reset values and the register-update handshake now match what real ESP32-C3, C5, C6, S3, P4 and S31 chips do (H2 follows C6). On P4 and S31 a UART interrupt handler could run twice for one event.
- Fixed: UART loopback with hardware flow control: data beyond the receive buffer limit was lost and the reader waited forever (ESP-IDF's "uart read write test").
- Fixed: MCPWM dead time: generator outputs now pass through the rising-edge and falling-edge delays. Before, a dead-time waveform came out with no delay.
- Fixed: MCPWM capture and clocks: a capture channel ignored its prescaler and captured every edge. A capture of the chip's own PWM output measured pulse widths that changed with the emulator's internal timing. A group clocked from RC_FAST ran at the wrong rate on ESP32-C6, H2 and S31.
- Fixed: MCPWM timer count after a sync: when one timer synchronised another on a timer event, the count read back from the synchronised timer was wrong, although its outputs were right. GH #72
- Fixed: ADC calibration on ESP32-H2:
adc_cali_create_scheme_curve_fitting()failed with "Calibration required eFuse bits not burnt", and Arduino'sanalogReadMilliVolts()returned 0. Calibrated readings now work. An--efusefile saved by an older version keeps its old value; make a new one to get the fix. GH #77 - Fixed: calibrated ADC readings on ESP32-C3: a voltage held on a pad read back up to 47 mV too low at 12 dB attenuation. Readings are now within 2 mV. GH #76
- Fixed: dedicated GPIO on the RISC-V chips: ESP-IDF's dedicated GPIO driver read back 0 for every value it wrote.
Networking
- BSController as a BLE backend: the BLE guide shows how to connect esp-emu and a GATT peer through BSController with
--ble-hci tcp:..., and how to capture the BLE packets sent over the air. GH #45, PR #73 - Fixed: a Wi-Fi station on a bridged TAP interface could not be reached: with
tap0bridged onto a real LAN (--net tapon Linux), other machines got no answer from the station, because its ARP replies carried the wrong Ethernet destination. The station is now reached under its own MAC address. GH #69 - Fixed: a station answered for other machines: on a bridged
tap0the firmware was given every frame on the segment and answered pings meant for other machines. A station now gets only frames addressed to it or to a group address, as with a real access point. Firmware in promiscuous mode on a bridgedtap0no longer sees other machines' unicast frames. - Fixed: four extra bytes after every Wi-Fi frame: each frame a station sent reached the host network four bytes too long. IP traffic was not affected, but the bytes showed in packet captures. GH #69
- Fixed: ESP-Hosted over the SDIO bridge was slow while idle: with a P4 host and a C5 or C6 slave in two emulators, each SDIO transaction could wait tens of milliseconds while the slave was idle. Wi-Fi bring-up ran several times slower than real time. In our test a 1.35 MB OTA over the bridge now takes 66 s instead of 253 s. GH #70
Co-simulation and parts
- A USB host over co-simulation: a program on
--cosim-tcp, or a.wasmpart, can be the computer that the chip's USB device is plugged into, on ESP32-S3, P4 and S31. It enumerates the device and runs control, bulk and interrupt transfers.tools/cosim-tcp.py PORT usb-hostdoes this for mass-storage, HID and CDC-ACM devices; ESP-IDF'stusb_mscandtusb_hidexamples run against it. Start the emulator with--usb-host cosimso that the built-in host stays off the port and the device is enumerated only once. GH #51 - Analog waveforms for ADC inputs: a part or a
--cosim-tcpprogram can send many voltages for an ADC pad in oneAnalogWavemessage, one sample period apart, instead of one message per voltage.tools/cosim-tcp.py PORT adcplays a sine, a square wave or a constant voltage onto a pad, andesp-partgainswave(). GH #56 - NTC thermistor example part: the part now warms and cools gradually toward the temperature it is set to, like a real thermistor, instead of jumping there at once.
- New test apps:
test_apps/adc_continuousreads a potentiometer part through the stockadc_continuousdriver, andtest_apps/gpio_deep_sleepwakes an ESP32-C3 from deep sleep with a button part. - Changed: pin levels go only to programs that take pins: over
--cosim-tcp, a connection now gets GPIO level messages only when it registered aGpioClaim(an empty one is enough) or registered with no claim at all. A program that claimed only a bus, the clock or EN and also read pin levels must now add aGpioClaim. The devices intools/cosim_tcpneed no change. GH #71 - Fixed: a clock holder and the chip could wait for each other forever: a
--cosim-tcpprogram that holds the clock, next to firmware that toggles pins fast (MCPWM outputs, for example), could miss the message that the chip is waiting for more time. GH #71 - Fixed: co-simulation time stopped while ESP32-C3 or C6 slept: a pin change scheduled during a sleep never happened, and a clock holder's time grant never ran out. Co-simulation time now goes on through a sleep. GH #75
Core
- Faster emulation: the CPU interpreters for RISC-V and Xtensa were reworked. In our measurements CoreMark runs more than 1.2 times as fast on the RISC-V chips, and ESP32-S3 is faster too. Results are unchanged.
- Carry-less multiply on ESP32-P4 and S31: the
clmul,clmulhandclmulrinstructions now run, as they do on the real chips. - Fixed: ESP-TEE on ESP32-C5: the TEE image crashed at its first compressed
Zcbinstruction. These instructions are now decoded. - Fixed: user-mode firmware on ESP32-S31: firmware that runs code in RISC-V user mode hung at boot. The same fix applies to ESP32-C5 and P4.
- Fixed: CPU cycle counter while idle on ESP32-C3, C6 and H2: the counter kept running while the core waited for an interrupt. It now stops, as on the real chips, so idle-time measurements are right.
- Fixed: PIE (SIMD) memory access on ESP32-P4 and S31: after reset, a misaligned vector store wrote to the wrong address. PIE loads and stores now also obey memory protection and trigger hardware watchpoints. On ESP32-S3 the
ee.*loads and stores obey memory protection too. - Fixed: huge logs from a trap loop: firmware stuck in a loop of illegal instructions wrote one warning per trap and could fill gigabytes of log. Repeated warnings are now thinned out.
Tools
tools/make-encrypted-flash.py: encrypts an ESP-IDF build on your computer and writes the eFuse file that goes with it, so the chip boots with flash encryption already on and skips the slow first boot. Works for all eight chips. See Flash Encryption Without the First Boot.tools/make-efuse.pywrites an eFuse file for ESP32 too.- Fixed: console input without a newline: bytes sent to the emulator's standard input now reach the UART as they arrive. Before, they waited for a newline, which broke XON/XOFF and binary input.
- Fixed: TAP proxy steps in the browser guide: the guide now runs
tools/ws-net-proxy.py, which is in this repository, instead of a build step that needs the emulator's source.
Installable via:
curl -fsSL https://raw.githubusercontent.com/espressif/esp-emulator/main/install.sh | sh
Or from an existing install:
esp-emu update
The browser build's network relay, esp-emu-relay 1.0.0; any 1.x relay works with this release's page:
curl -fsSL https://raw.githubusercontent.com/espressif/esp-emulator/main/install.sh | sh -s -- --relay --version 1.0.0
Or on Windows, from PowerShell:
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/espressif/esp-emulator/main/install-relay.ps1))) -Version 1.0.0