|Brian Pugh 6a08044e04 Update README.md||2 weeks ago|
|.github||1 month ago|
|example||1 month ago|
|include||1 month ago|
|mklittlefs @ a14dabe444||6 months ago|
|src||1 month ago|
|unit_tester||2 years ago|
|.gitignore||6 months ago|
|.gitmodules||6 months ago|
|CMakeLists.txt||1 month ago|
|Kconfig||2 months ago|
|LICENSE||1 year ago|
|Makefile||7 months ago|
|README.md||2 weeks ago|
|component.mk||7 months ago|
|idf_component.yml||3 weeks ago|
|partition_table_unit_test_app.csv||2 years ago|
|project_include.cmake||5 months ago|
|sdkconfig.defaults||1 month ago|
LittleFS for ESP-IDF.
LittleFS is a small fail-safe filesystem for microcontrollers. We ported LittleFS to esp-idf (specifically, the ESP32) because SPIFFS was too slow, and FAT was too fragile.
There are two ways to add this component to your project
As a ESP-IDF managed component: In your project directory run
idf.py add-dependency joltwallet/littlefs==1.3.1
As a submodule: In your project, add this as a submodule to your
git submodule add https://github.com/joltwallet/esp_littlefs.git git submodule update --init --recursive
The library can be configured via
idf.py menuconfig under
See the official ESP-IDF SPIFFS documentation, basically all the functionality is the
same; just replace
littlefs in all function calls.
Also see the comments in
Slight differences between this configuration and SPIFFS's configuration is in the
max_filesfield doesn't exist since we removed the file limit, thanks to @X-Ryl669
partition_labelis not allowed to be
NULL. You must specify the partition name from your partition table. This is because there isn't a define
littlefspartition subtype in
esp-idf. The subtype doesn't matter.
At compile time, a filesystem image can be created and flashed to the device by adding the following to your project's
For example, if your partition table looks like:
# Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x6000, phy_init, data, phy, 0xf000, 0x1000, factory, app, factory, 0x10000, 1M, graphics, data, spiffs, , 0xF0000,
and your project has a folder called
device_graphics, your call should be:
Here are some naive benchmarks to give a vague indicator on performance.
Formatting a ~512KB partition:
FAT: 963,766 us SPIFFS: 10,824,054 us LittleFS: 2,067,845 us
Writing 5 88KB files:
FAT: 13,601,171 us SPIFFS*: 118,883,197 us LittleFS**: 6,582,045 us LittleFS***: 5,734,811 us *Only wrote 374,784 bytes instead of the benchmark 440,000, so this value is extrapolated **CONFIG_LITTLEFS_CACHE_SIZE=128 ***CONFIG_LITTLEFS_CACHE_SIZE=512 (default value)
In the above test, SPIFFS drastically slows down as the filesystem fills up. Below is the specific breakdown of file write times for SPIFFS. Not sure what happens on the last file write.
SPIFFS: 88000 bytes written in 1325371 us 88000 bytes written in 1327848 us 88000 bytes written in 5292095 us 88000 bytes written in 19191680 us 22784 bytes written in 74082963 us
Reading 5 88KB files:
FAT: 3,111,817 us SPIFFS*: 3,392,886 us LittleFS**: 3,425,796 us LittleFS***: 3,210,140 us *Only read 374,784 bytes instead of the benchmark 440,000, so this value is extrapolated **CONFIG_LITTLEFS_CACHE_SIZE=128 ***CONFIG_LITTLEFS_CACHE_SIZE=512 (default value)
Deleting 5 88KB files:
FAT: 934,769 us SPIFFS*: 822,730 us LittleFS**: 31,502 us LittleFS***: 20,063 us *The 5th file was smaller, did not extrapolate value. **CONFIG_LITTLEFS_CACHE_SIZE=128 ***CONFIG_LITTLEFS_CACHE_SIZE=512 (default value)
LittleFS operates on blocks, and blocks have a size of 4096 bytes on the ESP32.
A freshly formatted LittleFS will have 2 blocks in use, making it seem like 8KB are in use.
To flash the unit-tester app and the unit-tests, run
To test on an encrypted partition, add the
encrypted flag to the
flash_test, data, spiffs, , 512K, encrypted
Also make sure that
The unit tester can then be flashed via the command:
make TEST_COMPONENTS='src' encrypted-flash monitor
0x74('t' ascii value).
This code base was heavily modeled after the SPIFFS esp-idf component.