Hello Gustavo, thank you for the quick reply!
On 9/20/22 16:39, Gustavo Henrique Nihei wrote:
Welcome to the Apache NuttX mailing list!
thanks :)
The esp32 flash driver suggests "Consider using spi_flash_mmap()" [1]
The "spi_flash_mmap()" and the referenced "spi_flash_read()" are ROM
functions from the ESP32-C3 chip and their usage should be restricted to
the chip implementation, so they should not be called from the userspace.
Okay, I see. Are there any alternative functions available in userspace?
BTW my requirement for memory mapping is to implement XiP.
By default, the NuttX application firmware images for every supported chip
of the ESP32 family runs from the External Flash, so XIP is already
supported.
Okay yes, understood. What I'm trying to do is to store a WASM AoT image
on flash, and then run it using XiP in WAMR. I've already got the
physical flash address, and I need to map, and unmap, to virtual memory.
If by supporting XIP you mean dynamically load executable code from
External Flash, then ROMFS support may be what you are looking for.
https://cwiki.apache.org/confluence/display/NUTTX/RAM+Disks+and+ROM+Disks
Yes that's pretty much it, but I need to both save to and load from
flash, dynamically.
We considered using an existing file system but because we need to
guarantee contiguous memory and (probably) 64kb alignment we discarded
that idea. So instead we have implemented our own simple, slot-based
flash driver. Storing to (encrypted) flash is working fine, reading back
into a buffer is also no problem, but getting a memory mapped pointer to
the data is proving a little challenging.
Since the reading back part already involves memory mapping inside
esp32_spiflash.c it seems it shouldn't be impossible. I just can't see
quite how.
It seems you are working with an ESP32-C3-based platform, so you may take a
look at these defconfigs that rely on the ROMFS support for achieving
different purposes:
https://github.com/apache/incubator-nuttx/tree/master/boards/risc-v/esp32c3/esp32c3-devkit/configs/elf
https://github.com/apache/incubator-nuttx/tree/master/boards/risc-v/esp32c3/esp32c3-devkit/configs/module
https://github.com/apache/incubator-nuttx/tree/master/boards/risc-v/esp32c3/esp32c3-devkit/configs/romfs
We're using the S2, I just included the wrong link in my email, sorry!
The config should be quite similar though. I will have a close look at
your references, thank you again.
best regards,
Martin