-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Why does SPIFFS file.write take several attempts before succeding? #4334
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
Turn on verbose debugging, by default logging is none. |
For the debug output above I had |
Originally I had trimmed the debug output to just that of my affected function. I have updated it to be the full output after boot. |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
I see the same issue on a ESP32 Wrover, often 3 trials before the file is stored successfully. Verbose debug info don't show additional information. Taking a photo... |
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. |
Same issue here, also using ESP32-CAM and Rui Santos's "RandomNerdTutorials.com/esp32-cam-take-photo-display-web-server". I "solved" the issue by switching to LittleFS. According to the official docs, SPIFFS is deprecated, so this "solution" might actually be quite reasonable. Replace Then replace all occurences of So far, every call to |
I will try LITTLEFS but in the mean time i have some observations. Using SPIFFS i can write data to a file like below. This works all the time. When i try to write the same data to the same file directly from PSRAM to the file it only works sporadically like below. It seems PSRAM and SPIFFS are not working well together. Anyone seen this also and solved it ? |
Please test with release 1.0.5, which includes #4850 |
Tried with 1.05 and still gets only sporadic success. |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
Hardware:
Board: ESP32-CAM
Core Installation version: I am using 1.0.4 of the ESP32 board config in Arduino, not sure if that is the correct value here
IDE name: Arduino IDE
Flash Frequency: 80Mhz
PSRAM enabled: yes
Upload Speed: 921600
Computer OS: Arch Linux
Description:
I am capturing a frame with an OV2640 camera and saving to SPIFFS. I have found that
file.write()
takes several attempts before it successfully writes any bytes to SPIFFS. I've enabled verbose debugging but don't seem to be getting any extra debug info during the SPIFFS write (I see lots of other debug logging during setup though, so I know verbose debug is on). I've also tried adding a 10 second delay between capturing the image and writing to SPIFFS in case there was some timing issue grabbing the large image over DMA, but I still get 5-10 failed writes before a successful one.Looking at
vfs_api.cpp
(which I think SPIFFS inherits from), it seems likewrite()
would return 0 if the file is a directory, if the file ...doesn't exist? fails to open?, if the input data is empty (confirmed this not the case as it eventually does write), if the length of input data is 0 (confirmed this is non-zero before the first write attempt. It would also return 0 iffwrite()
returns zero, but I'm not sure what would cause that. The lack of debug messages seems to indicate it doesn't think it is a directory or that the file is bad, so I'm at a loss for what to investigate next.Sketch: (leave the backquotes for code formatting)
Below is my full application for context, but the SPIFFS write happens in
capturePhotoSaveSpiffs()
.Debug Messages:
The text was updated successfully, but these errors were encountered: