Go Down

Topic: Problem using SPIFFS on ESP-01 (Read 828 times) previous topic - next topic

funtastic

SPIFFS worked for a long time but all of a sudden it stops working. Whenever i write a file its 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 use arduino IDE with this settings: Board: "Generic ESP8266 Module", Flash Mode DIO, Flash Frequency: 40MHZ, CPU Frequency: 80 MHZ, Flash Size: 1M (64K SPIFFS)

This example sketch show the problem:

#include <FS.h>

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

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

   readFile();
   writeFile();

   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 some startups:

- First start
  reading
  file not available
  writing
  done

- Second start
  reading
  read from file:
  writing
  done

- Third start
  reading
  file not available
  writing
  done

- Fourth start
  reading
  file exists but available <0
  writing
  File creation failed
  done


Any ideas? Thank you



funtastic

I found out some additional information that might be helpful.
The working ESP-01 report as flash_id:
Manufacturer: e0
Device: 4014

and the new ones that are not working:
Manufacturer: 85
Device: 6014

May the new flash chip is not supported by the arduino esp plugin yet ?

chucktodd

I found out some additional information that might be helpful.
The working ESP-01 report as flash_id:
Manufacturer: e0
Device: 4014

and the new ones that are not working:
Manufacturer: 85
Device: 6014

May the new flash chip is not supported by the arduino esp plugin yet ?
You might have to pop the top and ID the flash Chip.

Chuck.
Currently built mega http server, Now converting it to ESP32.

funtastic

Sorry,
can you explain in other words maybe? I  dont understand "You might have to pop the top and ID the flash Chip."

gdsports

SPIFFS may be corrupted and needs a reformat. SPIFFS functions are documented here.

Juraj

SPIFFS is on the same flash as everything else. it can't be "not supported by the plugin", because the plugin use esptool the same way the sketch is written to flash.

read the docs

funtastic

@Juraj
I understand your point but there seems to be a special strange behavior within SPIFFS that causes flash chip dependent problems. By the way.. Reading is working because i was able to read data from spiffs after uploading a flash image of a functional device.
Also updating the firmware with OTA works althought there the flash also has to be written.

@gdsports
Its not that easy. Of course i already tried to format and many other things. And as stated before a functionals spiffs dumped from a functional device can also not be written on a ESP-01 with the new flash chip

chucktodd

Sorry,
can you explain in other words maybe? I  dont understand "You might have to pop the top and ID the flash Chip."
unsolder the RF shield covering the ESP01 SPIFlash IC, Identify the manufacture/partnumber of the FlashIC. Use the FlashIc's datasheet to debug why SPIFFS is not correctly controlling that IC.

Chuck.
Currently built mega http server, Now converting it to ESP32.

Go Up