esp-iot-solution icon indicating copy to clipboard operation
esp-iot-solution copied to clipboard

[Feature request] elf-loader for RISC-V based ESP32 (like C6) (IDFGH-14086) (AEGHB-880)

Open martinssense opened this issue 1 year ago • 3 comments

Is your feature request related to a problem?

Dynamically loading code during runtime can be useful. There already is an elf-loader for Xtensa based ESP32, I cannot find a working solution for RISC-V based ESP32 (like C6 or H2) though.

Describe the solution you'd like.

A working elf-loader for RISC-V based ESP32 would be awesome. This way we could load "program modules" on RISC-V based ESP32 during runtime, without having to flash the firmware.

Describe alternatives you've considered.

Zephyr has something called LLEXT which is basically an elf-loader. Using Zephyr is not the same as having the luxury of FreeRTOS though - as I understand there are also limitations of using Zephyr on ESP32. There is also embedded wasm, but its overhead is huge, so it's not a viable solution for concurrent dynamically loaded code. There are always interpreters like MicroPython, but be real: it's not the same.

Additional context.

No response

martinssense avatar Nov 16 '24 12:11 martinssense

Thanks for the request, I will transfer your issue to https://github.com/espressif/esp-iot-solution/ since the elf-loader component is developed there. AFAIK, support for RISC-V (e.g. ESP32-P4) is in progress.

igrr avatar Nov 18 '24 11:11 igrr

I finish it this week for ESP32-C3. I changed some functions that I can run it from file. the CONFIG_ESP_SYSTEM_MEMPROT_FEATURE must be disabled

https://github.com/NyankoLab/esp32c3-elf/blob/extra/elf_loader/src/esp_elf.c https://github.com/NyankoLab/esp32c3-elf/blob/extra/elf_loader/src/arch/esp_elf_riscv.c

And I have a relocation executable to strip unneeded symbol for Relocatable ELF. Yes, I use the Relocatable ELF instead of the Static ELF.

https://github.com/NyankoLab/esp32c3-elf/blob/extra/build/relocation.c

metarutaiga avatar Nov 22 '24 17:11 metarutaiga

That's awesome! I'll take it as reference and try it out on C6 the upcoming days. Thanks a lot for the work :)

martinssense avatar Nov 25 '24 11:11 martinssense