-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Board
ESP32 Dev Module 4MB
Device Description
The ESP32 board info:
Board: "ESP32 Dev Module"
Upload Speed: "921600"
CPU Frequency: "240MHz (WiFi/BT"
Flash Frequency: "80MHz"
Flash Mode: "QIO"
Flash Size: "4MB (32Mb)"
Partition Scheme: "No OTA (2MB APP 2MB SPIFFS)"
Core Debug Level: "None"
PSRAM: "Disabled"
Arduino Runs On: Core1
Events Run On: Core1
Port: "COM9"
Hardware Configuration
no external devices
Version
v2.0.2
IDE Name
Arduino IDE 1.8.19
Operating System
Win10 64bit
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
115200
Description
Hi,
I initially posted it on forum.arduino.cc but got no replies there. Maybe that was the wrong place to post it.
I have a project in mind where I have to write sensor data into file in ESP32 flash memory (yes, I am aware of 10000 writes limit). As I understood SPIFFS is deprecated and LittleFS would be the way to go.
I decided to do a little speed test first. I uploaded the Arduino IDE ESP32 LITTLEFS_test.ino sketch onto the regular ESP32 Dev Module and added a couple of lines of code into loop to measure the append time of text "qwerty" to the file data.txt on ESP32 file system. I uploaded the file via ESP32 Sketch Data Upload tool with LittleFS, that seems to format the flash for using LittleFS.
To my great surprise the append function run time was 20-30ms in the beginning and when the data.txt file grew to a few hundred bytes it became 50-70ms. And there is very odd behavior - every 15th time the append operation takes 250-350ms. That does not depend on the append function call period. Extra long append time occurs every 15th time would the call period be 1, 2 or 3 seconds.
When I run the same script modified to use SPIFFS the append function run time is steady 5ms.
I tested the sketch on 2 different boards with the same results. I also uninstalled ESP32 boards from Arduino IDE and reinstalled. No difference.
Thank you in advance to get the LittleFS working.
Sketch
#include "FS.h"
#include "LittleFS.h"
#define FORMAT_LITTLEFS_IF_FAILED true
unsigned long lastAppendMillis = 0; // append function call period, ms
unsigned long beginAppendMillis = 0; // append function start time, ms
unsigned long appendMillis = 0; // append function end time, ms
void setup(){
Serial.begin(115200);
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
Serial.println("LittleFS Mount Failed");
return;
}
Serial.println("File system info:");
Serial.print(" Total space: ");
Serial.print(LittleFS.totalBytes());
Serial.println("byte");
Serial.print(" Total space used: ");
Serial.print(LittleFS.usedBytes());
Serial.println("byte");
Serial.println();
listDir(LittleFS, "/", 3);
}
void loop(){
if (millis() - lastAppendMillis > 1000) {
lastAppendMillis = millis();
Serial.println("###########################");
Serial.println("Append qwerty");
beginAppendMillis = millis();
appendFile(LittleFS, "/data.txt", "qwerty\r\n");
appendMillis = millis() - beginAppendMillis;
Serial.print("appendMillis = ");
Serial.print(appendMillis);
Serial.println(" ms");
}
}
// LittleFS functions
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
Serial.printf("Listing directory: %s\r\n", dirname);
File root = fs.open(dirname);
if(!root){
Serial.println("- failed to open directory");
return;
}
if(!root.isDirectory()){
Serial.println(" - not a directory");
return;
}
File file = root.openNextFile();
while(file){
if(file.isDirectory()){
Serial.print(" DIR : ");
Serial.println(file.name());
if(levels){
listDir(fs, file.path(), levels -1);
}
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print("\tSIZE: ");
Serial.println(file.size());
}
file = root.openNextFile();
}
}
void appendFile(fs::FS &fs, const char * path, const char * message){
Serial.printf("Appending to file: %s\r\n", path);
File file = fs.open(path, FILE_APPEND);
if(!file){
Serial.println("- failed to open file for appending");
return;
}
if(file.print(message)){
Serial.println("- message appended");
} else {
Serial.println("- append failed");
}
file.close();
}
Debug Message
no special debug messages
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Activity
atanisoft commentedon Feb 24, 2022
@lorol Any ideas?
bxparks commentedon Mar 10, 2022
I can confirm that my application sees a 10X-15X slower performance of LittleFS on the ESP32 compared to the ESP8266.
I created a minimal reproducible example (see below) which shows roughly:
File::read()
performance on ESP32 compared to ESP8266File::seek()
performance on the ESP32 compared to ESP8266Minimal Reproducible Example
The output is:
ESP8266
ESP32
Environments
esp8266:esp8266:d1_mini:xtal=80,vt=flash,exception=disabled,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled, lvl=None____,wipe=none,baud=921600
esp32:esp32:esp32:PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none
VojtechBartoska commentedon Apr 11, 2022
Hello, are you able to retest this with Arduino core ESP32 version 2.0.3-rc1? Thanks!
VojtechBartoska commentedon May 4, 2022
Any updates?
guestisp commentedon May 6, 2022
I'm experiencing exactly the same, with arduino-esp32 2.0.2 and 2.0.3
As workound, downgrading to arduino-esp32 1.0.6 and adding https://github.com/lorol/LITTLEFS LittleFS library seems to have fixed the performance issue.
bxparks commentedon May 6, 2022
@VojtechBartoska: Who is the "you" that you are asking? In my case, for various reasons, I don't have the environment and hardware to re-run the example that I uploaded, at least not for a while. But I uploaded a complete reproducible example, so anyone else can.
VojtechBartoska commentedon May 9, 2022
Adding this to our Roadmap.
9 remaining items
Suresh6060 commentedon Aug 23, 2024
Does it mean using SPIFFS.h is better than LittleFS.h ?
lbernstone commentedon Aug 23, 2024
I just did some quick testing on 3.0.4. LittleFS writes do get a bit slower as the disk gets fragmented (goes from 96ms to 200ms for open/write 4096/close), but is comparable to SPIFFS on a clean FS. SPIFFS does not get slower as it gets more fragmented, but it never says that it is out of space, so when it gets to the limit it dramatically slows down (1500ms for a write), but it will continue behaving as though it is writing, even though the disk is clearly full.
Based on the other benefits of LittleFS over SPIFFS, I'd say this speed issue will generally be an acceptable tradeoff, so SPIFFS is not a recommended filesystem.
Suresh6060 commentedon Aug 24, 2024
Thank you.
hitecSmartHome commentedon Dec 6, 2024
Any update?
Parsaabasi commentedon Jan 10, 2025
Hello,
I close this since this report contains the release we no longer support. Please try the new versions and in case the issue persists, feel free to reopen it.
Thanks
hitecSmartHome commentedon Jan 10, 2025
Thanks. Will reopen it because it still exists on latest arduino
garudaonekh commentedon Apr 5, 2025
Seek is terribly slow on ESP32. Any new input on this? THanks
zekageri commentedon May 13, 2025
We are on
IDF 5.3.2.250210
and LittleFS is still slow A.Fx29a commentedon Jul 21, 2025
@hitecSmartHome i assume you didnt create a new issue because this one already exists, or? #7337
hitecSmartHome commentedon Jul 21, 2025
@x29a because @Parsaabasi said
x29a commentedon Jul 21, 2025
ok, then i misunderstood your next comment "Thanks. Will reopen it because it still exists on latest arduino".
so issue is solved for you?
hitecSmartHome commentedon Jul 21, 2025
No. LittleFS is still slow. I have to check the versions hovewer