Hi!
I’m having issues using LittleFS
and SPIFFS
with my Adafruit Feather ESP32-S3 TFT. I have code that is working fine on the Arduino IDE, but LittleFS
and SPIFFS
cannot be successfully be started with pio
running on VS Code, whether it’s ran on Ubuntu 24.04 or windows 11.
This is my main.cpp code:
#include "LittleFS.h"
String fileContent = ""; // Global string to store file content
int led = LED_BUILTIN;
void setup()
{
pinMode(led, OUTPUT);
Serial.begin(115200);
delay(10000); // wait for 10 seconds
//This always returns false
if (!LittleFS.begin())
{
Serial.println("An Error has occurred while mounting LittleFS");
return;
}
File file = LittleFS.open("/text.txt", "r");
if (!file)
{
Serial.println("Failed to open file for reading");
return;
}
Serial.println("Reading file content...");
while (file.available())
fileContent += (char)file.read();
file.close();
}
void loop()
{
if (!fileContent.isEmpty())
Serial.println("file contains: " + fileContent);
else
Serial.println("could not read file");
//blink the led
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
This is my platformio.ini
file:
[env:adafruit_feather_esp32s3_tft]
platform = espressif32
board = adafruit_feather_esp32s3_tft
framework = arduino
board_build.partitions = partitions.csv
At the root of my project I have this partitions.csv
file (a copy of the default 4MB with spiffs
partition scheme from the Arduino IDE):
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
app1, app, ota_1, 0x150000,0x140000,
spiffs, data, spiffs, 0x290000,0x160000,
coredump, data, coredump,0x3F0000,0x10000,
And my text file in data/test.txt
.
I can successfully build and upload my Filesystem Image using the platformio menu, then upload the firmware just fine, but calls to LittleFS.begin()
(or SPIFFS.begin()
, if I use that instead) always fail. Here’s what the serial monitor looks like:
---- Opened the serial port COM5 ----
An Error has occurred while mounting LittleFS
could not read file