SPIFFS files return empty
Posted: Thu Mar 03, 2022 4:15 pm
Hi all
Returning to an older project - I suddenly got the stangest behavior: Files on SPIFFS filesystem reads empty - as in no output from files.
I guess that all libraries has been updated since i last worked on the project, so some error has been introduced. A simple sketch for testing:
This sketch returns the list of files .. but reading a file returns nothing:
SPIFFS filesystem is created like this:
Any thoughs on this one?
Best regards, Stickybit
Returning to an older project - I suddenly got the stangest behavior: Files on SPIFFS filesystem reads empty - as in no output from files.
I guess that all libraries has been updated since i last worked on the project, so some error has been introduced. A simple sketch for testing:
Code: Select all
#include <FS.h>
void setup() {
Serial.begin(9600);
if (!SPIFFS.begin()) {
Serial.println("SPIFFS failed to mount !\r\n");
}
}
void loop() {
Dir dir = SPIFFS.openDir("/");
while (dir.next()) {
Serial.print(dir.fileName());
Serial.print(" - ");
Serial.println(dir.fileSize());
}
delay(1000);
File f = SPIFFS.open("/index.html", "r");
if (!f) {
Serial.println("file open failed");
}
for (int i = 1; i <= 10; i++) {
String s = f.readStringUntil('\n');
Serial.print(i);
Serial.print(":");
Serial.println(s);
}
delay(3000);
}
This sketch returns the list of files .. but reading a file returns nothing:
Code: Select all
/configuration.js - 810
/index.html - 4010
/jquery-3.3.1.min.js - 86927
/jquery-confirm.min.css - 22581
/jquery-confirm.min.js - 27734
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
SPIFFS filesystem is created like this:
Code: Select all
"%LOCALAPPDATA%\Arduino15\packages\esp8266\tools\mkspiffs\3.0.4-gcc10.3-1757bed\mkspiffs.exe" --create website --block 8192 --page 256 --debug 5 --size 1048576 SPIFFS.bin
Any thoughs on this one?
Best regards, Stickybit