ESP32: Upload Files to LittleFS using Arduino IDE

In this guide, you’ll learn how to upload files to the ESP32 Filesystem (LittleFS) by using a plugin for Arduino IDE (1.8.X). LittleFS is a lightweight filesystem created for microcontrollers that lets you access the flash memory like you would do in a standard file system on your computer, but simpler and more limited. The plugin we’ll install lets you use three different filesystems: LittleFS, SPIFFS, or FatFS.

ESP32 Upload Files to LittleFS using Arduino IDE

At the moment, this method is not compatible with Arduino 2.0. So, you should be using Arduino IDE version 1.8.X.

If you want to use LittleFS with the ESP8266, read: Install ESP8266 NodeMCU LittleFS Filesystem Uploader in Arduino IDE.

Table of Contents

Introducing LittleFS

LittleFS is a lightweight filesystem created for microcontrollers that lets you access the flash memory like you would do in a standard file system on your computer, but it’s simpler and more limited. You can read, write, close, and delete files. Using a filesystem with the ESP32 boards is especially useful to:

Installing the Arduino ESP32 filesystem uploader

Currently, there is a plugin for the Arduino IDE (version 1.8.X) that allows you to pack and upload files to the SPIFFS, LittleFS, or FatFS filesystem image in the ESP32 filesystem.

Note: in most of our projects we use SPIFFS for the ESP32 filesystem. It’s still compatible with the ESP32, and you can use SPIFFS without any issues. However, currently, many libraries are moving to LittleFS.

The plugin we’ll install is both compatible with SPIFFS and LittleFS. So, it’s an advantage over the older plugin and you can still use SPIFFS.

There are a few advantages of using LittleFS over SPIFFS:

  • LittleFS is optimized for low resource usage and it employs a wear-leveling algorithm that evenly distributes writes across the flash memory, prolonging its lifespan.
  • LittleFS provides faster mount times and file access by utilizing a directory indexing structure.
  • LittleFS minimizes the risk of data corruption during power loss or system failures.
  • LittleFS is under active development.

Windows Instructions

Follow the next steps to install the filesystem uploader if you’re using Windows:

1) Go to the releases page and click the latest esp32fs.zip file to download.

Arduino ESP32 Download Filesystem Uploader Plugin

2) Unzip the downloaded file. You should have a folder called esp32fs with a file called esp32fs.jar inside.

esp32fs file downloaded

3) Find your Sketchbook location. In your Arduino IDE, go to File > Preferences and check your Sketchbook location. In my case, it’s in the following path: C:\Users\sarin\Documents\Arduino.

Arduino sketchbook location

4) Go to the sketchbook location, and create a tools folder if you don’t have it already (make sure that the Arduino IDE application is closed).

creating tools folder sketchbook folder LittleFS

5) Inside the tools folder, create another folder called ESP32FS if you haven’t already.

6) Inside the ESP32FS folder, create a folder called tool.

7) Copy the esp32fs.jar file to the tool folder (if you already have an esp32fs.jar file from a previous plugin, delete it and replace it with the new one). So, the directory structure will look like this:

<home_dir>/Arduino/tools/ESP32FS/tool/esp32fs.jar
esp32 filesystem tool arduino directory

8) Now, you can open Arduino IDE.

To check if the plugin was successfully installed, open your Arduino IDE and select your ESP32 board. In the Tools menu, check that you have the option “ESP32 Sketch Data Upload“. Click on that option. A window will pop up for you to choose the filesystem you want to use.

ESP32 Filesystem uploader Arduino IDE choose filesystem

As you can see, you have the option to choose from LittleFS, SPIFFS, or FatFS and you can even have the option to erase flash if needed.

Congratulations! You’ve successfully installed the Filesystem uploader plugin for the ESP32 on the Arduino IDE.

Mac OS X Instructions

Follow the next instructions if you’re using MacOS X.

1) Go to the releases page and click the latest esp32fs.zip file to download.

Arduino ESP32 Download Filesystem Uploader Plugin

2) Unpack the files. You should have a folder called esp32fs with a file called esp32fs.jar inside.

3) Create a folder called tools in /Documents/Arduino/ if you haven’t already.

4) Inside the tools folder create another one called ESP32FS.

5) Inside the ESP32FS folder, create a folder called tool. So, the directory structure will look like this:

<home_dir>/Arduino/tools/ESP32FS/tool/

6) Copy the unpacked esp32fs.jar file to the tool directory (if you already have an esp32fs.jar file from a previous plugin, delete it and replace it with the new one). You should have a similar folder structure.

esp32 filesystem tool arduino directory

7) Now, you can open Arduino IDE.

To check if the plugin was successfully installed, open your Arduino IDE and select your ESP32 board. In the Tools menu, check that you have the option “ESP32 Sketch Data Upload“.

ESP32 Data Sketch Upload MACOS X

Click on that option. A window will pop up for you to choose the filesystem you want to use.

ESP32 Filesystem uploader Arduino IDE choose filesystem MAC OS

As you can see, you have the option to choose from LittleFS, SPIFFS, or FatFS and you can even have the option to erase flash if needed.

Congratulations! You’ve successfully installed the Filesystem uploader plugin for the ESP32 on the Arduino IDE.

Uploading Files using the Filesystem Uploader

To upload files to the ESP32 LittleFS filesystem follow the next instructions.

1) Create an Arduino sketch and save it. For demonstration purposes, you can save an empty sketch.

2) Then, open the sketch folder. You can go to Sketch > Show Sketch Folder. The folder where your sketch is saved should open.

Arduino IDE Show Sketch folder to create data folder

3) Inside that folder, create a new folder called data.

ESP32 Arduino Sketch Example File Filesystem fs LittleFS

4) Inside the data folder is where you should put the files you want to save into the ESP32 filesystem. As an example, create a .txt file with some text called test_example.

ESP32 Notepad Test Example File Filesystem fs LittleFS

5) Then, to upload the files, in the Arduino IDE, you just need to go to Tools > ESP32 Sketch Data Upload.

ESP32 Sketch Data Upload Arduino IDE FS Filesystem

6. Select the LittleFS option and click OK.

Filesystem Plugin ESP32 - Choose filesystem

Make sure the Serial Monitor is closed before uploading the files, otherwise, you’ll get an error related to the Serial communication, and the files won’t upload.

The uploader will overwrite anything you had already saved in the filesystem.

Note: in some ESP32 development boards you need to press the on-board BOOT button for around two seconds to upload the files.

The files were successfully uploaded to the ESP32 filesystem when you see the message “LittleFS Image Uploaded“.

Filesystem image Uploaded successfully arduino ide ESP32

Testing the Filesystem Uploader Plugin

Now, let’s just check if the file was actually saved into the ESP32 filesystem. Simply upload the following code to your ESP32 board.

/*********
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp32-littlefs-arduino-ide/
*********/

#include "LittleFS.h"
 
void setup() {
  Serial.begin(115200);
  
  if(!LittleFS.begin()){
    Serial.println("An Error has occurred while mounting SPIFFS");
    return;
  }
  
  File file = LittleFS.open("/test_example.txt");
  if(!file){
    Serial.println("Failed to open file for reading");
    return;
  }
  
  Serial.println("File Content:");
  while(file.available()){
    Serial.write(file.read());
  }
  file.close();
}
 
void loop() {

}

View raw code

After uploading, open the Serial Monitor at a baud rate of 115200. Press the ESP32 “ENABLE/RST” button. It should print the content of your .txt file on the Serial Monitor.

ESP32 LittleFS Filesystem Example Arduino IDE Serial Monitor

You’ve successfully uploaded files to the ESP32 filesystem using the plugin.

Wrapping Up

In this tutorial, you installed a plugin for the Arduino IDE that allows you to upload files to the ESP32 filesystem. This plugin supports three different filesystems: SPIFFS, LittleFS, and FatFS.

While many libraries and projects are moving to LittleFS, SPIFSS is still used and your previous projects that use SPIFFS should still be working.

Because this new plugin supports both SPIFFS and LittleFS, you should consider installing this one instead of the SPIFFS plugin so that you have more flexibility with the choice of filesystem.

We hope you’ve found this tutorial useful.

Learn more about the ESP32 using our resources:



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

22 thoughts on “ESP32: Upload Files to LittleFS using Arduino IDE”

    • Hi.
      What ESP32 board model are you using?
      Check the version of the ESP32 core you have installed. Go to Tools > Board > Boards Manager, search for ESP32 and check the version you have installed. You may need to upgrade.
      Regards,
      Sara

      Reply
  1. Hi Rui
    I tried your HOWTO to set up the littlefs-Fileuploader in Arduino IDE 1.X. I can follow it easily (thank you very much!), but as soon as I click on LITTLEFS in the step 6 for Mac, I get an error:

    Arduino: 1.8.16 (Mac OS X), Board: “LOLIN D32, Default, 80MHz, 921600, None, Disabled”

    Chip : esp32
    Using partition scheme from Arduino IDE.
    Start: 0x290000
    Size : 0x160000
    mklittlefs : /Users/toddd/Library/Arduino15/packages/esp32/tools/mklittlefs/3.0.0-gnu12-dc7f933/mklittlefs

    Error: esptool not found!

    Can you please point out to me where I would have to get this esptool? I used to be able to upload to SPIFFS, but now, no upload at all seems to be working.

    Tank you very much, Dani

    Reply
    • Hi.
      What’s the version of the ESP32 board you have installed? Tools > Board > Boards Manager, Search for ESP32 and check the version. Update to the newest version and see if it fixes the issue.
      Regards,
      Sara

      Reply
  2. Hi,
    Thanks for the tutorial!
    For some reason I’m not getting “Filesystem” selection popup when I click “ESP32 Sketch Data Upload”, it just uploads right away (and I think SPIFFS is used by default).
    Tried latest (1.1) and previous version of the plugin.
    board – eps32
    arduino – 1.8.19

    Reply
  3. Hi,
    I have read this manual. Thanks for it. Is it possible that it will not work with the latest OSX from Apple (Ventura). When I loop trough your instructions no fs is visual iin my ide. I use the ESP32 touchdown (Dutch vendor) with and esp32 dev on board.

    Cheers,
    Jan (NL)

    Reply
  4. Hi and thanks for this solution.
    I installed the .jar file, i have the option into the Tools> menu but, when I select to upload the files, i have no “Select the LittleFS” option!
    ArduinoIDE 1.8.x and everything else is OK…

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.