You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by mi...@mdc-service.de on 2022/07/27 08:22:37 UTC

Porting Nuttx to new board: Question about SPI-FRAM / malloc

Dear all,

we are in the process of porting Nuttx to our new EsPiFF-V3 board. Basic 
Nuttx with nsh is working already. This is a board with a ESP32-WROVER 
module, and has additional SPI-connected FRAM (2kB to 256kB possible). 
How could the SPI-connected FRAM be integrated into Nuttx?

- the FRAM is as fast as the ESP32-SPI PSRAM, and it should offer the 
application to store process variables and not lost it when power down. 
Best would be, when it can be addressed with malloc() or similar 
function for the user.

- SPI-based EEPROMs have traditionally a mount point in the file system, 
and are exposed as a device driver to the user. I could implement it in 
this way, but as such, the attractive variable assignment in RAM would 
not be available.

Could the existing HiMem driver on the ESP32 with bank switching be 
extended, to also support FRAM for use with malloc? Our FRAM is 
connected to a different SPI bus then the PS-RAM.

Or is it not a good idea to expose the SPI-FRAM via malloc, and we 
should use a device driver and let the user access the content via a 
mount point in the file system?

Best regards,
Michael


Re: Porting Nuttx to new board: Question about SPI-FRAM / malloc

Posted by Xiang Xiao <xi...@gmail.com>.
You can either:

   1. Or expose FRAM as a tmpfs through mount pointer
   2. If you want to use FRAM as PSRAM, you can add FRAM to the system heap
   with kmm_addregion
   3. If you want to use FRAM as an separated heap, you can call
   mm_initialize, mm_malloc and mm_free

https://github.com/apache/incubator-nuttx/blob/master/include/nuttx/mm/mm.h#L155-L156

depending on your case, you may select one or several approaches together.

On Wed, Jul 27, 2022 at 4:24 PM <mi...@mdc-service.de> wrote:

> Dear all,
>
> we are in the process of porting Nuttx to our new EsPiFF-V3 board. Basic
> Nuttx with nsh is working already. This is a board with a ESP32-WROVER
> module, and has additional SPI-connected FRAM (2kB to 256kB possible).
> How could the SPI-connected FRAM be integrated into Nuttx?
>
> - the FRAM is as fast as the ESP32-SPI PSRAM, and it should offer the
> application to store process variables and not lost it when power down.
> Best would be, when it can be addressed with malloc() or similar
> function for the user.
>
> - SPI-based EEPROMs have traditionally a mount point in the file system,
> and are exposed as a device driver to the user. I could implement it in
> this way, but as such, the attractive variable assignment in RAM would
> not be available.
>
> Could the existing HiMem driver on the ESP32 with bank switching be
> extended, to also support FRAM for use with malloc? Our FRAM is
> connected to a different SPI bus then the PS-RAM.
>
> Or is it not a good idea to expose the SPI-FRAM via malloc, and we
> should use a device driver and let the user access the content via a
> mount point in the file system?
>
> Best regards,
> Michael
>
>