Closed tpwrules closed 1 month ago
Hi @tpwrules, thanks for opening an issue, sorry about the late response.
As far as I can tell, the superblock is always stored in one of the first two blocks (i.e. block_size units) of the filesystem, so it should suffice to erase the first two blocks only?
Yep!
The spec says that the first entry must be a valid superblock to put the littlefs magic at the 8th byte of the block. Does this mean it's sufficient to erase just the first 16 bytes of the first block? Would the first 16 bytes of the second block need to be erased too?
Yep! But most flash doesn't really support erasing a smaller size than a block, so you best bet is probably just erasing the first two blocks.
Actually, if your block device supports masking, you may be able to just prog zeros to the two sets of 16 bytes to invalidate the littlefs image without using an erase cycle. Though you would need to check your device's data sheet, not all flash supports masking for various ECC/reliability reasons (though maybe you don't care if you're just invalidating things?).
This answers my question well, thank you!
I'm designing a system where the storage area used by littlefs will be used for other purposes during system updates. I'm looking at how to safely reset the storage once the process is complete so that littlefs is guaranteed to not see a partial filesystem and the application knows to reformat it. The updater isn't linked with littlefs so it will not have the format routines. I'm using littlefs 2 if that matters.
block_size
units) of the filesystem, so it should suffice to erase the first two blocks only?littlefs
magic at the 8th byte of the block. Does this mean it's sufficient to erase just the first 16 bytes of the first block? Would the first 16 bytes of the second block need to be erased too?