LittleFS library for arduino-esp32
- A LittleFS wrapper for Arduino ESP32 of Mbed LittleFS
- Based on ESP-IDF port of joltwallet/esp_littlefs , thank you Brian!
- See also the LillteFS library for ESP8266 core
- Functionality is similar to SPIFFS
- Related PR at esp32 core development
- Related PR at esp-idf development
! Warning: This wrapper depends on ESP-IDF, esp32 core, esp_littlefs and Mbed LittleFS versions
- Tested with esp32 cores built on IDFv3.2, IDFv3.3 and esp32s2 on IDFv4.2
- For esp32 core release 1.0.4 w/ IDFv3.2 you need to uncomment this line in esp_littlefs.c:
- See LITTLEFS_time example with file timestamps that works with esp32 core on IDF v3.3
- Copy LITTLEFS to Arduino IDE /libraries folder (File > Preferences > Sketchbook location).
- Use LITTLEFS same way as SPIFFS
- A quick startup based on your existing code you can re-define SPIFFS like this
#define USE_LittleFS #include <FS.h> #ifdef USE_LittleFS #define SPIFFS LITTLEFS #include <LITTLEFS.h> #else #include <SPIFFS.h> #endif
Differences with SPIFFS
- LittleFS has folders, you need need to iterate files in folders
- At root a "/folder" = "folder"
- Requires a label for mount point, NULL will not work
- maxOpenFiles parameter is unused, kept for compatibility
- LITTLEFS.mkdir(path) and LITTLEFS.rmdir(path) work as expected for folders
- Speed comparison based on LittleFS_test.ino sketch (for a file 1048576 bytes):
|Filesystem||Read time [ms]||Write time [ms]|
*The read speed improved by changing
#define CONFIG_LITTLEFS_CACHE_SIZE from 128 to 512
Arduino ESP32 LittleFS filesystem upload tool
- Use (replace if exists) arduino-esp32fs-plugin with this variant, which supports SPIFFS, LittleFS and FatFS
- Requires mklittlefs executable which is available in releases section here or download the zipped binary here or from esp-quick-toolchain releases here
- Copy it to /tools folder of esp32 platform where espota and esptool (.py or.exe) tools are located
- Restart Arduino IDE.
(notes from BlueAndi )
Add to platformio.ini:
extra_scripts = replace_fs.py
Add replace_fs.py to project root directory (where platformio.ini is located):
Import("env") print("Replace MKSPIFFSTOOL with mklittlefs.exe") env.Replace (MKSPIFFSTOOL = "mklittlefs.exe")
- Add mklittlefs.exe to project root directory as well.
Credits and license
- This work is based on Mbed LittleFS , ESP-IDF port of joltwallet/esp_littlefs , Espressif Arduino core for the ESP32, the ESP-IDF - SPIFFS Library
- Licensed under GPL v2 (text)