SPIFFS
0.3.7Features
-
Designed for low RAM usage on small embedded targets without dynamic memory allocation (heap).
-
Uses statically sized RAM buffers that remain independent of the number of files present.
-
Provides a POSIX-like API including open, close, read, write, seek, and stat functions.
-
Compatible with any NOR flash, including SPI flash and internal microprocessor flash.
-
Supports multiple SPIFFS configurations running concurrently on the same target or flash device.
-
Implements static wear leveling to prolong the life of flash memory by distributing erase cycles.
-
Includes built-in file system consistency checks to ensure data integrity after power loss.
-
Highly configurable through compile-time defines to adjust page/block sizes and features.
-
Supports optional file metadata for storing additional information alongside files.
-
Features index memory mapping to improve file reading performance and determinism.
-
Includes a temporal cache system to speed up file opening operations by caching file descriptors.
-
Offers a read-only build configuration to minimize the library’s binary footprint.
-
Provides both quick (non-intrusive) and full-scale (intrusive) garbage collection mechanisms.
-
Supports a flat file structure without directory support to minimize metadata overhead.
-
Includes API functions for file system formatting and retrieving usage information.
-
Allows for file renaming and explicit error code clearing via SPIFFS_clearerr.
-
Supports singleton mode to optimize performance and RAM when only one instance is used.
-
Configurable garbage collection heuristics to tune wear-leveling behavior.
-
Provides a HAL layer requiring only three basic functions: read, write, and erase.
Architecture
SPIFFS operates on a logical abstraction layer over physical NOR flash memory. It divides the flash into logical blocks, which are further subdivided into logical pages. A logical page is the smallest unit of data storage and metadata tracking. The system is designed to be entirely heap-less, relying on user-provided static buffers for work areas, file descriptors, and optional caches. This design ensures deterministic memory usage, which is critical for small embedded systems.
The file system utilizes a flat structure where filenames can include slashes to simulate paths, but no actual directory hierarchy exists. This minimizes the metadata overhead required for navigation. The architecture includes a Hardware Abstraction Layer (HAL) that requires only three primitive operations from the user: read, write, and erase. Internally, SPIFFS manages an object index to track file locations and a garbage collector that reclaims space from deleted or modified files while maintaining wear leveling across the flash blocks.
Core Components
- HAL Interface: The bridge between SPIFFS and physical flash hardware, handling address-based read, write, and erase calls.
- Object Indexer: Manages file metadata, including names, sizes, and the mapping of logical pages to physical locations.
- Garbage Collector: Implements heuristics to select blocks for erasure, balancing free space reclamation with wear leveling.
- Cache Subsystem: Provides optional read/write caching and a temporal file descriptor cache to improve performance on frequently accessed files.
- Consistency Checker: A built-in tool to verify the integrity of the file system structure and repair common issues caused by unexpected power loss.
Use Cases
This library is ideal for:
- IoT Sensors: Storing periodic sensor readings on small SPI flash chips where RAM is extremely limited.
- Configuration Management: Saving and updating device settings, calibration data, and network credentials in non-volatile memory.
- Bootloaders: Utilizing the read-only mode to load firmware images from flash while maintaining a minimal binary footprint.
- Data Logging: Efficiently appending logs to files with wear leveling to prevent premature failure of specific flash sectors.
- Embedded Web Servers: Storing static assets like HTML, CSS, and JavaScript files for local device management dashboards.
- Resource Storage: Storing UI assets, fonts, or lookup tables for microcontrollers driving small displays.
Getting Started
To integrate SPIFFS into an embedded project, begin by copying the source files from the src/ directory and the spiffs_config.h template into your build system. You must define basic integer types (e.g., u32_t, s32_t) in the configuration header to match your architecture. The integration requires implementing three HAL functions for your specific flash hardware: read, write, and erase.
Once the HAL is ready, initialize a spiffs_config struct with the physical parameters of your flash (start address, total size, and block sizes) and provide the necessary static RAM buffers for the work area and file descriptors. Call SPIFFS_mount to initialize the system. If the flash is unformatted or contains invalid data, SPIFFS_format must be called before a successful mount can occur. For detailed configuration options and performance tuning, refer to the SPIFFS Wiki.
Related Projects (121)
Apache NuttX for SF2000
A port of the Apache NuttX real-time operating system targeting the Data Frog SF2000 handheld console. It provides a POSIX-compliant environment with a small footprint, supporting 8-bit to 64-bit microcontroller environments with a focus on standards and modularity.
ESP32 Remote Control with WebSocket
A comprehensive tutorial-based project for building a real-time remote control interface on the ESP32. It utilizes WebSockets for bidirectional communication, JSON for data serialization, and SPIFFS for hosting web assets, all built within the Arduino framework using PlatformIO.
NMEA0183-WiFi Marine Data Gateway
An ESP32-based marine data gateway that captures NMEA0183 messages over UDP and serves them through a real-time web interface. It features environmental monitoring using M5Stack sensors, historical data logging to SPIFFS, and integrated Over-The-Air (OTA) update capabilities.
NodeMCU Device Lua Modules
A comprehensive collection of Lua modules and a build environment for NodeMCU firmware, targeting ESP8266 and ESP32 microcontrollers. It includes features for WiFi management, Home Assistant integration, and various sensor/controller implementations using SPIFFS and LFS.
OFMon: Offline-first Smart Energy Monitoring
An offline-first energy monitoring system built with Rust for ESP32 microcontrollers. It utilizes LittleFS for power-loss resilient local storage and integrates with a custom Flutter mobile app and the Thingsboard IoT platform for data synchronization and visualization.
openHASP
A comprehensive firmware for ESP32 and STM32F4 microcontrollers that provides a customizable touchscreen UI controlled via MQTT. It utilizes the LVGL graphics library to drive various commodity displays, enabling home automation control through a flexible JSONL-based configuration.
ReadMePaper: ESP32 7-Color e-Paper Display Project
An ESP32-based firmware for displaying 24-bit BMP images on a Waveshare 7-color e-Paper module. It features a REST API to receive image URLs over WiFi, stores them in SPIFFS, and renders them on the display using the Arduino framework.
Sistema de Apertura de Portón con Módulo GSM
An ESP32-based application designed to control an electric gate remotely using SMS via a SIM800L GSM module. The system manages authorized users through a text file in SPIFFS and ensures gate state persistence across reboots using the Preferences library.
Snow Radio
An advanced ESP32-based internet radio application featuring a VS1053 audio codec and a real-time spectrum analyzer. It supports touchscreen and gesture-based controls, provides a web interface for station management, and integrates OpenWeatherMap data for environmental updates.
Thing: Simplified MQTT Framework for ESP8266 and ESP32
A lightweight Arduino library for building MQTT-connected sensors and actuators on ESP8266 and ESP32 platforms. It automates WiFi management and MQTT connectivity while storing configuration settings securely in SPIFFS to avoid hardcoded credentials.
Timezone_Generic Library
A comprehensive Arduino library for handling timezone conversions and automatic Daylight Saving Time (DST) adjustments across a wide range of embedded platforms. It supports numerous microcontrollers including ESP32, ESP8266, STM32, and RP2040, integrating with various storage and networking modules.
Vortex Cannon ESP32 Access Point Controller
A GPIO control system and browser interface for a vortex cannon project based on the ESP32. It utilizes a wireless access point with a captive portal and a SPIFFS-hosted web server to provide remote control capabilities via a mobile device.
WebServer_ESP32_W5500
A comprehensive WebServer and HTTP/HTTPS client wrapper library for ESP32-based boards using the W5500 Ethernet controller with LwIP. It provides an API compatible with standard ESP32 and ESP8266 WebServer libraries, supporting MQTT, WebSockets, and file serving from LittleFS or SPIFFS.
Mongoose OS
Mongoose OS is a comprehensive IoT firmware development framework designed for microcontrollers like ESP32, ESP8266, and STM32. It provides built-in support for over-the-air (OTA) updates, security via flash encryption and mbedTLS, and seamless integration with major cloud providers like AWS IoT and Google Cloud IoT Core.
MultiResetDetector_Generic Library
A cross-platform Arduino library for detecting multiple resets within a configurable timeout period. It supports a vast array of hardware including AVR, STM32, SAMD, nRF52, and RP2040, utilizing various storage backends like EEPROM, FlashStorage, and LittleFS to persist reset counts for triggering configuration modes or special startup routines.
Lua RTOS for ESP32
Lua RTOS is a real-time operating system for embedded systems, featuring a Lua 5.3 interpreter on top of a FreeRTOS-powered micro-kernel. It provides a hardware abstraction layer for ESP32, ESP8266, and PIC32MZ platforms, allowing for programming via Lua or a block-based IDE.
LVGL Port for M5Stack Core2
A port of the Light and Versatile Graphics Library (LVGL) for the M5Stack Core2 development kit based on the ESP32. It utilizes the ESP-IDF framework and FreeRTOS to provide a high-performance graphical user interface on the device's integrated display, including support for the AXP192 power management chip.
Marauder Centauri
A portable suite of WiFi and Bluetooth offensive and defensive tools built for the ESP32 microcontroller. It enables security researchers to perform packet sniffing, beacon spamming, and network analysis through a dedicated handheld interface utilizing the Arduino framework.
MicroPython for ESP32 with psRAM Support (LoBo Port)
A specialized MicroPython port for ESP32 microcontrollers with extensive support for external psRAM (SPIRAM) up to 16MB. Built as an ESP-IDF component, it features dual-core support, integrated hardware drivers, and advanced networking modules including MQTT, FTP, and GSM/PPPoS.
MicroPython for Kendryte K210 (LoBo Port)
A comprehensive MicroPython port for the Kendryte K210 64-bit RISC-V SoC, built upon the Kendryte FreeRTOS SDK. It features dual-core support, advanced multi-threading, and extensive peripheral drivers for displays, networking, and file systems.
Mongoose to Tasmota, Home Accessory Architect or ESPurna
A minimal intermediate firmware for OTA flashing target firmwares like Tasmota, HAA, or ESPurna onto Shelly devices. Built on Mongoose OS, it provides a bridge for migrating ESP8266-based smart home hardware from stock firmware to open-source alternatives.
HTTPS_Server_Generic Library
A comprehensive HTTP and HTTPS server library for ESP32-based boards, supporting WiFi and various Ethernet controllers like W5500, W6100, and ENC28J60. It provides an Express-like API for handling routes, middleware, and asynchronous request processing using the ESP32's multi-tasking capabilities.
IoT Agricultural Data Monitoring System
An IoT-based monitoring system for agricultural fields using an ESP8266 or ESP32 microcontroller. It collects temperature, humidity, soil moisture, and rainfall data, serving a dynamic web interface hosted directly on the device's flash memory via SPIFFS.
IoT Industrial Operation and Room Condition Monitor
An IoT-based monitoring system using an Arduino and NodeMCU to track industrial parameters like temperature, humidity, gas levels, and production counts. It features a web-based dashboard hosted on the NodeMCU via SPIFFS and provides real-time warnings when sensor thresholds are exceeded.
IoT Project on HVAC
An ESP8266-based HVAC control system that monitors temperature, humidity, and atmospheric pressure. It features a real-time web dashboard using SPIFFS and asynchronous web serving, with automated relay control to maintain environmental parameters within defined thresholds.
ESP_DoubleResetDetector Library
A specialized Arduino library for ESP32 and ESP8266 microcontrollers designed to detect double-reset events. It enables developers to trigger specific actions, like opening a configuration portal or clearing settings, by detecting two consecutive resets within a defined time window using various storage backends.
ESP-Datalogger with Firebase and SPIFFS
A data-logging application for the ESP8266 that records system metrics and sensor data to local SPIFFS storage in CSV format. It features a web-based interface for file management and visualization, while simultaneously synchronizing data to a Firebase Realtime Database.
ESP8266 Config Data Management
A demonstration project for the ESP8266 that uses SPIFFS to store and retrieve application configuration data in JSON format. It provides a structured way to manage sensitive information like WiFi credentials and system settings outside of the source code using the Arduino framework.
ESP8266 DHT22 SPIFFS Demo
A demonstration project for ESP8266 microcontrollers featuring DHT22 sensor integration and a web-based file manager using SPIFFS. It provides a secure web interface with Basic Authentication for monitoring environmental data and managing static files on the device's flash storage.
ESP8266_ENC_Manager
A connection and credentials manager for ESP8266 boards using ENC28J60 Ethernet modules. It provides a fallback web configuration portal for runtime setup of static or DHCP IP addresses, DNS servers, and NTP settings, utilizing the LwIP stack and Arduino framework.
ESP8266_W5500_Manager
A connection and credentials manager for ESP8266 boards using the W5500 Ethernet controller. It provides a web-based configuration portal for setting static or DHCP IP addresses, DNS servers, and custom parameters at runtime, with support for LittleFS and SPIFFS.
ESP8266 Webserver Tutorials
A comprehensive collection of tutorials and example projects for building robust web servers on the ESP8266 platform. It covers advanced features including SPIFFS file system management, NTP time synchronization, JSON data handling, and interactive dashboards using Google Charts.
ESP8266 WiFi Relay Async
An asynchronous web server application for the ESP8266 platform designed to control multiple relay modules via a web interface. It utilizes the ESPAsyncWebServer library for non-blocking communication and includes features like MDNS support, ArduinoOTA updates, and SPIFFS-based configuration.
ESP8266 Wireless Sensor Network (WSN)
A Wireless Sensor Network implementation using ESP8266 microcontrollers to collect and visualize environmental data. The system utilizes a client-server architecture where remote nodes transmit DHT11 sensor readings via HTTP to a central server that stores data and serves a web-based dashboard.
ESPGaggia: Smart Coffee Machine Controller
An ESP32-based firmware designed to upgrade Gaggia coffee machines with smart capabilities. It features PID and Fuzzy Logic temperature control, a custom scripting engine for brew recipes, and a touch-screen interface powered by LVGL, with full MQTT and Homebridge integration.
EspSaveCrashSpiffs
A specialized library for ESP8266 microcontrollers that automatically captures and saves crash information, including exception details and stack traces, to SPIFFS flash memory. It provides developers with persistent logs for diagnosing software exceptions and watchdog timer resets using the ESP Exception Decoder.
EUC-Dash-ESP32 Dashboard
A stand-alone Bluetooth dashboard for electric unicycles (EUCs) designed for the ESP32-based TTGO T-Watch 2020. It leverages the Arduino framework and FreeRTOS to provide real-time telemetry, power management, and system settings via a wearable interface. Currently supports KingSong wheels with features like speed monitoring, battery status, and OTA updates.
Fashion MNIST on ESP32 with TensorFlow Lite Micro
An example project demonstrating how to run the Fashion MNIST TFLite model on an ESP32 microcontroller using the ESP-IDF framework. It utilizes TensorFlow Lite Micro for edge AI inference, allowing the device to classify clothing items locally.
Freebees Access Control for ESP32
An ESP32-based access control system that integrates PN532 NFC readers, a DS3231 real-time clock, and MQTT for remote management. It features a web-based configuration interface, SPIFFS-based local storage for access keys, and support for dual readers and relays.
SHA2017 Badge Firmware
The official firmware for the SHA2017 hacker camp badge, built on the Espressif ESP-IDF framework and FreeRTOS. It provides a robust platform featuring a MicroPython runtime, uGFX graphics support for E-ink displays, and integrated WiFi connectivity for the ESP32-based hardware.
Animated GIF stored in SD Card and played from SPIFFS on a Round Display (GC9A01) with the ESP32
This project demonstrates how to display animated GIFs on a round GC9A01 TFT display using an ESP32. It implements a workflow that reads GIF files from an SD card, copies them to internal SPIFFS storage for optimized access, and renders them using the AnimatedGIF and TFT_eSPI libraries.
arduino-esp-utils
A collection of utility classes for ESP8266 and ESP32 chips that simplifies configuration management via SPIFFS, web server implementation with WebSockets, and OSC data streaming. It provides high-level abstractions to reduce boilerplate in Arduino-based IoT and interactive media projects.
AsyncESP32_SC_Ethernet_Manager
An asynchronous Ethernet connection manager for ESP32-S2/S3/C3 microcontrollers. It utilizes the LwIP stack with W5500 or ENC28J60 controllers to provide a web-based configuration portal for managing network credentials and static IP settings at runtime.
AsyncESP8266_ENC_Manager
A high-performance asynchronous connection and credentials manager for ESP8266 boards using the ENC28J60 Ethernet controller. It provides a fallback web configuration portal for runtime setup of DHCP/Static IP settings, hostnames, and custom application parameters stored in LittleFS or SPIFFS.
AsyncESP8266_W5100_Manager
An asynchronous Ethernet credentials and connection manager for ESP8266 boards using Wiznet W5100 or W5100S controllers. It provides a fallback web configuration portal for setting static or DHCP IP addresses, hostnames, and custom parameters at runtime using ESPAsyncWebServer.
AsyncESP8266_W5500_Manager
A comprehensive connection and credentials manager for ESP8266 boards equipped with W5500 Ethernet shields. It features an asynchronous web configuration portal for runtime network setup, supporting DHCP, static IP, and custom parameters stored via LittleFS or SPIFFS.
AsyncHTTPSRequest_Generic
A high-performance asynchronous HTTPS request library for ESP32 and ESP8266, enabling non-blocking REST communication. It supports a wide range of network interfaces including built-in WiFi and various Ethernet controllers like W5500, W6100, and ENC28J60.
AsyncWebServer_ESP32_SC_ENC
An asynchronous web server library specifically designed for ESP32-S2, S3, and C3 microcontrollers using the ENC28J60 Ethernet controller via the LwIP stack. It enables high-performance, non-blocking network communication, supporting concurrent connections, WebSockets, and Server-Sent Events.
AsyncWebServer_ESP32_SC_W5500
An asynchronous web server library designed for ESP32-S2/S3/C3 microcontrollers using the W5500 Ethernet controller. It leverages the LwIP stack to provide high-performance, non-blocking network handling, supporting WebSockets, EventSource, and efficient CString-based memory management.
AsyncWebServer_ESP32_W5500
A high-performance asynchronous web server library for ESP32 microcontrollers using the W5500 Ethernet controller. It leverages the LwIP stack to provide non-blocking network operations, supporting WebSockets, Server-Sent Events, and efficient memory handling for large data transfers.
awtk-fs-adapter
AWTK File System Adapter provides a unified interface for integrating various file systems like FATFS and SPIFFS into the AWTK (Toolkit AnyWhere) framework. It bridges the gap between embedded file system implementations and AWTK's file system API, supporting both single-threaded and multi-threaded environments.
Blynk_Async_ESP32_BT_WF
An advanced ESP32 library that enables simultaneous or runtime-selectable Blynk connections via WiFi, Bluetooth, and BLE. It leverages asynchronous web servers for a non-blocking configuration portal and supports multi-credential management with storage in SPIFFS, LittleFS, or EEPROM.
Blynk_Async_GSM_Manager
A comprehensive library for ESP32 and ESP8266 that enables simultaneous WiFi and GSM/GPRS connections for Blynk applications. It features an asynchronous web-based configuration portal to manage credentials at runtime, eliminating the need for hardcoded network settings.
Blynk_Async_WM
An asynchronous WiFi and Blynk configuration manager for ESP8266 and ESP32 platforms. It leverages ESPAsyncWebServer to provide a non-blocking configuration portal with support for multi-WiFi/multi-Blynk credentials, SSL, and persistent storage via LittleFS, SPIFFS, or EEPROM.
Blynk_WiFiManager
A powerful WiFi and Blynk configuration library for ESP8266 and ESP32 that eliminates hardcoded credentials. It provides a web-based portal for runtime configuration of multiple WiFi APs and Blynk tokens, supporting SSL and various storage backends like LittleFS and SPIFFS.
Blynk_WiFiNINA_WM
A comprehensive WiFi configuration manager and Blynk connection library for a wide range of Arduino-compatible boards using WiFiNINA modules. It enables runtime credential configuration via a web portal, supports multiple WiFi networks, and integrates with storage solutions like LittleFS and EEPROM to eliminate hardcoded credentials.
Chronothermostat: An AWS-Powered IoT Climate Control System
A comprehensive IoT chronothermostat system utilizing ESP32 nodes and a Raspberry Pi 3 gateway integrated with Amazon Web Services. It features multi-room temperature and humidity monitoring, remote control via MQTT, and a web-based GUI for scheduling and statistics.
EasyINI
EasyINI is a lightweight utility library for ESP8266 and ESP32 platforms designed to simplify reading and writing configuration data in .ini file format. It leverages the SPIFFS (Serial Peripheral Interface Flash File System) to provide a persistent storage solution for key-value pairs organized into sections.
Effortless-SPIFFS
Effortless-SPIFFS is a C++ library for ESP8266 and ESP32 that simplifies data persistence using the SPIFFS file system. It provides a high-level API for saving and loading various data types, including primitives, strings, and ArduinoJson documents, through simple template-based methods.
ESP32 AsyncWebServer File Upload Example
A practical demonstration of handling file uploads and management on the ESP32 using the ESPAsyncWebServer library and SPIFFS. It features examples ranging from simple single-page uploads to advanced implementations with authentication and real-time progress bars.
ESP32 BLE OTA Arduino
A project enabling Over-the-Air (OTA) firmware updates for ESP32 microcontrollers using Bluetooth Low Energy (BLE). It supports both the standard ESP32 BLE library and the more memory-efficient NimBLE-Arduino, providing Python scripts and an Android app for the update process.
ESP32 Monaco Editor SPIFFS
A project demonstrating a VSCode-like Monaco editor interface for the ESP32, allowing users to edit files stored on the SPIFFS filesystem via a web browser. It utilizes WebSockets for real-time communication and the ESPAsyncWebServer for handling file operations.
ESP32 MQTT Motor Control
An ESP32-based automation project for controlling window blinds using a 12V wiper motor and MQTT. It features multi-threaded motor control, soft-start PWM, over-current protection, and integration with Home Assistant for remote management and sensor data reporting.
ESP32 Sniffer
An ESP32-based firmware designed to capture Wi-Fi Probe Request packets sent by smartphones. Built on the ESP-IDF framework, it extracts metadata such as MAC addresses and signal strength, stores them locally using SPIFFS, and periodically uploads the data to a central server via MQTT.
ESP32 Spartan Edge SPIFFS Loader
A utility for the Spartan Edge Accelerator Board that enables loading FPGA bitstreams directly from the ESP32's internal SPIFFS flash memory. By utilizing the onboard 4MB flash chip, it allows the Spartan-7 FPGA to be configured without the need for an external microSD card.
ESP32 SPIFFS with Directory Support Example
This project provides an enhanced SPIFFS implementation for the ESP32, adding native directory support to the standard ESP-IDF VFS driver. It includes a modified mkspiffs tool for host-side image creation and demonstrates advanced file system operations including multitasking and time-stamped file management.
ESP32-targz
A comprehensive Arduino library for ESP32, ESP8266, and RP2040 that enables handling of .tar, .gz, and .tar.gz files. It supports compression, decompression, and streaming across various filesystems and network protocols, including specialized features for OTA firmware updates from compressed archives.
ESP32-TUX
ESP32-TUX is a comprehensive Touch UX template for ESP32 and ESP32-S3 microcontrollers, leveraging the LVGL graphics library and LovyanGFX driver. It provides a ready-to-use framework for building sophisticated HMI applications with features like Wi-Fi provisioning, OTA updates, and theme switching across various 3.5-inch display modules.
ESP32 SPIFFS Image Generation Example
This project provides a practical example of integrating the SPIFFS file system into an ESP32 application using the ESP-IDF framework. It features automated workflows for generating binary images from local data folders and flashing them to specific partitions on the ESP32.
ESP32_W5500_Manager
A comprehensive connection and credential manager for ESP32 boards using the W5500 Ethernet controller and LwIP. It provides a fallback web configuration portal for runtime setup of static or DHCP IP addresses, custom parameters, and NTP settings, supporting storage via LittleFS or SPIFFS.
ESP32 Web Server using SPIFFS
This project demonstrates how to host a web server on an ESP32 using the SPI Flash File System (SPIFFS) to serve static HTML and CSS files. It provides a practical example of controlling hardware GPIOs through a web interface, allowing users to toggle LEDs remotely.
Esp32PC8001SIO
A hardware and software bridge for the NEC PC-8001 vintage computer that utilizes an ESP32 to provide modern connectivity. It enables SNTP time synchronization, environmental monitoring via BME280, and file transfers from FTP servers or internal SPIFFS storage using the XMODEM protocol.