Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By popsodav
#27468 Hi,

I'm trying to work with SPIFFS in ESP8266 Arduino.
I'm using ESP-01 generic moduke with 512K SPI flash.
In the eagle file I found, that start address for SPIFFS is 0x4026B000.
This value I also got by modifying FS library (added function to get start address which is used by SPIFFS library).

I'm trying to burn prebuilt with mkspiffs FS image into my ESP by this command:
Code: Select allesptool -cp COM3 -ca  0x4026B000 -cf file.bin


Command complets successfully.

I created a small sketch to test SPIFFS:
Code: Select all#include <FS.h>

void setup() {
 Serial.begin(115200);
 
  delay(100);
 
  if (!SPIFFS.begin())
  {
    Serial.println("Failed to mount file system");
    return;
  }

}

void loop() {
  Dir dir = SPIFFS.openDir("/");
  while (dir.next()) {
      Serial.print(dir.fileName());
      Serial.print("\t");
      File f = dir.openFile("r");
      Serial.println(f.size());
  }
  uint32_t addr = SPIFFS.getStartAddress();
  Serial.print("0x");
  Serial.println(addr, HEX);
  delay(10000);
}


It prints:
Code: Select all   35586048
   117112832
0x4026B000


Filename is empty and a strange filesize...

Real structure of FS image:
Code: Select allmkspiffs.exe -l file.bin
543     /index.html
1787    /loading.gif


Could you please clarify, where I'm wrong? Thank you!
User avatar
By martinayotte
#27502 First, the SPIFFS address when doing the upload is 0x6B000, not 0x4026B000, it is relative to Flash start.

which version of ArduinoESP are you using ?
Because there were a lot of bug fixes recently.

Second, the SPIFS root path is "/data". Also, you don't need to open file any more to get its size (for which you also forgot to do a f.close()), since the dir.fileSize() method has been added few weeks ago. Here is the snippet of code I'm using :

Code: Select all        if (!SPIFFS.begin()) {
          Serial.println("SPIFFS failed to mount !\r\n");
        }
        else {
        Dir dir = SPIFFS.openDir("/data");
          while (dir.next()) {
            Serial.print(dir.fileName());
            Serial.print(" - ");
            Serial.println(dir.fileSize());
          }


Also, beware that there still a bug that filesystem built from mkspiffs seems to be in ReadOnly, so you won't be able to write new files until this bug been corrected.
User avatar
By martinayotte
#27620 Yes, you can, the EEPROM emulation is in another section of the Flash placed after the end of SPIFFS.
And the the ReadOnly issue of existing SPIFFS partition, it is a bug, so expect it to be fixed soon.