-
Notifications
You must be signed in to change notification settings - Fork 7k
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
ESP-IDF SPIFFS fails to save files even with alot more bytes left (IDFGH-6974) #8593
Comments
I state more clearly that a format of the mounted spiffs did NOT fix the problem, as I have seen other forums mention as a solution. The logs of that is attached in spiffs_format_errors.txt |
Thanks for the detailed issue description @Sjurinho! It seems that first it would be nice to solve the issue with failed erase operations. I'm not sure if SPIFFS will continue working correctly after some erase operations fail. If you run the Another question, could you please upload the |
Thanks for the quick reply @igrr. I have attached a zip with a simple application that reproduces the error. Error logsE (80860) SPIFFS: failed to erase addr 00006000, size 00001000, err 258
D (80870) example: Json stored! 10317
D (81070) example: Json stored! 10384
D (81270) example: Json stored! 10451
D (81470) example: Json stored! 10518
D (81670) example: Json stored! 10585
E (81890) SPIFFS: failed to erase addr 0000b000, size 00001000, err 258
D (81900) example: Json stored! 10652
D (82100) example: Json stored! 10719
D (82300) example: Json stored! 10786
D (82500) example: Json stored! 10853
D (82700) example: Json stored! 10920
D (82900) example: Json stored! 10987
E (83120) SPIFFS: failed to erase addr 0000f000, size 00001000, err 258
D (83130) example: Json stored! 11054
D (83330) example: Json stored! 11121
D (83530) example: Json stored! 11188
D (83730) example: Json stored! 11255
D (83930) example: Json stored! 11322
D (84140) example: Json stored! 11389
W (84350) SPIFFS: Failed to update mtime (-10002)
D (84360) example: Json stored! 11389
W (84570) SPIFFS: Failed to update mtime (-10002)
D (84580) example: Json stored! 11389
W (84790) SPIFFS: Failed to update mtime (-10002)
D (84800) example: Json stored! 11389
W (85010) SPIFFS: Failed to update mtime (-10002)
D (85020) example: Json stored! 11389
E (85220) example: Failed to open file 'Log1.txt' for appending
E (85220) example: Failed to delete file '/spiffs/Log1.txt': I/O error - 5
E (85220) example: Storage failure! Failed to delete file
|
I'm sorry, clicking the above spiffs.zip link gives me "Not found" error, could you please try again? |
Ah, yes, hopefully it works now :) |
The issue is that the
You can check the result by running |
@igrr, Indeed, changing the app partitions seems to have fixed my problem. That makes sense. Thank you very much for your help, you are a lifesaver! :) That being said, I do miss some warning in the docs about this though. |
Thanks for confirming the fix! Indeed this is an easy mistake to make, and it's a simple thing to add a check/warning for. We'll backport the commit I have linked to release/v4.3 and release/v4.4 and close this issue afterwards. |
Environment
Development Kit: ESP32-DevKitC
Kit version: v1
Module or chip used: ESP32-WROOM-32
IDF version (run git describe --tags to find it): v4.2.2
Build System: idf.py
Compiler version (run xtensa-esp32-elf-gcc --version to find it): 8.4.0
Operating System: Linux
Using an IDE?: VSCode with the ESP-IDF extension
Power Supply: External 5v
Problem Description
I am running a logger on my esp32 microcontroller. The logs are circular and thus consists of 6 files of size 16384 bytes which are deleted as the spiffs fill up. Additionally I have a small file (approx. 1000 bytes) of config values. After a while I saw that the spiffs wasn't able to save new logs, and turning on the debug logs showed that the gc in the spiffs couldn't erase certain memory addresses. This is shown in the attached logs (spiffs_erros.txt). I have tried to search around on the forums, but I have not been able to find the cause of this problem. It does not appear to be the spiffs running out of memory, as the esp_spiffs_info() api shows that only 38905 bytes are used out of 233681. My spiffs partition (see below) is set to be 256k bytes. I think the problem has something to do with the free blocks being equal to 0, but not sure why or how to fix it. To generate the spiffs I use the standard CMake api spiffs_create_partition_image(spiffs spiffs_image FLASH_IN_PROJECT), as shown in storage/examples. Correct me if I'm wrong, but I think this gives a page size of 256 bytes (as in the sdkconfig) and a 4 KiB erase block size.
Is anyone familiar with the issue and how to resolve/work around it?
Expected Behavior
Spiffs continue to work as long as there are bytes left (according to esp_spiffs_info), and the circular logs work.
Actual Behavior
Spiffs run out of blocks(?) and therefore stops being able to save new logs.
Steps to reproduce
Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 20k,
otadata, data, ota, , 8k,
factory, app, factory, , 1215k,
ota_0, app, ota_0, , 1215k,
ota_1, app, ota_1, , 1215k,
spiffs, data, spiffs, , 256k,
coredump, data, coredump, 0x3F0000, 64k
Initialization of spiffs
I initialize my spiffs accordingly
LogFiles
spiffs_error.txt
spiffs_format_errors.txt
The text was updated successfully, but these errors were encountered: