The SPI Flash File System or SPIFFS is a light-weight file system for microcontrollers with an SPI flash chip. A flash file system is designed for storing files on flash memory–based storage devices optimized for the particular system.
SPI stands for Serial Peripheral Interface. Flash memory is a type of non-volatile storage that is electrically eraseable and rewriteable. Flash memory is a kind of non-volatile memory much used for storing programs for simple microprocessors.
SPI flash is a flash module that is interfaced to over SPI. SPI flash modules are handy because they are low cost and have a small footprint. SPI interfaces can be moderately fast by cheap embedded controller standards (133MHz). Some support 2-bit and 4-bit data buses as well, increasing transfer rates further over a pure serial interface.
Compared to modern processors, of course, SPI is slow.
The on-board flash chip of the ESP32 has plenty of space, most have 4MB or 8MB version. SPIFFS let us access the flash memory like a normal file system like the one on our computer. We can read and write files, create folders.
---
We can mount the file system, read and write files, create folders. If you have installed the newer version of ESP32 software for Arduino IDE (which is just the normal guide we have), then probably the required library for SPIFFS on ESP32 Arduino already installed and your Arduino IDE have example sketches. From Arduino IDE, navigate to to File > Examples > SPIFFS > Simple_Test and load the example to test compile to check whether it supports the two libraries FS and SPIFFS :
1 2 3 | #include "FS.h" #include "SPIFFS.h" ... |
Now, go here and download the zip file :
1 | https://github.com/me-no-dev/arduino-esp32fs-plugin/releases/ |
In your Arduino sketchbook directory, create tools directory if it does not exist yet. Unpack the tool into tools directory (the path will look like
). Restart Arduino IDE.
After Arduino IDE is started. You’ll see there is a new menu item option under the Tools menu named ESP32 Sketch Data Upload
. This menu is for starting upload the files into ESP32 flash file system. This is an example code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include "SPIFFS.h" void setup() { Serial.begin(115200); if (!SPIFFS.begin(true)) { Serial.println("An Error has occurred while mounting SPIFFS"); return; } File file = SPIFFS.open("/example.txt", FILE_WRITE); if (!file) { Serial.println("There was an error opening the file for writing"); return; } if (file.print("TEST")) { Serial.println("File was written"); } else { Serial.println("File write failed"); } file.close(); } void loop() {} |
Save the sketch. Now from Arduino IDE and go to Sketch > Show Sketch Folder. Create a directory/folder named data in that location. Inside the data folder is where you should put the files you want to be saved into the ESP32 filesystem. As an example, create a text file named example.txt
with some text. Upload it. Open Serial Monitor of Arduino IDE. Now click the menu item option under the Tools menu named ESP32 Sketch Data Upload
.
A common error you may face is :
SPIFFS Error: esptool not found!
It is means you need to use the latest versions of ESP32 software for Arduino IDE and the SPIFFS tool.
Tagged With file system in flash , sketch speech recognition esp32 , spi flash file , esp32 spiffs , spiffs h , esp32 spiffs example , esp32 mounting file system in flash , esp32 file system , what is spiffs esp32 , arduino ESP32 windows file explorer for SPIFFs tool