-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
LittleFS loses file content. #8155
Comments
This looks to be a coding issue in the MCVE. not LittleFS. Until the |
Thanks @earlephilhower for your information, What I think is LittleFS wrapper library doesn't employ original littlefs correctly, somehow causing the file to be erased first before calling What makes it more clear that littlefs states it falls back to last known state, which is not the case.
I'd welcome If this kind of feedback is welcomed: (removing |
No, that's not the case, or the way LittleFS atomicity is spec'd. LittleFS It can't be any other way. Say, for example, you have a 1MB file on a 1MB FS, so 0 bytes free. If open("file", "w") did not erase the existing file, you could never write to the file again. The "w" implies a 0-ing out of the dir entry, which is rewritten by LFS in an atomic way (i.e. the FS won't go inconsistent due to a partial write). For what you want to do, the traditional thing is to have 2 files with an epoch counter in each. You then overwrite the older epoch'd file on each run. On startup you'd read both files and pick the highest epoch. |
The workaround could solve it, but it's not what's expected from a FS to lose an entire file. IMO, as a library: it shouldn't be left to the user to do so. Now it's going to be LFS related issue (not to the wrapper). |
Basic Infos
Platform
Settings in IDE
Problem Description
While using LittleFS, file is getting lost if the MCU resets.
It was early discovered by noticing some configuration are lost, caused by a bad and loosely power supply cable causes MCU to reboot several times at start.
After that, I've verified the issue, and wrote an example sketch with an external user requirement to reproduce it, which is pressing RST button quickly.
While LittleFS documentation states the following:
MCVE Sketch
An extra calls are put to produce helpful (hopefully) information to the Serial, starting with
LittleFS.end();
.platformio.ini:
It could contain some irrelated options,
Debug Messages
The text was updated successfully, but these errors were encountered: