/LittleFS

LittleFS library for arduino-esp32

Primary LanguageCGNU General Public License v2.0GPL-2.0

LittleFS_esp32 for Tasmota (Arduino IDF 3.3.x)

***Notice: The Library is been integrated to Arduino esp32 core idf-release/v4.2 branch and later versions

LittleFS library for arduino-esp32

Usage

#define USE_LittleFS

#include <FS.h>
#ifdef USE_LittleFS
  #define SPIFFS LittleFS
  #include <LittleFS.h>
#else
  #include <SPIFFS.h>
#endif
  • Note, this may not work if your sketch uses other libraries that use SPIFFS themselves.
  • See also esp_partition.h . LITTLEFS re-uses same type and subtype as SPIFFS

Differences with SPIFFS

  • LittleFS has folders, you need to iterate files in folders unless you set #define CONFIG_LITTLEFS_SPIFFS_COMPAT 1
  • At root a "/folder" = "folder"
  • Requires a label for mount point, NULL will not work. Recommended is to use default LITTLEFS.begin()
  • maxOpenFiles parameter is unused, kept for compatibility
  • LITTLEFS.mkdir(path) and LITTLEFS.rmdir(path) are available
  • file.seek() behaves like on FFat see more details
  • file.write() and file.print() when partition space is ending may return different than really written bytes (on other FS is also inconsistent).
  • Speed comparison based on LittleFS_test.ino sketch (for a file 1048576 bytes):
Filesystem Read time [ms] Write time [ms]
FAT 276 14493
LITTLEFS 446* 16387
SPIFFS 767 65622

*The read speed improved by changing #define CONFIG_LITTLEFS_CACHE_SIZE from 128 to 512

Arduino ESP32 LittleFS filesystem upload tool

PlatformIO

  • See LITTLEFS_PlatformIO example here ( based on notes below 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