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
- Clone nuttx + nuttx-apps
- Configure:
./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
- Build and flash:
- make CROSSDEV=riscv32-esp-elf-
- make CROSSDEV=riscv32-esp-elf- flash ESPTOOL_PORT=/dev/ttyACM0 ESPTOOL_BINDIR=./
- 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
Description / Steps to reproduce the issue
On ESP32-C3 (
esp32c3-devkit:usbconsole), running ELF binaries fromexamples/elfROMFS fails with an Instruction access fault. This is reproducible on master,Steps to reproduce
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_APPSExpected
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
lib_memalign()(DRAM) whenCONFIG_ARCH_USE_TEXT_HEAPis not set.up_textheap_memalign().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