Electronic – MMC/SD card interface – any access to wear levelling info? (counters, etc)

sd

I don't suppose there's something in the MMC/SD card specification for retrieving any information on erase counts on an MMC/SD card, is there?

My goal is to get my embedded system to avoid writing to metadata like last access or modified times, allocate moderately sized files filled with 0xFF sa needed, and only append records within that.

This is to reduce the risk of data loss, since power can be lost at any time.

However, the wear-leveling algorithms of MMC/SD cards is an unknown, and possibly implemented very poorly. I need to verify that the cards don't attempt to erase data blocks if I'm only writing data over 0xFFs. So, if there was just about any kind of erase count (total for the disk, per block, whatever) available to read… that'd be great.

I'm not entirely sure where this question lives… but since it involves SD card protocol level stuff, I figured maybe here.

EDIT

I believe I will go ahead and overcomplicate things. Disk tests proved that at least the SD cards I have will erase blocks even if the data you write is unchanged from the contents on disk. I'll store up to 128KB of data in directly controllable NAND (which I can control write behavior somewhat better on), then write 128KB chunks into a 128KB-aligned file on the VFAT partition. That should limit the exposure about as much as possible… but wow how ugly and complicated.

Best Answer

I don't know whether particular SD cards expose wear-leveling information, but for the most part I would suggest that your desire to avoid erasing blocks that hold FF's is misplaced. Even if a virtual disk block happens to only contain FF's, it will almost certainly contain other addressing information and error-correction data which will have to be rewritten if any changes are made to the block, regardless of its previous content.

I believe SD card manufacturers are free to select their own algorithms for deciding when to rewrite blocks which haven't been accessed for awhile, and for ensuring data integrity in the event of power failure. Consequently, I don't know of any particular method of ensuring that an SD card won't get corrupted if the power fails during a write.