Skip to content
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

Finally #5

Closed
ullix opened this issue Oct 15, 2020 · 9 comments
Closed

Finally #5

ullix opened this issue Oct 15, 2020 · 9 comments

Comments

@ullix
Copy link

ullix commented Oct 15, 2020

I struggled with SPIFFS, finding it to be "A Flash Memory Catastrophe" [https://forum.arduino.cc/index.php?topic=648987](ESP32 mit SPIFFS - eine Speicher Katastrophe), using FFat with some success but issues on power failures, but wanting LittleFS for its claimed Power-loss resilience.

Many, many thanks for making it available in the Arduino libs!

I repeated my earlier tests, and can say that at least in writing performance LittleFS beats the others.

FS_Compare_Auswahl_362

SPIFFS is simply not usable. Why would one uses it when FFat and now LittleFs are avaialble?

There does not seem to any reason to simulate behavior of this very poor FS, so why even bother thinking about it?

@lorol
Copy link
Owner

lorol commented Oct 15, 2020

@ullix
Thank you for your analyses and good words.

Edit: I just missed your essential question about simulation of SPIFFS flatness. Here is the answer:

There are existing examples that simply don't work, because they expect to create a file like: /aaa/bbb/ccc/file.txt at one shot, w/o creating folders. Also when such file is deleted and no more files named /aaa/... the folders to be deleted too.
To make the things even worse, on esp8266, LittleFS already simulates it backwards-compatible and again, LittleFS examples that work on esp8266 may not work directly with this lib. here.

I guess 99% of devs don't know, don't care or just wait for an "official" announcement about SPIFFS depreciation +blessed replacement availability to consider LittleFS on esp32 (or even FAT - it is still unfinished in terms of official/standard FS image uploading).
Esp32 is rather a commercial than community thing and their (i hope well-) paid developers concentrate on other priorities, like HW drivers, S2 and S3 peripheries ... etc.
Credits for this project go mostly to @BrianPugh who did the big work to bring implementation alive.
I just experimentally succeed to "plug-it" to Arduino as a library without new pre-compiled set of .a files as most low-level IDF<->Arduino stuff is done otherwise.
We did everything from our side, a submission to official IDF components, Arduino library manager, examples for IDF, PlatformIO, Arduino and uploading tools. Code and info is there. whoever search will find it. Some links again, hope they are useful:

https://github.com/joltwallet/esp_littlefs
https://github.com/lorol/arduino-esp32fs-plugin
https://github.com/lorol/ESPAsyncWebServer/tree/master/examples/SmartSwitch
espressif/arduino-esp32#3765
espressif/arduino-esp32#4096
espressif/esp-idf#5469
https://github.com/earlephilhower/mklittlefs
me-no-dev/ESPAsyncWebServer#792
espressif/arduino-esp32#4138
http://community.platformio.org/t/how-to-define-littlefs-partition-build-image-and-flash-it-on-esp32/11333/

@ullix
Copy link
Author

ullix commented Oct 16, 2020

Well, kudos to all developers; unfortunately most of this stuff is beyond my pay grade...

The "Power-loss resilience" is still something I wanted to test. So I took the program used for the graphs above, and increased saving rate 10fold to once every 100ms. Then I interrupted the ESP32-Pico by pulling the USB-power plug or hitting the reset button on the device. With a saving cycle - open,print,close - typically taking some 50...80 ms, there would be a very good chance of knocking the cpu out in a middle of saving.

I tried hard, but I have to admit that I failed miserably trying to corrupt the Internal-Flash filesystem.

Wonderful :-))

Though I don't need it now, I am wondering whether LittleFS can also be used on an external SD card?

@lorol
Copy link
Owner

lorol commented Oct 16, 2020

@ullix
Thanks again to continue testing. Your robustness validation is a great feedback!
Regarding SD card, I believe currently it uses only FAT (ff.h), but maybe @lbernstone or @BrianPugh can determine if LittleFS is possible to be implemented for esp32 SD and or if makes sense to go be done :) at all.

@ullix
Copy link
Author

ullix commented Oct 17, 2020

On LittleFS: how do you know that you have a corrupt file system or at least one corrupt file?

Would be great if it never happens, but I am not ready yet to believe that.

On FFat I routinely and often checked and looked for a file with this file name:

const char bad[] = {'/', 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, '.', 0xFF, 0xFF, 0xFF, 0x00};

When you find only a single of them, the FFat FS is corrupt and it needs formatting.

But what to check on LittleFS???

@lorol
Copy link
Owner

lorol commented Oct 17, 2020

You can use provided means: https://github.com/lorol/LITTLEFS/blob/master/src/LITTLEFS.cpp#L50
Further, you can check in lower level files when ESP_FAIL and ESP_OK are returned.

See also on ARMmbed discussions, like; littlefs-project/littlefs#68 (comment)

@ullix
Copy link
Author

ullix commented Oct 18, 2020

I found an error code LFS_ERR_CORRUPT, but I don't see how to read it from the Arduino code?

Also, the ARM discussion seems to show that corruption can happen, but will be seen only as a bad directory, suggesting that the individual files in that dir can be read, although they may be correupt and contain nonsense?

It would seem that an enhancement to code is valuable which allows an easy call to determine a "corrupt" situation!

@lorol
Copy link
Owner

lorol commented Oct 18, 2020

@ullix At Arduino, you just should enjoy the high-level programming and don't worry too much :)
If something is wrong and detectable, it will fail on mounting (begin ...) stage and require format anyway.
Looking at corrupted directory pair internals, trying to recover, chasing the readable files etc. is not something that I would recommend to go deploy at your application level. Maybe implement your own verification at high level, example, a checksum, redundancy with several files for given thing etc.

@lorol
Copy link
Owner

lorol commented Oct 21, 2020

I am closing this case as it is rather a discussion, not a problem.
You can still comment after the closure if necessary.

@lorol lorol closed this as completed Oct 21, 2020
@EL-EK
Copy link

EL-EK commented Jun 22, 2021

Just wondering if work was done on implementing littlefs on esp32 and SD card as discussed by @ullix ? Are there thoughts from @BrianPugh or @lorol ? I'd like to use littleds on an SD card with ~32GB of storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants