Unable to Open Uploaded file - LitteFS + ESP8266FS
Posted: Sat Aug 29, 2020 10:23 am
Hi,
I am having issues reading a file back that I have uploaded using ESP8266FS.
Uploading the file, everything seems OK... (note: I am uploading a file called 'index.html')
However, when I use the following sketch to see if the file opens...
Console:
The serial monitor returns:
The following are my settings:
https://ibb.co/dLcWrzX
Any thoughts/suggestion would be gratefully received... I guess I have a configuration wrong somewhere.
Regards,
Harold
I am having issues reading a file back that I have uploaded using ESP8266FS.
Uploading the file, everything seems OK... (note: I am uploading a file called 'index.html')
Code: Select all
[SPIFFS] data : C:\Users\harol\OneDrive\Documents\Arduino\upload\data
[SPIFFS] size : 2024
[SPIFFS] page : 256
[SPIFFS] block : 8192
/index.html
[SPIFFS] upload : C:\Users\harol\AppData\Local\Temp\arduino_build_598521/upload.spiffs.bin
[SPIFFS] address : 0x200000
[SPIFFS] reset : --before default_reset --after hard_reset
[SPIFFS] port : COM4
[SPIFFS] speed : 115200
[SPIFFS] python : C:\Users\harol\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1\python3.exe
[SPIFFS] uploader : C:\Users\harol\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\tools\upload.py
esptool.py v2.8
Serial port COM4
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:24:7b:23
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 2072576 bytes to 2730...
Wrote 2072576 bytes (2730 compressed) at 0x00200000 in 0.2 seconds (effective 67815.2 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
However, when I use the following sketch to see if the file opens...
Code: Select all
#include "LittleFS.h"
void setup() {
Serial.begin(115200);
Serial.println(":mount_fs");
Serial.print(F("mounting file system..."));
if (LittleFS.begin()){
Serial.print(F("done.\n"));
} else{
Serial.print(F("failed.\n"));
}
File file = LittleFS.open("./index.html", "r");
if(!file){
Serial.println("Failed to open file for reading");
return;
}
Serial.println();
Serial.println("File Content:");
while(file.available()){
Serial.write(file.read());
}
file.close();
}
void loop() {
// put your main code here, to run repeatedly:
}
Console:
Code: Select all
Executable segment sizes:
IROM : 260668 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 26968 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1248 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 1420 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 25112 ) - zeroed variables (global, static) in RAM/HEAP
Sketch uses 290304 bytes (27%) of program storage space. Maximum is 1044464 bytes.
Global variables use 27780 bytes (33%) of dynamic memory, leaving 54140 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM4
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 5c:cf:7f:24:7b:23
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 294464 bytes to 216369...
Wrote 294464 bytes (216369 compressed) at 0x00000000 in 19.1 seconds (effective 123.1 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
The serial monitor returns:
Code: Select all
mounting file system...done.
Failed to open file for reading
The following are my settings:
https://ibb.co/dLcWrzX
Any thoughts/suggestion would be gratefully received... I guess I have a configuration wrong somewhere.
Regards,
Harold