Most devices need to store data either configuration files, sensor data firmware updates, and while it’s in theory possible to write directly to the storage device, it’s normally not a good idea to do so due to issues such as wear, which could lead to a premature death of your storage…
LittleFS is an open source file system specifically designed for small devices such as IoT nodes for SPI NOR flash and SD card storage, and introduced in Mbed OS 5.7. The “high-integrity embedded file system” is resilient to power-cuts, supports wear-leveling, and comes in a small memory and storage footprint.
Mbed support both FAT and LittleFS, so the latter was compared to the former with the following key highlights:
- Footprint – Code for LittleFS takes 13KB less storage than FAT, and 4KB less RAM
- Power loss resilience – The file system has strong copy-on-write guarantees, and storage on disk is always kept in a valid state. FAT has no such resilience
- Wear-leveling – LittleFS file system provides a form of dynamic wear leveling for systems that cannot fit a full flash translation layer. FAT has no wear-leveling capabilities.
One of the downsides of LittleFS is that if you use (micro) SD cards for your project(s), you’ll lose compatibility with your computer, although if you run Linux there’s a FUSE wrapper that will allow you to mount littleFS in your computer.