Skip to content

Writing files with SPIFFS no longer working for ESP-01 #4061

Closed
@funtastic99

Description

@funtastic99

Basic Infos

SPIFFS no longer works on a ESP-01.

Hardware

Hardware: ESP-01
Core Version: 2.3.0-rc2
also tried with stable

I reproduced this problem on several different ESP-01. So seems not to be hardware related

Description

Problem description
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.

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

#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()
{
}

Debug Messages

messages here

  • 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?
thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions