[BUG] ESP32-C3: ELF module execution fails with Instruction access fault
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
### Description / Steps to reproduce the issue
On ESP32-C3 (`esp32c3-devkit:usbconsole`), running ELF binaries from `examples/elf` ROMFS fails with an **Instruction access fault**. This is reproducible on **master**,
### Steps to reproduce
1. Clone nuttx + nuttx-apps
2. Configure:
```bash
./tools/configure.sh esp32c3-devkit:usbconsole
Enable: `CONFIG_ELF`, `CONFIG_MODULES`, `CONFIG_FS_ROMFS`, `CONFIG_BOARDCTL_ROMDISK`, `CONFIG_EXAMPLES_ELF`, `CONFIG_EXAMPLES_ELF_ROMFS`, `CONFIG_EXECFUNCS_HAVE_SYMTAB`, `CONFIG_EXECFUNCS_SYSTEM_SYMTAB`, `CONFIG_NSH_FILE_APPS`
3. Build and flash:
- make CROSSDEV=riscv32-esp-elf-
- make CROSSDEV=riscv32-esp-elf- flash ESPTOOL_PORT=/dev/ttyACM0 ESPTOOL_BINDIR=./
4. On NSH: elf
### Expected
ELF test binaries from ROMFS should run.
### Actual
riscv_exception: EXCEPTION: Instruction access fault
MCAUSE: 00000001, EPC: 3fc8b5d8, MTVAL: 3fc8b5d8
EPC is in DRAM (0x3fc8xxxx), which is not executable on ESP32-C3.
### Notes
- libs/libc/elf/elf_load.c uses `lib_memalign()` (DRAM) when `CONFIG_ARCH_USE_TEXT_HEAP` is not set.
- Current arch/risc-v/src/esp32c3/ has no `up_textheap_memalign()`.
- Legacy port has arch/risc-v/src/esp32c3-legacy/esp32c3_textheap.c (instruction-bus alias).
- Requesting guidance whether text-heap support should be ported for ELF on current ESP32-C3.
### On which OS does this issue occur?
[OS: Linux]
### What is the version of your OS?
WSL2 Ubuntu 24.04 (Linux 6.6.87.2-microsoft-standard-WSL2 x86_64)
### NuttX Version
master
### Issue Architecture
[Arch: risc-v]
### Issue Area
[Area: Board support]
### Host information
CONFIG_BASE_DEFCONFIG="esp32c3-devkit:usbconsole-dirty"
CONFIG_ARCH_CHIP="esp32c3" CONFIG_ARCH_BOARD="esp32c3-devkit"
CONFIG_ESPRESSIF_USBSERIAL=y
CONFIG_ELF=y
CONFIG_EXAMPLES_ELF=y
CONFIG_EXAMPLES_ELF_ROMFS=y
CONFIG_FS_ROMFS=y
CONFIG_BOARDCTL_ROMDISK=y
**Host**: Linux WSL2 x86_64 (6.6.87.2-microsoft-standard-WSL2)
Toolchain: riscv32-esp-elf-gcc (crosstool-NG esp-12.2.0_20230208) 12.2.0
Esptool: 5.3.0
HAL: sync/master.c-nuttx-20260428-23-g0eb59f7e02a
Board at test time: ESP32-C3 (QFN32), USB Serial/JTAG, 4MB flash
### Verification
- [x] I have verified before submitting the report.
Contributor guide
Assessment
This issue has not been assessed yet.