Open
Description
With Flash and EEPROM memory, it's possible that a physically interrupted write or erase leaves a hardware memory cell in a metastable state, that is a state such that reading will return 0 in some condition (e.g. cold/now), or 1 (e.g. hot/some days later). If you ask hard enough , manufacturers of serial Flash will end up acknowledging that, and the insurances they give on reliability assume that erase and write cycles have not been interrupted by power loss.
The consequence for a file system is that on reset, it's not enough that some data reads fine to conclude it will read fine next time.
I know at least three ways to handle the issue:
- Ignore it, reasoning that it's rare, to the point that it's non-trivial to prove experimentally that it can reach the application level.
- Use a small area of memory without this metastability issue (e.g. battery-backed RAM) to handle recovery on power loss.
- Handle it with Flash only. There are some ways to make good use that Flash physically allows overwrite (as long as it's with the original data) to at least handle interrupted writes of critical flags, and build on top of that to handle interrupted erase.
I wonder what littlefs currently do w.r.t. that issue.