Repository navigation
This release adds TWAI (CAN and CAN FD) on every chip, most of the ESP32 peripherals that were missing, and SD cards and parts that you can put in and take out while the firmware runs. The Event Task Matrix runs more tasks, at the exact time of their event. The emulator page now works with relay 2.0.0, which is protected by a token.
Peripherals
- TWAI (CAN) on every chip: firmware that uses
esp_driver_twai(twai_new_node_onchip) or the legacy TWAI driver now sends and receives frames. Before, the driver waited for a controller that never answered. ESP32, C3, S3 and H2 have one classic CAN controller, C6 has two and P4 has three. ESP32-C5 and S31 have two CAN FD controllers each. A controller with nothing connected works in self-test and loopback mode.tools/cosim-tcp.py PORT twaiis the rest of the bus: it prints and sends frames incandumpnotation, connects the bus to a SocketCAN interface (--socketcan vcan0), and joins the buses of several emulators. Not modelled: the clock output and bus-off indicator pins, and receive timestamps on ESP32-P4. GH #23 - More peripherals on ESP32: LEDC (both speed groups, with fades), RMT, PCNT, MCPWM and I2S (standard and PDM modes, with
--i2s-wavand--i2s-wav-in) now work with the stock ESP-IDF drivers. A part or an SD card in SPI mode (--sd FILE,cs=PIN) answers on SPI2 and SPI3.adc_oneshotreads a voltage that a part holds on a pad, with calibration. Light sleep and deep sleep wake on the timer, and light sleep also wakes on a GPIO.esp_wifi_set_csidelivers CSI data, and the station reports the access point's real signal strength instead of -126 dBm. Not modelled yet on ESP32: continuous ADC, the DAC, touch pads, SPI slave mode, and wake-up by EXT0, EXT1, touch or the ULP. - eFuse coding schemes and Secure Boot V1 on ESP32:
espefusecan burn a key or a custom MAC on a chip with the 3/4 coding scheme, and write-protected and read-protected fields behave as on a real chip. Firmware built withCONFIG_SECURE_BOOT_V1_ENABLEDenables Secure Boot on its first boot, and the mask ROM then checks the bootloader on every reset. - Arduino-ESP32 1.0.x firmware on ESP32: an image built on ESP-IDF 3.x printed its bootloader lines and then nothing, and the watchdog reset it in a loop. Such an image now starts and runs
setup()andloop(). I2C with the driver of that old release works too: before, every transfer failed, because that driver loads its data from an interrupt the emulator did not raise. Devices added with--i2c-devanswer it, and so does a part. GH #81 - SD card in and out while the firmware runs: on the control channel (
--control-tcp),sd ejecttakes the card out andsd insert FILE[,ro][,slot=N|,cs=PIN][,cd=PIN]puts one in, with the same options as--sd. An empty slot answers like a slot with no card, and a card-detect pin given withcd=PINfollows the card. Before, the card could only change with a restart of the emulator. The browser build hassd_eject()next tosd_attach(). GH #87 - More Event Task Matrix (ETM) tasks and events on ESP32-C5, C6, H2, P4 and S31: the MCPWM tasks now work: timer sync (also between two MCPWM groups), one-shot trip and trip clear, capture, and generator stop. A DMA channel's
IN_DONEevent reaches its task. A channel that is enabled on an event or a task that the emulator does not model now logs a warning. Before, it returnedESP_OKand did nothing, with no sign. GH #58 - ADC triggered by the ETM on ESP32-S31: an ADC unit in ETM trigger mode now converts when the ETM runs its sample task, and stops on its stop task. In continue mode it keeps converting until the stop task. Before, such a unit delivered no samples. The ADC's own ETM events are not modelled. GH #56
- Fixed: ETM tasks ran late: a task ran up to about 1 µs after its event, and a GPTimer capture from a GPIO edge was a few counts off. A task now runs at the time of its event, and a capture reads the exact count. GH #58
- Fixed: UART receive timeout and line timing: the UART receive timeout (
uart_set_rx_timeout) never fired on ESP32-C3, C5, C6, H2, P4, S3 and S31, so protocols that end a frame on an idle line, such as Modbus RTU, never saw a complete frame. It now fires after the idle time. Bytes to and from a--uart-tcpor--uart1-tcpclient, and bytes from a part, now take their time on the line at the baud rate. GH #20 - Fixed: a UART that receives its own output: with TX routed to the UART's own RX pad, a burst longer than the receive buffer was never lost, and the receive timeout came while the UART was still sending. The buffer now overflows and the timeout comes after the last byte, as on a real ESP32-S3.
- Fixed: ADC results on ESP32-S31:
adc_oneshot_read()andadc_continuousreturned a bit pattern (for example 50777) instead of the ADC code (1647) with ESP-IDF v6.1. The result is now the code, 0 to 4393. Newer ESP-IDF versions, which ask the chip for the bit pattern, get it as before. GH #82 - Fixed: slow I2C to a part on ESP32: a transfer to a part took about 30 times longer than on a real chip, so a driver with a short timeout failed. On ESP32, C3 and S3 the transfer after a driver timeout also failed once. GH #84
- Fixed: USB-Serial/JTAG console input longer than 64 bytes: on every chip with a USB-Serial/JTAG console, input written in one piece lost everything after the first 64 bytes until more input came. Long lines now arrive whole. GH #86
- Fixed: light sleep on ESP32-C5, C6, P4 and S31:
esp_light_sleep_start()never returned after the wake-up. - Fixed: timers on ESP32-S3: a GPTimer on the crystal clock ran twice as fast as it should, and the task watchdog fired after 2 s for a timeout of 1 s.
- Fixed: MCPWM capture on ESP32-S3: a capture measured a pulse width wrong by the factor of the group's clock prescaler.
- Fixed: UART baud rate detection on ESP32: automatic baud rate detection counted no edges, and with power management on (
CONFIG_PM_ENABLE) the console's baud rate was measured as 9.41 Mbit/s instead of 115200. - Fixed: LEDC channel moved to another timer: a duty change that was running when the channel was bound to another timer never ended.
Networking
- Changed: the emulator page needs relay 2.0.0: the Network panel of the page now shows a command with the page's own token,
esp-emu-relay --token <token>. Copy it and run it; the page connects when the relay answers. This page does not connect to relay 1.0.0. See the relay 2.0.0 release notes and the Browser guide. - A page can serve DHCP and ARP itself: a page that carries the firmware's Wi-Fi frames to a network of its own calls
wifi_set_host_link(true). The built-in access point then leaves DHCP and the gateway's ARP answers to that network. Before, the firmware got two answers. - Fixed: Bluedroid on ESP32, ESP32-C3 and ESP32-S3:
esp_bluedroid_init()failed with "Controller not initialised". Bluedroid now starts, and ESP-IDF'sgatt_serverexample runs. BLE needs the firmware's ELF file (--elf), as before. GH #80
Co-simulation and parts
- Plug a part in and take it out while the firmware runs: on the control channel,
part NAME add MODULE [PIN=GPIO ...] [addr=N]loads a.wasmpart and wires it like an entry of a--cosim-boardfile, andpart NAME removetakes it out. A part that the chip refuses is not added, and the command answerserr: .... After a removal the part's pins are released, and its I2C address or chip select has nobody on it. GH #89 - OBD-II example part and test app:
examples/parts/obd2is a car's engine control unit on a CAN bus, andtest_apps/twai_obd2is firmware that reads it. - Fixed: a part lost data at random: a part could see its time go backwards, which a part takes for a chip reset. An infrared emitter part on ESP32 dropped frames this way.
- Fixed: slow steps for a clock holder on Linux: a program built on
tools/cosim_tcpthat holds the chip's clock could wait up to 40 ms in each step.
Core
- Changed: a breakpoint instruction in the firmware no longer ends the emulation:
ebreakon the RISC-V chips andbreakon ESP32 and ESP32-S3 now raise the exception that a real chip raises, and the firmware goes on. Before, the emulator stopped with "EBREAK at PC=...". A kernel that runs applications in user mode now sees their breakpoints. On ESP32-S3, a stack overflow that ends in ESP-IDF's double exception handler now prints the same panic as a real board. A bare-metal program that usedebreakto end the run must end it another way, for example with--exit-on. Under--gdba breakpoint instruction still stops for the debugger. GH #85, GH #91 - Fixed:
run_untilafter a GPIO wake-up: on ESP32-C3 and ESP32, the firstrun_until(n)after a GPIO ended a light sleep returned without running. This showed in the browser build. GH #90
Tools
- PSRAM size in the browser build:
set_psram_size(bytes)fits another external RAM before the firmware is loaded, andpsram_size()reports the size, on ESP32, C5, P4, S3 and S31. A size that the chip cannot have is refused. The--psram-sizehelp and the CLI guide now name2M, which ESP32, C5 and S3 accept. GH #79
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 2.0.0; any 2.x relay works with this release's page:
curl -fsSL https://raw.githubusercontent.com/espressif/esp-emulator/main/install.sh | sh -s -- --relay --version 2.0.0
Or on Windows, from PowerShell:
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/espressif/esp-emulator/main/install-relay.ps1))) -Version 2.0.0