-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fail to open file for write on SPIFFS #4311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@brianjmurrell, I think you will find that you have a PUYA branded flash chip on your esp module. Don't worry, you're not going crazy :) There is a problem with SPIFFS and these chips that has not been resolved yet. I have sourced some replacement flash chips and am swapping them out until the issue is fixed. I tested your sketches on a 'fixed' module and it behaves as expected, but with a module that still has the PUYA chip I get the same results that you're getting. |
How do I determine if I have said PUYA branded flash chip? My problem doesn't seem to be as bad as the issues you linked. I was able to write the 2206039 byes of files that are on there with SPIFFS. It just seems to have stopped accepting writes at 2206039 bytes out of 2949250 instead of writing up to the max of 2949250 bytes. |
With a magnifying glass, or you can run this sketch: #include "FS.h" void setup() { SPIFFS.begin(); float fileTotalKB = (float)fs_info.totalBytes / 1024.0; float flashChipSize = (float)ESP.getFlashChipSize() / 1024.0 / 1024.0; Serial.println("=========================================================="); Serial.println("Flash chip information: "); Serial.println("File system (SPIFFS): "); Dir dir = SPIFFS.openDir("/"); File f = SPIFFS.open("/formatComplete.txt", "w"); if (!SPIFFS.exists("/formatComplete.txt")) { f = SPIFFS.open("/formatComplete.txt", "r");
} dir = SPIFFS.openDir("/"); while (dir.next()) { void loop() { // open file for reading Serial.println("====== Reading from SPIFFS file ======="); } |
Yeah, found that sketch elsewhere.
As for the magnifying glass, I tried that but didn't see anything with PUYA on it. |
My board is a NodeMCU with a "shield" over that part I would guess. I'm not going to remove it. :-) So looks like I don't have a PUYA given that mine is Manuf E0 and yours is 85. |
Ah, yes can't say I can blame you for not wanting to remove the shield. Here's the relevant debug line from my PUYA chipped module: Are you getting the read fails like this: On a healthy module, the 1:, 2: etc should be followed by the same numbers as the corresponding lines in the write section. |
Oh, yes, of course. s/E0/20/ for mine.
Generally no. reads and writes generally work -- until I hit 2206039 bytes out of the max. of 2949250 that SPIFFS.info() is giving me. I'm not convinced that my problem is the same as yours. |
Ok, if you're reading fine in the lower addresses then no , not the same, sorry didn't catch that. It's almost as if the flash chip is smaller than reported. Have you tried with 2.3 core? Going the other way have you tried the latest git or just the 2.4 release? |
As in https://github.com/esp8266/Arduino/releases/download/2.3.0/esp8266-2.3.0.zip? If yes, then no, I have not.
No, just using the latest GA release, 2.4.0. |
You can simply downgrade/upgrade between the 2.3 and 2.4 release in boards manager. |
I've never thought to try, no need or point as far as I'm aware. I only ever simply use Spiffs.begin. No idea if that could be your problem but certainly worth trying. |
Good luck.. I'm off to bed :) |
To be clear, I (the OP) don't use
Per above, I am not using |
It looks a bit like it. What I know of SPIFFS:
Due to these design choices, the file system may become fragmented and thus not all storage capacity can be used. I think if you also add a call to the gc() function with the parameter and call it |
It might not be obvious to everyone that the Tools->Flash Size arduino menu could get reset to FS:none. It might not be the same symptom since I think SPIFFS.begin() returns null when there is no fs space. |
SPIFFS is no longer maintained by the author. There are some weird corner cases when the filesystem is under heavy use involving GC/etc. We have added the |
Basic Infos
Same as in #4291
Sketch
Debug Messages
Why did it fail to open so many times? Then it did finally open but the write added nothing new.
There is still lots of space available on the SPIFFS.
The text was updated successfully, but these errors were encountered: