Magic Photo Recovery

Software Press Flash Data Recovery: Inside SD Cards Part I  

East Imperial Soft

September 12, 2014

Open PDF version

Flash Data Recovery: Inside SD Cards Part I   

There is something unique about how SD and Compact Flash cards store and organize data. Built-in microcontrollers and wear leveling mechanisms not only prolong the life of the flash storage device, but they can help recover lost data. Read how and why wear leveling helps recovering data from SD and Compact Flash cards in this series.

“I shot a wedding session last week. Moved 1.5GB of files to my computer, then shot another session with approximately 2GB of files. Unfortunately, my computer died after a power spike; the hard drive no longer spins up. Is there a chance I could recover the first photo session from my camera’s SD card, or did the second shooting session overwrite the first one?”

This was the question we received last week from one of our customers. To some of you, the answer may seem obvious: of course the second two-gigabyte data set has overwritten the first session with one-and-a-half gigabytes of data! However, when SD cards are concerned, the answer is less than obvious.

First of all, each and every SD card is not just a bunch of flash memory cells directly accessible via exposed electric pins. SD cards are controlled with a tiny built-in microcontroller that routes read and write requests, assigning one flash cell or another for the upcoming write operation.

Why do that? Flash cells take wear every time data is written. As a result, flash memory has a limited, finite lifespan measured in the number of write cycles. If data is written over and over again into the very same flash cell, that cell will soon fail, while neighboring cells will have their effective write cycles unused. To avoid this scenario, makers of flash-based storage media (SD and Compact Flash in particular) introduced a smart technology called wear leveling. Wear leveling attempts to evenly distribute write cycles among available flash cells to prevent premature failure of any particular cell.

Understanding Flash Wear Leveling

There are two approaches to wear leveling used in flash-based storage devices. Each has its pros and contras, and each has consequences with regards to data recovery.

No wear leveling

When flash-based storage devices first hit the market, many had no wear leveling at all. A flash drive with no wear leveling maps physical cells permanently to logical addresses. As a result, even if you had a large storage device, writing a small file, deleting it then writing another small file over and over would use the same memory cell(s). Obviously, in this scenario a flash storage with no wear leveling would only take so many writes before its cells start failing. In general, a flash based storage device with no wear leveling will not last very long if it writes data to the flash reasonably often.

Flash storage with no wear leveling is marginally simpler and slightly cheaper to make. It’s often used in stand-alone devices where writes are not frequently expected such as DVD, Blu-Ray and network media players, digital cameras, GPS devices and some other types of consumer electronics.

Wear leveling

Flash storage with no wear leveling is rarely used in SD cards. Although wear leveling is not officially part of the SD specification, it is routinely implemented by all major SD card manufacturers. Unless you buy a knock-off memory, chances that your SD card has wear leveling are high.

In SD cards, a built-in microcontroller creates and maintains a dynamic map linking physical cells in the SD card to certain logical addresses accessible to the outside world (e.g. by the digital camera, Windows, or your mobile phone).

Each time new data gets written to the device, this map is updated to ensure that data is written to a physical cell with least wear count, while the original cell is marked as dirty. As a result, empty cells in SD cards are utilized evenly.

Comments are closed.