3 ms·
SD cards are much like SSDs - they are a combination of NAND flash and an embedded controller. Upon power-up, the controller has to initialise by reading the bl
by userbinator 12y ago
SD cards are much like SSDs - they are a combination of NAND flash and an embedded controller. Upon power-up, the controller has to initialise by reading the block mapping tables (BMT) from the NAND. This wouldn't be a concern, and it wasn't, in the days of large-geometry/high-endurance flash where the controller would power up and just sit idle waiting for commands after initialisation. Any power interruption would just reset the controller and it'd try again.
However, newer higher-capacity (and smaller process size) flash is far less reliable - endurance and retention are orders of magnitude less, while raw bit error rates are correspondingly higher. MLC makes this even worse, but manufacturers have been masking the problems by using stronger error correction. This strategy mostly works, but combined with another characteristic of dense NAND flash -read disturb - makes for memory devices that are far more fragile and sensitive to power interruptions than before. Read disturb means that repetitive reading of the same blocks in flash has a writing effect to adjacent bits to the ones being read, so even read operations are somewhat destructive. What this means is that the block management controller may have to perform a copy (i.e. a write) and erase after a certain number of reads. Furthermore, blocks which have been idle for a long time also need to have their contents periodically refreshed, since the data slowly fades away as the electrons leak out.
All these characteristics together mean that at any one time, even if the SD card is "idle" or only being read, block erase/program operations maybe occurring internally. If a power interruption happens, then depending on what was being written at the time, anything from silent data corruption (if the block was storing user data) to a complete failure of the card (if the block was part of the BMT or other management data) can occur.
Most applications of SD cards don't often cut power abruptly, which is why this problem doesn't occur. The RPi is an exception. If you want to reduce this problem as much as possible, my recommendation is to use older, low-capacity SD cards, which may contain large-geometry SLC flash. This is not going to cheap (per capacity), but will be cheaper than new "industrial grade" cards (which may actually be worse). I've had good luck with cards from relatively unknown Chinese/Taiwanese OEMs - many of them explicitly specify "100K program/erase cycles", something that the "consumer" brands don't even mention.
- kabdib 12y agoThey don't do transaction systems on these cards? That's like "Writing to a Consumer File System 101". Yike.
- userbinator 12y agoI'd say that they certainly try to, but the block-erase and page-program granularity of NAND flash makes it pretty much impossible to guarantee any atomicity of operations without ridiculously wasting the capacity. Furthermore, pages within a block can only be programmed sequentially to avoid corrupting previously programmed pages (this is known as "program disturb"), and each page can only be programmed once, also to avoid program disturb effects.
- kabdib 12y agoInteresting. I'm surprised that NAND flash chips don't have some kind of hardware assist for this (e.g., really small pages for handling the much smaller checkpoint writes). But I guess at the level of utterly fungible consumer hardware it's about cost rather than reliability, since the latter doesn't have any absolute metrics.
- wyager 12y agoIs there such thing as a modern high-reliability SD card, resistant to power cuts and tough environmental conditions? It seems like there would be a market for that in embedded industrial or military devices.