01 Overview
SPIFFS is the built-in flash filesystem in ESP-IDF, designed for small files and low-capacity scenarios. It formats a partition of internal flash and exposes it through the standard VFS interface (fopen/fwrite/readdir).
It solves the problem of managing static resources (web pages, icons, certificates, small logs) as files, instead of stuffing data into NVS or compiling it into firmware. SPIFFS allows runtime read/write and supports pre-seeding files at manufacturing time.
Typical uses: local web server pages and CSS/JS, TLS client certificates, JSON backups of device config, low-frequency sensor logs.
It is not a general-purpose hard disk: capacity is small (typically hundreds of KB to a few MB), write endurance is limited, and power loss can corrupt files. For high-rate logs, use an SD card or external storage.
Division of labor with NVS: NVS is for small key-value pairs (Wi-Fi config, calibration values), SPIFFS is for file-type data. Keep critical config in NVS to avoid device lockout due to file corruption.
This example demonstrates how to mount SPIFFS, read/write files, and pre-seed resources in a factory image.