Best practice for implementing bare metal or lightweight OS flash file system?

Although you reference a 1 MB SPI Serial Flash chip, I think it is much more common to see file systems implemented on removable SD cards. That has two advantages: much larger storage (GB instead of MB), and you can remove the SD cards and read/write them on a PC.

An additional advantage is that the name-brand SD card makers like Kingston and SanDisk provide wear-leveling as part of the SD card architecture (but don't count on that from less expensive SD card makers).

Microchip (and I am sure other vendors) has a library you can use to implement either a FAT16 or FAT32 filesystem on an SD card. It is described in this application note AN1045, "Implementing File I/O Functions Using Microchip’s Memory Disk Drive File System Library". Obviously this will be targetd for PIC microcontrollers.

The low-level read/write SD card sector routines in this library could probably be modified to work with a SPI serial flash, but you would need to do your own wear-leveling and bad sector marking which would add a lot of complexity.


Here is one option I found during the search: a lightweight filesystem for SPI flash storage: SPIFFS

It doesn't have bad block management support, but it seems pretty complete otherwise as far as a really simple way to read and write files!

Tags:

Flash

Stm32