After running the sketch I downloaded the flash memory and it compared OK so nothing is being corrupted...
$ esptool.py --port=/dev/ttyUSB0 read_flash 0x200000 0x10000 foo
$ cmp html.img foo
$
If I try the same with LittleFS then I get no files reported!
I also tried upgrading to the 3.0.0 libraries (and thus also the later version of mkspiffs that came with the library)
Clearly I'm doing something stupid and wrong!
Hopefully the following (showing how I build it, upload it) will help point out my mistake!
Thanks for any assistance...
================================================================
Creating Image file
This is done using the mkspiffs that comes with the package so it should(!) match the library used by the ESP8266
$ ~/.arduino15/packages/esp8266/tools/mkspiffs/2.5.0-4-b40a506/mkspiffs -c html html.img
/menu_frame.html
/change_ap.html
/top_frame.html
/index.html
/main_frame.html
Compiling with 4M2M memory layout
$ arduino-cli compile --fqbn=esp8266:esp8266:nodemcuv2:eesz=4M2M
Executable segment sizes:
IROM : 265840 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 26888 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1248 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 800 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 25120 ) - zeroed variables (global, static) in RAM/HEAP
Sketch uses 294776 bytes (28%) of program storage space. Maximum is 1044464 bytes.
Global variables use 27168 bytes (33%) of dynamic memory, leaving 54752 bytes for local variables. Maximum is 81920 bytes.
Uploading, writing the bin at 0x0 and the filesystem at 0x200000
$ python ~/.arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/esptool/esptool.py --port=/dev/ttyUSB0 write_flash 0x0 SPIFFS.esp8266.esp8266.nodemcuv2.bin 0x200000 html.img
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: b4:e6:2d:67:b1:45
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 298928 bytes to 219676...
Writing at 0x00034000... (100 %)
Wrote 298928 bytes (219676 compressed) at 0x00000000 in 19.5 seconds (effective 122.7 kbit/s)...
Hash of data verified.
Compressed 65536 bytes to 1353...
Writing at 0x00200000... (100 %)
Wrote 65536 bytes (1353 compressed) at 0x00200000 in 0.1 seconds (effective 4232.8 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
Results
... It shows 2M for the filesystem.
... But only one file is listed?
Starting...
Total size of FS is: 1953282
Used size of FS is: 2259
File list:
/menu_frame.html
Finished
And, finally, the sketch
#include <FS.h>
void setup()
{
Serial.begin(115200);
delay(500);
Serial.println("Starting...");
SPIFFS.begin();
FSInfo fs_info;
SPIFFS.info(fs_info);
Serial.print("Total size of FS is: ");
Serial.println(fs_info.totalBytes);
Serial.print("Used size of FS is: ");
Serial.println(fs_info.usedBytes);
Serial.println("File list: ");
Dir dir = SPIFFS.openDir("/");
while (dir.next())
{
Serial.println(dir.fileName());
}
Serial.println("Finished");
}
void loop() { }
Stephen