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.