ESP32/ESP8266 Sketch Data Upload (SPIFFS and LittleFS FileSystems)

The ESP8266 and ESP32 devices from Espressif, allow for files to be embedded into a filesystem, which is in the same flash chip as your program.

As these share the same memory space, the size allocated to your filesystem depends both the size of the Flash Chip, and the program embedded.

Detailed Information about the sizes of Chips and Filesystems is available on the ESP8266 File System Page and the ESP32 SPIFFS Page.

 

Adding Files to the FileSystem

This is the same for both mechanisms:

1) Create a sub-folder in your project at the same level as the project.INO file, called "data"

2) Add any files you want to be uploaded to SPIFFS to this folder

 

SPIFFS

Warning Icon SPIFFS Note:

NOTE - SPIFFS is no longer maintained, and will be deprecated in future versions of the ESP8266 toolset.

To Perform a SPIFFS Upload:

1) Add code to your sketch to mount, and use the SPIFFS FileSystem (See Examples in IDE)

2) Select the relevant Flash Size Board Option for your Chip + FileSystem Usage

3) Build your Project (required before FS Upload)

4) Upload your SPIFFS Image from vMicro > Publish Server Data Files (spiffs)

5) Upload your Sketch as Normal

Automatic Filesystem Uploads

Since version 21.09.17.0, there is an additional Board Menu Option, to allow Automatic filesystem uploads to your board alongside the code upload.

To use this simply set the board option to On, then Build and Upload your code to your board as normal.

Filesysystem Automatic Uploads Board Menu Option

Note IconNote:

Many ESP8266 baords are not automatically put into bootloader mode.

You will need to put it back into bootloader mode between the sketch upload, and the Filesystem upload happening if the automatic option is used.

The output message below is shown to remind you of this when uploading with the Automatic FS upload enabled:

 

LittleFS

LittleFS is the successor to the SPIFFS system, and is still actively maintained, offering speed advantages over the SPIFFS system when used on-chip.

Versions Before 21.09.17.0 (ESP8266 Only)

Visual Micro will automatically switch to LittleFS when the SPIFFS tools are no longer found.  See the next section to force your project to use LittleFS instead of SPIFFS.

Force LittleFS

Add a Local Board.txt by right clicking the project in the Solution Explorer > Add > Local Board.txt

Add the below text to the file, and Save.  The project will now use the LittleFS system instead of SPIFFS.

# Force LittleFS Usage for ESP8266
        runtime.tools.mkspiffs.path=notTheToolYoureLookingFor 

To Perform a LittleFS Upload:

1) Add code to your sketch to mount, and use the LittleFS FileSystem (See ESP8266 Examples > LittleFS)

2) Select the relevant Flash Size Board Option for your Chip + FileSystem Usage

3) Build your Project (required before FS Upload)

4) Upload your SPIFFS Image from vMicro > Publish Server Data Files (spiffs)

5) Upload your Sketch as Normal

Versions After 21.09.17.0

Visual Micro now adds a board menu item to allow selection of SPIFFS or LittleFS:

To Perform a LittleFS Upload:

1) Add code to your sketch to mount, and use the LittleFS FileSystem (See ESP8266 Examples > LittleFS)

2) Select the relevant Flash Size Board Option for your Chip + SPIFFS FileSystem Usage

3) Select FS Option as LittleFS from the Drop down board Option

4) Build your project (required before FS Upload)

5) Upload your FS Image from vMicro > Publish Server Data Files (spiffs)

6) Upload your Sketch as Normal

 

If the mklittlefs.exe cannot be found, or you wish to use a different version the below setting can be added to a local board.txt to identify where the tool is:

Add a Local Board.txt by right clicking the project in the Solution Explorer > Add > Local Board.txt

Add the below text to the file, and Save.  The project will now use the LittleFS system instead of SPIFFS.

        # LittleFS Usage for ESP8266/32 when MkLittleFS.exe cannot be found
        # Only the path to the folder of the EXE needs adding as below;
        runtime.tools.mklittlefs.path=C:\Users\vMicro\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs

 

FatFS

FatFS is an alternative to the LittleFS File system, and is still actively maintained.

Versions After 2021.0917.6.0

Visual Micro now adds a board menu item to allow selection of SPIFFS or LittleFS:

To Perform a FatFS Upload:

1) Add code to your sketch to mount, and use the LittleFS FileSystem (See ESP8266 Examples > LittleFS)

2) Select the relevant Flash Size Board Option for your Chip + SPIFFS FileSystem Usage

3) Select FS Option as FatFS from the Drop down board Option

4) Build your project (required before FS Upload)

5) Upload your FS Image from vMicro > Publish Server Data Files (spiffs)

6) Upload your Sketch as Normal

 

If the fatfs.exe cannot be found, or you wish to use a different version the below setting can be added to a local board.txt to identify where the tool is:

Add a Local Board.txt by right clicking the project in the Solution Explorer > Add > Local Board.txt

Add the below text to the file, and Save.  The project will now use the LittleFS system instead of SPIFFS.

        # LittleFS Usage for ESP8266/32 when FatFS.exe cannot be found        
        # Only the path to the folder of the EXE needs adding as below;
        runtime.tools.fatfs.path=C:\Users\vMicro\AppData\Local\Arduino15\packages\esp8266\tools\mklittlefs
        # This ensures FatFS is used instead of LittleFS
        runtime.tools.mklittlefs.path=NotTheToolYourLookingFor

 

Further Information

All methods accessible for both File Systems and their usage can be found in the ESP8266 Documentation here