Flash Memory & Storage
Memory Technology · Hardware Foundations track
11 min read
In this module
Storing Bits Without Power
Flash memory is the dominant non-volatile storage technology. Unlike SRAM and DRAM, flash hangs onto data after the power dies. Your SSD, USB drive, phone storage, and firmware chips all run on flash. The trick is trapping electrical charge inside a transistor structure that holds its state for years, even decades, without anything plugged in.
Flash matters for systems engineering and security work alike. The physics of flash cells dictate performance characteristics, endurance limits, and the data remanence properties that make secure erasure surprisingly hard.
Floating Gate Transistors
A flash memory cell is a modified MOSFET with an extra floating gate: a conductive polysilicon layer buried inside the gate oxide, walled off on every side by insulating oxide.
How Charge Trapping Works
To programme (write) a cell, you slam a high voltage onto the control gate (typically 15-20V). The strong electric field across the thin tunnel oxide pushes electrons to tunnel from the channel into the floating gate via Fowler-Nordheim tunnelling (older NOR designs use hot-carrier injection). Drop the voltage and the electrons are stranded on the floating gate, walled in by the surrounding oxide. Under normal conditions, they have nowhere to go.
To erase a cell, apply high voltage with the opposite polarity, yanking the electrons back out of the floating gate through the tunnel oxide.
Charge on the floating gate shifts the transistor's threshold voltage (Vt). A programmed cell (electrons trapped) has a higher Vt than an erased one. Apply a read voltage that sits between these two thresholds to the control gate, and the cell either conducts (erased, logical 1) or stays off (programmed, logical 0).
Modern 3D NAND has largely abandoned polysilicon floating gates for charge trap cells, where electrons sit in a silicon nitride layer instead of a conductor. Charge trap cells are friendlier to manufacture in vertical stacks and shrug off cell-to-cell interference better, because the charge stays put instead of roaming around a conductive gate. The underlying principle, shifting Vt by trapping charge, hasn't changed.
NOR Flash
In NOR flash, each cell has its own connection to a bit line, all wired in parallel (the topology vaguely resembles a NOR gate, hence the name). Parallel wiring buys you random byte-level access. Any individual byte reads directly off its row and column, just like SRAM or DRAM.
Characteristics
- Read speed: fast random reads (tens of nanoseconds per byte), comparable to DRAM
- Write speed: slow programming (microseconds to milliseconds per byte)
- Erase: must erase an entire block at once (typically 64-256 KB)
- Density: lower than NAND, because each cell requires its own bit line contact
Use Cases
NOR flash earns its keep where execute-in-place (XiP) matters. The processor fetches and executes instructions directly from NOR flash, skipping the copy to RAM. That makes NOR flash a natural fit for:
- System firmware (BIOS/UEFI)
- Microcontroller code storage
- Boot ROMs
- Embedded systems with limited RAM
NAND Flash
In NAND flash, cells are wired in series, in a chain that vaguely resembles a NAND gate. A string of 32 to 128 cells shares a single bit line contact, daisy-chained through the series.
Series Architecture
Reading a specific cell in a NAND string means turning every other cell in the string fully on (pass voltage on their control gates), so current can actually flow through the chain. The target cell gets a read voltage. If it conducts, the string pulls the bit line low (erased/1); if it stays off (programmed/0), the bit line stays high.
Series wiring has one consequence that defines everything else: NAND flash cannot give you random byte-level access. Reads happen in pages (typically 4-16 KB), writes happen in pages, and erasure operates on even chunkier blocks (256 KB up to several megabytes).
Why NAND Dominates Storage
Series wiring kills off per-cell contacts, which slashes cell area. A NAND cell is roughly 40-60% smaller than a NOR cell, packing far more bits into the same silicon. That density edge is why NAND owns mass storage: SSDs, SD cards, USB drives, smartphones.
| Property | NOR Flash | NAND Flash |
|---|---|---|
| Cell wiring | Parallel | Series |
| Read access | Random (byte-level) | Sequential (page-level) |
| Read speed | ~100 ns (random) | ~25 us (page read) |
| Write speed | ~10 us (byte) | ~200 us (page) |
| Erase unit | Block (64-256 KB) | Block (256 KB - 4 MB) |
| Density | Lower | Higher |
| Primary use | Firmware, XiP | Mass storage (SSDs) |
Multi-Level Cells
The original flash cells stored a single bit per cell (SLC, Single-Level Cell), with just two states: erased and programmed. By distinguishing more voltage levels on the floating gate, manufacturers shove more bits into each cell.
MLC (Multi-Level Cell): 2 bits per cell, 4 voltage levels. The threshold voltage window splits into four distinct regions, each one a different two-bit value.
TLC (Triple-Level Cell): 3 bits per cell, 8 voltage levels. Tighter margins between adjacent levels, demanding more precise programming and more sensitive read circuits.
QLC (Quad-Level Cell): 4 bits per cell, 16 voltage levels. The voltage margins are razor-thin, making QLC the most fragile of the bunch on errors and wear.
Every programme/erase cycle bruises the tunnel oxide, slowly wearing it out. As the oxide degrades, the threshold voltage distribution for each level widens and drifts, levels eventually overlap, and read errors creep in. SLC, with its wide margins, can survive 50,000-100,000 programme/erase cycles. MLC drops to roughly 3,000-10,000. TLC scrapes by on 1,000-3,000. QLC is rated for a meagre 500-1,000. The price of squeezing more bits per cell is paid in endurance.
| Cell Type | Bits/Cell | Voltage Levels | Typical Endurance (P/E Cycles) | Relative Cost |
|---|---|---|---|---|
| SLC | 1 | 2 | 50,000-100,000 | Highest |
| MLC | 2 | 4 | 3,000-10,000 | High |
| TLC | 3 | 8 | 1,000-3,000 | Medium |
| QLC | 4 | 16 | 500-1,000 | Lowest |
Wear Levelling
Flash cells have a finite write budget, so an SSD has to spread writes evenly across all cells to keep any single block from getting hammered to death. That's wear levelling, run by the SSD's controller firmware.
Static vs Dynamic Wear Levelling
Dynamic wear levelling: when new data is written, the controller picks the free block with the lowest erase count. Writes get spread across the actively-used blocks, while blocks sitting on cold (rarely-updated) data are left alone.
Static wear levelling: periodically migrates cold data from low-wear blocks to high-wear blocks, freeing up the low-wear blocks for new writes. Now even cold-data blocks join the wear party, stretching drive lifetime considerably.
Enterprise SSDs run aggressive static wear levelling. Consumer drives mostly stick with dynamic wear levelling, with the occasional static reshuffle.
The Flash Translation Layer (FTL)
The Flash Translation Layer is the firmware that makes a flash device look like a regular block device (with logical block addresses) to the operating system, hiding the messy realities of flash physics.
Why the FTL Exists
Flash has two constraints that traditional block devices don't:
- No in-place overwrite: you can't rewrite a page without first erasing the entire block it lives in. Erasing is slow (milliseconds) and operates on large blocks.
- Asymmetric granularity: reads and writes work on pages (4-16 KB), but erases work on blocks (256 KB - 4 MB).
The FTL keeps a mapping table from logical block addresses (LBAs) to physical flash pages. When the OS writes to an LBA, the FTL drops the data on a new, clean physical page and updates the mapping. The old physical page gets marked invalid (stale).
Garbage Collection
Over time, blocks fill up with a mix of valid and invalid pages. Garbage collection reclaims space by:
- Picking a block with lots of invalid pages
- Copying the surviving valid pages to a new block
- Erasing the old block so it can take new writes
The cost is write amplification. The controller ends up writing more data internally than the host actually asked for, because valid pages get relocated during GC. Amplification factors run from 1.1 (sequential workloads) to 3-5 (random write-heavy workloads). Driving that ratio down is a primary design goal for SSD firmware.
TRIM
When the OS deletes a file, it no longer cares about those LBAs, but the SSD has no way to know unless someone tells it. The TRIM command (UNMAP in SCSI-speak) is that signal. The FTL marks the matching physical pages as invalid, so garbage collection can scoop them up without bothering to preserve their data. TRIM cuts write amplification and keeps long-term performance from sliding.
Here's a toy SSD with 8 blocks of 8 pages and its own FTL. Press Write every LBA once and the write amplification sits at exactly 1.00. Then hammer it with random bursts and watch invalid pages pile up, garbage collection kick in and the counter climb towards the 3-5 range; drag the over-provisioning slider up and try again, or TRIM a few LBAs first and see how many fewer pages GC has to copy.
Flash translation layer
8 erase blocks of 8 pages. A page can't be overwritten in place, and erase works only on a whole block, so every write goes to the next free page and the old copy becomes invalid.
Changing it resets the drive. The minimum keeps one block in reserve for garbage collection.
- Host writes
- 0
- NAND writes
- 0
- GC copies
- 0
- Write amplification
- n/a
Write amplification = NAND writes / host writes. Erases: 0, TRIMs: 0. Pages: 0 valid, 0 invalid, 64 free.
Physical flash
5 valid (holds LBA 5) 5 invalid (stale copy) · free. Outlined pages were just programmed; eN is the block's erase count. Free blocks are opened lowest erase count first.
Mapping table (LBA → block.page)
- 0 → none
- 1 → none
- 2 → none
- 3 → none
- 4 → none
- 5 → none
- 6 → none
- 7 → none
- 8 → none
- 9 → none
- 10 → none
- 11 → none
- 12 → none
- 13 → none
- 14 → none
- 15 → none
- 16 → none
- 17 → none
- 18 → none
- 19 → none
- 20 → none
- 21 → none
- 22 → none
- 23 → none
- 24 → none
- 25 → none
- 26 → none
- 27 → none
- 28 → none
- 29 → none
- 30 → none
- 31 → none
- 32 → none
- 33 → none
- 34 → none
- 35 → none
- 36 → none
- 37 → none
- 38 → none
- 39 → none
- 40 → none
- 41 → none
- 42 → none
- 43 → none
- 44 → none
- 45 → none
- 46 → none
- 47 → none
A toy drive: real SSDs have thousands of blocks of hundreds of pages, separate hot and cold write streams and background GC, but the bookkeeping is the same. GC runs on its own when only the reserve block is left free.
3D NAND
Planar (2D) NAND ran into a wall around the 15-16 nm node. Cells got so close together that electrical interference between neighbours (cell-to-cell coupling) drove error rates through the roof.
3D NAND dodged the problem by stacking cell layers vertically. Rather than shrinking cells sideways, manufacturers build towers of a hundred to over 300 layers, each layer holding a full NAND array. The cells in 3D NAND are physically larger than in cutting-edge 2D NAND, which actually helps reliability and endurance, while the vertical stack delivers obscene density.
Production 3D NAND passed 300 layers in 2024-25 (SK hynix's 321-layer parts, for example), and each generation adds more. Vertical scaling is what's powered the steady march of SSD capacities (4 TB consumer drives, 30+ TB enterprise drives) while keeping endurance at or above late-generation planar NAND.
Security: Data Remanence and Secure Erasure
Flash memory presents unique security challenges.
Data Remanence
When the OS "deletes" flash data, all that changes is the file system metadata. The actual bits sit in the physical flash pages until those pages get erased and overwritten. Even after an erase, residual charge on the floating gate can leave a faint ghost of the previous data, recoverable with specialised gear.
The FTL only makes things hairier:
- Over-provisioned space: SSDs reserve 7-28% of their flash capacity for wear levelling and garbage collection. Data can hide out in over-provisioned blocks that aren't reachable through normal I/O commands.
- Invalid pages: when data is updated, the old page is still physically there (marked invalid) until garbage collection finally erases the block. No timeline guaranteed.
- Wear levelling relocation: during wear levelling, data may have been copied across multiple physical locations, leaving stray copies scattered around the device.
Traditional magnetic disk overwrite techniques (writing zeroes or random data across the entire drive) do not reliably sanitise SSDs because the FTL remaps writes to new physical locations, leaving old data in place. The ATA Secure Erase command and the NVMe Format command trigger a controller-level erase of all blocks, but their effectiveness depends on the controller firmware correctly implementing the operation. For highest assurance, cryptographic erasure (encrypting all data with a key stored on the controller, then destroying the key) provides instant and verifiable sanitisation.
Cryptographic Erasure
Modern self-encrypting drives (SEDs) encrypt all data with an internal key before writing it to flash. To securely erase the drive, the controller just destroys the key. Every bit on the flash is now cryptographically irrecoverable, whether or not the physical pages were ever wiped. The process is fast (milliseconds) and thorough (it covers over-provisioned space and invalid pages), provided the drive's encryption is implemented properly. That's a big proviso. In 2018 Carlo Meijer and Bernard van Gastel analysed self-encrypting SSDs from Crucial and Samsung and found several where the data could be recovered without the password, because the key wasn't actually derived from it. Microsoft responded by changing BitLocker's default from trusting the drive's hardware encryption to doing the encryption in software.
Flash-based devices are nasty forensics targets. The FTL mapping table (usually held in DRAM on the SSD controller and flushed to flash periodically) is the Rosetta Stone for reconstructing logical-to-physical mappings. Without it, raw flash dumps come out in physical order rather than logical order, which makes analysis a nightmare. Some forensic tools desolder the NAND chips and read them with a chip programmer, bypassing the controller entirely. The catch is that interpreting the data still demands reverse-engineering the FTL's mapping scheme, error correction, and encryption.