A well-known SD card producer advertises that his SD cards use wear leveling. If enough space is free on the card, write access is evenly distributed over free memory.

But how does the built-in memory controller know which memory sectors are unused or free?

  • Each flash page consists of bytes for payload (i.e. user data) and extra bytes for meta-data and error correction. It's the meta-data that indicates how the page (and the sectors within) are used/allocated and use counts. – sawdust Mar 24 '16 at 17:41
  • Good that, but how can I fill the meta-data with the correct information? Respectively, how can I set a flag in the metadata to indicate that the corresponding memory is unused? – wewa Mar 25 '16 at 7:39
  • You can't. These regions of the flash are for the exclusive use of the SDcard's controller. This controller will perform the wear-leveling. Why do you think you need access? BTW your concept of wear-leveling is flawed. Wear-leveling does not involve states of "unused or free". Wear-level does employ a use-count, i.e. the number of times the page has been erased and written. The pages with the lowest counts are first-choice for the next write. – sawdust Mar 25 '16 at 21:52

SD cards have a ERASE command with which the OS can signal that a given block is no longer in use. I don't know how well that command is supported on cameras, tablets, phones, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.