Documentation
// risc-v

RISC-V Emulation (ESP32-C3)

ESP32-C3, XIAO ESP32-C3, and C3 SuperMini boards run on the RISC-V RV32IMC architecture at 160 MHz. Eidolon emulates them through the same QEMU-based backend as the Xtensa ESP32 family, using libqemu-riscv32 with the esp32c3-picsimlab machine target. A separate TypeScript ISA implementation lives in the repo for unit-testing RV32IMC instruction decoding, but it is not the production emulation path.

Supported Boards

BoardCPUFlashRAM
ESP32-C3RV32IMC @ 160 MHz4 MB384 KB DRAM
XIAO ESP32-C3RV32IMC @ 160 MHz4 MB384 KB DRAM
C3 SuperMiniRV32IMC @ 160 MHz4 MB384 KB DRAM

Memory Map

RegionBase AddressSizeDescription
IROM (Flash)0x420000004 MBCode stored in flash
DROM (Flash R/O)0x3C0000004 MBRead-only data in flash
DRAM0x3FC80000384 KBData RAM (stack + heap)
IRAM0x4037C000384 KBInstruction RAM (copied from flash)
UART00x600000001 KBSerial port 0 (GPIO 20/21)
GPIO0x60004000512 BGPIO output / input / enable

ISA Support

  • RV32I: Full base integer instruction set (ALU, load/store, branches, JAL/JALR)
  • RV32M: Multiply/divide: MUL, MULH, MULHSU, MULHU, DIV, DIVU, REM, REMU
  • RV32C: 16-bit compressed instructions: C.LI, C.ADDI, C.LUI, C.J, C.JAL, C.BEQZ, C.BNEZ, C.MV, C.ADD, C.JR, C.JALR, C.LW, C.SW, C.LWSP, C.SWSP, C.SLLI, C.ADDI4SPN

Compilation Flow

When you click Compile + Run for an ESP32-C3 board:

  1. The backend compiles your sketch with arduino-cli using the esp32:esp32 core.
  2. The resulting binary is a merged 4 MB flash image: bootloader at 0x1000, partition table at 0x8000, application at 0x10000.
  3. The frontend's esp32ImageParser.ts finds the app at offset 0x10000, reads the 24-byte ESP32 image header (magic 0xE9), and extracts all segments (load address + data).
  4. Each segment is written into the correct memory region (IROM, DROM, DRAM, or IRAM) of the Esp32C3Simulator.
  5. The CPU starts executing from the entry point specified in the image header.

GPIO Registers

RegisterOffsetDescription
GPIO_OUT_REG+0x04Current output value
GPIO_OUT_W1TS+0x08Set bits (write 1 to set)
GPIO_OUT_W1TC+0x0CClear bits (write 1 to clear)
GPIO_ENABLE_REG+0x20Output enable
GPIO_IN_REG+0x3CInput pin states

UART0

Writing a byte to 0x60000000 (UART0 FIFO) triggers the onSerialData callback, which streams characters to the Serial Monitor. Reading from the same address pops from the receive FIFO (used by Serial.read()). The UART status register always returns 0 (TX ready).

Key Source Files

FileRole
simulation/RiscVCore.tsRV32IMC interpreter (step, MMIO hooks)
simulation/Esp32C3Simulator.tsESP32-C3 peripherals, memory map, lifecycle
utils/esp32ImageParser.tsParses merged flash image, extracts segments
Full details: docs/RISCV_EMULATION.md in the repository.