Part 2 of 7 · 2 min read
Pages and blocks
Think of a whiteboard that can only be wiped as a whole board, while you may write on any clean spot with a pen. Writing a word on a clean spot is easy. Changing one letter of a word means wiping the board and rewriting everything you wanted to keep. The analogy stops in one place: a real flash page cannot be partly written twice, and a pen can add more words to a half-full spot.
In plain words: Flash memory stores bits as charge in cells. Cells are grouped into pages (commonly 4 KiB to 16 KiB), and pages are grouped into blocks (commonly 64 to 256 pages). The chip can read a page and program (write) an erased page. It can erase only a whole block. A programmed page cannot be programmed again until its block has been erased. Erasing is slow and wears the cells out after a limited number of cycles.
A worked example (made up to show the idea). A page has 4 KiB and a block has 64 pages, so a block has 256 KiB. Reading a page takes 50 microseconds, programming a page takes 500 microseconds and erasing a block takes 3 ms. A 1 GiB drive then has 1 GiB / 256 KiB = 4,096 blocks. Reading all 64 pages of a block takes 3.2 ms. Programming all 64 pages takes 32 ms.
The key lines. These three operations have different sizes. Read and program work on one page. Erase works on one block. Everything in the rest of this page follows from that mismatch.
Flash page and block
A flash page is the smallest unit that can be read or programmed in a flash chip. A flash block is the smallest unit that can be erased, and it holds many pages. A page that holds data cannot be programmed again before its whole block is erased.
Example: a block of 64 pages of 4 KiB holds 256 KiB. Changing one 4 KiB page in place needs the whole 256 KiB to be erased first.
Check yourself: 1. Which of read, program and erase works on a whole block? 2. How many blocks does a 1 GiB drive have in the worked example? 3. How long does reading all pages of one block take in the worked example?