Flash
2026-05-24
Edited: 2026-05-24
Flash is cool. Very cool. But also kind of confusing, but maybe that is just a me thing. Anyways, flash storage has five organizational levels. From largest to smallest these are
- package: the entire chip itself
- die: an independent unit capable of executing commands, a package has at least one
- planes: a die can have one or two (sometimes more) planes, each plane performs the same actions concurrently
- blocks: a plane contains blocks, the smallest unit which can be erased
- pages: and blocks contains pages, the smallest unit which can be programmed
Note: it seems sometimes blocks might be referred to as sectors? Reading and writing (programming) operates on pages while erasing operates on blocks. Some flashes can also support offsets (sometimes called columns) into the pages, so you can write in the middle of the page if you want. Also it seems that there are often two stages for reading and programming
- reading: load to cache, read from cache
- programming: load program, execute program
The first step always involves writing or reading to some buffer first and the second step actually performs the process, whether it is making the data available after reading or actually storing the data onto the drive for flash. These seem to be a good way to cache up larger reads and writes, which should be better for performance.
And to erase data, you must do so on an entire block, which is larger than a page. This is problematic because you obviously should not erase an entire block each time you want to change a page, which is like eating one noodle with a giant fork. So instead the smarter option is to use a FTL (Flash Translation Layer), which keeps tracks of invalid pages so they can be erased later once the block is mostly filled with invalid data and to write the new data else where.
This is really useful for wear leveling as blocks have a limited program erase cycle (PE cycle) so by delaying the erase until it is really needed, we can extend the life of the flash, which is especially so in an embedded environment where such flashes have a much shorter lifecycle than their desktop counterparts. I find LittleFS to be a pretty good choice for embedded use.
Note: an empty NAND flash has all 1s.
Links:
https://stackoverflow.com/questions/12345804/difference-between-blocks-and-sectors