Closed alessandrofrancesconi closed 10 months ago
A little update: as you see the "writing" part writes 10 rows of 0123456789012345678901234567890123456789\n
. The actual sync is executed by the close operation after the loop.
Now, if I add a lfs_file_sync
inside the loop, then I cut-off the power during the test, now the resulting error at the reboot is LFS_ERR_CORRUPT
.
Again I still need to check the validity of my implementation. But if it is correct, I'm wondering what the authors mean with "Power-loss resilience" of the library. Maybe I'm misunderstanding the point?
I've noticed that flash.eraseBlock(block)
function from SPIFlash internally uses opcode "0xD8", that is the "Block 64K Erase" operation on Winbond. So I've changed the lfs_cfg.block_size parameter into:
lfs_cfg.block_size = 1024 * 64;
That seems to be a solution of most of my issues. I will keep this open until I've finished some tests...
I'm working with a hardware based on Arduino Zero board (SAMD21) and Winbond W25Q128JV flash memory. My application must be able to handle random power failures, so I'm trying littlefs for this purpose since that:
I'm not a real expert on NOR flash-memory usage, so I'm asking you some help to validate my implementation.
I've started setting the
lfs_config
structure, looking at the W25Q architecture described in the official DS: https://www.winbond.com/resource-files/w25q128jv_dtr%20revc%2003272018%20plus.pdfEnding up with these parameters:
Then for low-level operations, I'm using Adafruit_SPIFlash library that is compatible with Winbond W25Qxxx memories (also it uses DMA for faster operations). It provides the following set of functions:
Full list here and here
So I've tried to use these functions for littlefs' read/prog operations:
Here is the code I use to test: I create a TXT file and I will it with some strings. then I read it back.
I encapsulate the test procedure in a
while(true)
loop in order to stress it. I currently have two issues:lfs_file_close(&lfs, &f)
takes 4 seconds to finish with OK result (instead of average 200ms) but the nextopenFile(&f, path, LFS_O_RDONLY)
returnsLFS_ERR_NOENT
. At the very next iteration, it works again for another 30 iterations, then the error again.lfs_mount
returnsLFS_ERR_INVAL
and no more operation is possible.The second point is what scares me as I'm expecting that littlefs should manage power offs fairly good. Anyway, first I would like to know if my core implementation is correct. Can you help me? Thanks.