Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By funtastic
#72862 SPIFFS worked for a long time but all of a sudden it stoped working on a ESP-01.
Whenever i write a file its not existing or empty after next boot.
Using the same sketch on an Wemos D1 mini its works without problems. Actually im only facing this problem on a ESP-01.
I reproduced this problem on several different ESP-01. So seems not to be hardware related

Hardware: ESP-01
Core Version: 2.4.0

Settings in IDE
Module: Generic ESP8266 Module
Flash Size: 1MB (64k SPIFFS), also tried with 512k (64k SPIFFS)
CPU Frequency: 80Mhz
Flash Mode: DIO
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: ck


Sketch to reproduce

#include <FS.h>

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

if (!SPIFFS.begin()) Serial.println("error while mounting filesystem!");

readFile();
writeFile();
readFile();

Serial.println("done");
}

void readFile()
{
Serial.println("reading");
File f = SPIFFS.open("/myFile.txt", "r");
if (!f) Serial.println("file not available");
else if (f.available()<=0) Serial.println("file exists but available <0");
else
{
String ssidString = f.readStringUntil('#');
Serial.print("read from file: ");
Serial.println(ssidString);
}
f.close();
}

void writeFile()
{
Serial.println("writing");
File f = SPIFFS.open("/myFile.txt", "w");
if (!f) Serial.println("File creation failed");
else
{
f.print("networkConfig");
f.print("#");
f.flush();
f.close();
}
}

void loop()
{
}

Output of first run:
reading
file not available
writing
reading
read from file: <--- here we see the problem already
done

Output of second run:
eading
file not available
writing
reading
read from file:
done

Output of third run:
reading
read from file:
writing
File creation failed <---- check this!
reading
read from file:
done

Any ideas? Help is realy appreciated
thank you!

Hermann