Help Needed: SPIFFS not showing expected file contents in Serial Monitor (ESP32)

Hi all,

I'm working with an ESP32 and trying to manually upload a SPIFFS filesystem using mkspiffs.exe and esptool.exe. The process seems to complete without errors, but when I try to read the file in my sketch, I don’t get the expected output.


Folder structure:

kotlin

CopyEdit

C:\esp32-spiffs\
├── mkspiffs.exe
├── spiffs.bin
├── GOTID_SPIFFS_Test\
│   ├── data\
│   │   └── example.txt

Contents of example.txt:

kotlin

CopyEdit

This is a test file inside SPIFFS.
If you can see this, your SPIFFS works!

Command to create spiffs.bin:

css

CopyEdit

mkspiffs.exe -c GOTID_SPIFFS_Test\data -b 4096 -p 256 -s 0x110000 spiffs.bin

Command to flash it:

css

CopyEdit

esptool.exe --chip esp32 --port COM5 --baud 921600 write_flash 0x110000 ..\..\spiffs.bin

Both commands complete successfully. spiffs.bin is created and flashes to the ESP32 without error. I verified the COM port and board settings (ESP32 Dev Module on COM5). Uploads via Arduino IDE also work fine.


Test sketch:

cpp

CopyEdit

#include "FS.h"
#include "SPIFFS.h"

void setup() {
  Serial.begin(115200);
  delay(1000);

  if (!SPIFFS.begin(true)) {
    Serial.println("SPIFFS Mount Failed");
    return;
  }

  File file = SPIFFS.open("/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() {}

Problem:

When I open the Serial Monitor, instead of seeing the content of example.txt, I either get:

yaml

CopyEdit

File Content:
ets Jul 29 2019 12:21:46

or just nothing at all. Sometimes only the “File Content:” line appears with no actual text after it.


What I’ve confirmed:

  • The file is saved as plain text
  • I’ve regenerated and reflashed spiffs.bin multiple times
  • Flashing shows success (hash verified, hard resetting via RTS)
  • The same sketch has worked for other SPIFFS setups when using Arduino’s built-in SPIFFS upload tool

What am I missing here? Is something going wrong during the SPIFFS image creation or flashing, even though no errors are reported?

Appreciate any help from the community. Thanks.

All those kotlin and talk scattered in your text seems to indicate a copy and paste from ChatGPT or similar AI… are you working with AI?

Any reason why you don’t use the data upload tool that you can install in the IDE?

1 Like

Are you aware that SPIFFS is deprecated? I think LittleFS is the 'new' SPIFFS.

Thanks for the info. I’ve decided to go back to Arduino IDE 1.8.x since it fully supports the ESP32 SPIFFS Upload Tool. I now understand that the newer 2.x IDE doesn’t support the plugin, which explains a lot of the issues I ran into. I’ll continue working with 1.8.x for now as it’s more stable for SPIFFS uploads.

Appreciate the guidance.

Hi @me109bf.

It is true that Arduino IDE 2.x does not support the plugins that were created for the Arduino IDE 1.x "Tools" framework. However, there is a high quality and very well maintained replacement extension for Arduino IDE 2.x you can use to upload littlefs filesystems to the ESP32 board: