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 | Random Nerd Tutorials (1) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (1)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/Install-Filesystem-Plugin-ESP32.jpg?resize=828%2C466&quality=100&strip=all&ssl=1)
Using Arduino IDE 2? Follow this tutorial instead: Arduino IDE 2: Install ESP32 LittleFS Uploader (Upload Files to the Filesystem)
If you want to use LittleFS with the ESP8266, read: Install ESP8266 NodeMCU LittleFS Filesystem Uploader in Arduino IDE.
Table of Contents
- Introducing LittleFS
- Installing the Arduino ESP32 filesystem uploader
- Windows Instructions
- Mac OS X Instructions
- Uploading Files to ESP32 LittleFS using the Filesystem Uploader
- Testing the ESP32 Filesystem Uploader
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:
- Create configuration files with settings;
- Save data permanently;
- Create files to save small amounts of data instead of using a microSD card;
- Save HTML, CSS, and JavaScript files to build a web server;
- Save images, figures, and icons;
- And much more.
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.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (2) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (2)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/Arduino-ESP32-Uploader-Plugin-Download.png?resize=693%2C250&quality=100&strip=all&ssl=1)
2) Unzip the downloaded file. You should have a folder called esp32fs with a file called esp32fs.jar inside.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (3) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (3)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/esp32fs-folder-file.png?resize=735%2C250&quality=100&strip=all&ssl=1)
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.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (4) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (4)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2018/10/Arduino-Sketchbook-location.png?resize=802%2C479&quality=100&strip=all&ssl=1)
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).
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (5) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (5)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2018/10/creating-tools-folder-sketchbook-location.png?resize=675%2C229&quality=100&strip=all&ssl=1)
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: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (6) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (6)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/uploader-plugin-esp32-file-directory.png?resize=772%2C278&quality=100&strip=all&ssl=1)
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: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (7) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (7)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/Filesystem-uploader-plugin-esp32-littlefs.png?resize=271%2C149&quality=100&strip=all&ssl=1)
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.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (8) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (8)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/Arduino-ESP32-Uploader-Plugin-Download.png?resize=693%2C250&quality=100&strip=all&ssl=1)
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: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (9) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (9)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/ESP32-Filesystem-tool-directory-macos.png?resize=750%2C223&quality=100&strip=all&ssl=1)
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: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (10) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (10)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/ESP32-sketch-data-upload-arduino-ide-macos.png?resize=750%2C329&quality=100&strip=all&ssl=1)
Click on that option. A window will pop up for you to choose the filesystem you want to use.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (11) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (11)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/Filesystem-uploader-plugin-esp32-littlefs-macos.png?resize=300%2C152&quality=100&strip=all&ssl=1)
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.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (12) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (12)](https://i0.wp.com/i0.wp.com/rntlab.com/wp-content/uploads/2018/09/show-sketch-folder.png?w=828&quality=100&strip=all&ssl=1)
3) Inside that folder, create a new folder called data.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (13) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (13)](https://i0.wp.com/i0.wp.com/rntlab.com/wp-content/uploads/2018/09/data.fodler.png?w=828&quality=100&strip=all&ssl=1)
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: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (14) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (14)](https://i0.wp.com/i0.wp.com/rntlab.com/wp-content/uploads/2018/09/text_txt.png?w=828&quality=100&strip=all&ssl=1)
5) Then, to upload the files, in the Arduino IDE, you just need to go to Tools> ESP32 Sketch Data Upload.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (15) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (15)](https://i0.wp.com/i0.wp.com/rntlab.com/wp-content/uploads/2018/09/sketch-data-upload.png?w=828&quality=100&strip=all&ssl=1)
6. Select the LittleFS option and click OK.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (16) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (16)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/Filesystem-uploader-plugin-esp32-littlefs.png?resize=271%2C149&quality=100&strip=all&ssl=1)
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“.
![ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (17) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (17)](https://i0.wp.com/i0.wp.com/randomnerdtutorials.com/wp-content/uploads/2023/06/LittleFS-image-uploaded-successfully.png?resize=655%2C162&quality=100&strip=all&ssl=1)
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() {}
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: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (18) ESP32: Upload Files to LittleFS using Arduino IDE | Random Nerd Tutorials (18)](https://i0.wp.com/i0.wp.com/rntlab.com/wp-content/uploads/2018/09/testing-file-system-serial-monitor.png?w=828&quality=100&strip=all&ssl=1)
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 ESP32 with Arduino IDE (eBook)
- Build Web Servers with ESP32 and ESP8266 (eBook)
- Firebase Web App with ESP32 and ESP8266 (eBook)
- Free ESP32 Projects and Tutorials…