littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
4.92k stars 774 forks source link

Can littleFS run with STM32 and external raw NAND Flash ? #856

Open ShaiBinary opened 1 year ago

ShaiBinary commented 1 year ago

Can littleFS run with STM32 and external raw NAND Flash ?

kyrreaa commented 8 months ago

If you write a NAND access layer for it to init the flash and provide the read, write and erase functions then LittleFS should not care what the underlying storage really is. This is what I have done for nRF5340 (SPIM access since QSPI was hardcoded for NOR flash). You need to set up good values for the read-, write- and erase-blocks as well as cache though so the requests align with the flash and your implementation. (If you ONLY implement single sector writes for example, do not give LittleFS a larger cache or it will request multi-sector writes occasionally.)

geky commented 8 months ago

I just wanted to comment that even if you limit LittleFS's cache, LittleFS may still write multiple-sectors in a single prog call. This can happen if you call lfs_file_write with a buffer larger than the cache, in which case LittleFS bypasses the cache.

Also LittleFS has a number of performance issues with NAND, particularly it does not scale well when block sizes become large. It may be worth looking into the issues labeled performance.

kyrreaa commented 7 months ago

Thank you @geky that is very useful to know. It also explains why I had some issues with my access layer before as I had done a naive implementation assuming only single block writes.