littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data Flash values after erase is "undefined" - Would LittleFS work?

test-sg opened this issue · comments

I would like to know if LittleFS is designed based on the assumption that, the values of flash after erase, are '0xFF'?
I am using a family of Renesas family MCU where the values of data flash after erase is 'undefined'

Would LittleFS work on this type of MCU?

LittleFS doesn't assume 0xFF actually, so it should work.

To be exact, LittleFS requires only that subsequent reads after an erase returns the same value, or consistently returns LFS_ERR_CORRUPT.

Usually when flash devices say the value after an erase is undefined, it's because they include some extra error-correction that becomes invalid after an erase. But as long as it consistently reports invalid, we can use that to detect if the block has been erased.

But I would also double check the datasheet to see if they define "undefined". In theory a new storage type could put the storage into a truly unstable state on erase, but if that's the case I'm not sure it's even theoretically possible to log when power-loss is involved...

Worst case, erased-state in LittleFS is checked with a checksum before use, so if the erased-state is truly unstable it just means LittleFS will erase much more often. Though depending on the underlying storage this could be impractically slow.