On BiBoard (ESP32), in addition to the regular program area and boot area, we use the file system in the Flash partition.
The role of a file system with independent partitions is as follows:
Save the data at the specified address and will not be deleted due to re-update (such as calibration data, gait data)
No external SD card needed, saving hardware resources
Common file systems include Windows NTFS, exFAT, and Linux log file systems Ext and XFS. But in the embedded field, these large file systems are too large. We use the lightweight SPIFFS (SPI Flash File System), an embedded file system for SPI NOR flash devices, and support functions such as wear leveling and file system consistency checking.
Because of its light weight, the biggest feature of SPIFFS is that it does not support tree directories, that is, all files are stored in the same layer. SPIFFS provided by ESP32 has the following features:
Currently, SPIFFS does not support directories, it produces a flat structure. If SPIFFS is mounted under /spiffs, then creating a file with the path /spiffs/tmp/myfile.txt will create a file called /tmp/myfile.txt in SPIFFS, instead of myfile.txt in the directory /spiffs/tmp.
It is not a real-time stack. One write operation might take much longer than another.
For now, it does not detect or handle bad blocks.
You can create/save and delete files with your own Arduino code, but the operation is cumbersome. You need to put data or even binary files into Arduino Sketch and create files by running the program.
However, there is a very useful tool that can directly upload files from the computer to the file system. Although it is slightly more troublesome than the "drag-and-drop" copy of the "removable storage", whether it is MP3 audio or HTML web files, all can be easily uploaded to flash memory. Let's learn how to use this plugin.
Please install the latest Arduino IDE and the ESP32 support package of Arduino IDE (refer to the instructions).
Download the compressed package of the ESP32FS plug-in at:
Go to the Arduino IDE directory and open the "Tools" folder.
Unzip the downloaded .zip folder to the Tools folder. You should have a similar folder structure：
<home_dir> / Arduino- <version> / tools / ESP32FS / tool / esp32fs.jar
Finally, restart the Arduino IDE.
To check whether the plug-in has been successfully installed, open the Arduino IDE. Select your ESP32 development board, go to "Tools", and then check if there is an "ESP32 Sketch Data Upload" option.
To upload files to the ESP32 file system, follow the steps below:
Create an Arduino project and save
To open the project directory, you can use the "Sketch-Show Sketch Folder" option
Inside this folder, create a new folder named "data"
In the "data" folder, you should put the file which you want to save into the ESP32 file system. For example, create a .txt file that contains some text named "test_example".
Please go to Tools> ESP32 Sketch Data Upload in Arduino IDE
When you see the "SPIFFS Image Uploaded" message, the file has been successfully uploaded to the ESP32 file system.
The demo of the file system comes from the official ESP32 without modification. The code implements the basic operation of "addition, deletion, modification, and check", and provides a SPI flash IO test program.
If necessary, it is recommended to directly use the code of the demo to operate ESP32 SPIFFS.