SD cards and DATA_STAT_AFTER_ERASE

Arnd Bergmann arnd at arndb.de
Sun Apr 17 17:29:08 EDT 2011


On Thursday 14 April 2011, Daniel Drake wrote:
> Hi Arnd,
> 
> As you've obviously been working with a large range of SD cards, I
> wonder if you have any comments/knowledge on erase behaviour.
> 
> The SD card spec says that CMD32/CMD33 erase can leave the data as
> either all-zero or all-one, depending on bit 55
> (DATA_STAT_AFTER_ERASE) of the SCR.
> 
> Do you have any comments on the general trend is for
> DATA_STAT_AFTER_ERASE? Do most vendors erase as 0 or erase as 1?
> I've seen the discussions around badly manufactured SD cards; do you
> know how reliably this bit is set by the vendors? If they set it
> incorrectly it would be quite inconvenient for my plans.

I have only looked at this for two cards. Both had the correct information
in them, one had 0, the other had 1. My feeling is that the majority
of the cards would be using 0, but that could be wrong.

> Currently, when installing software, OLPC firmware erases the entire
> disk then writes the entire disk contents, even if most of that is
> zeroes. I am looking at an optimization where we can simply avoid
> writing those 0 blocks, greatly speeding up the flashing process. In
> my test case of 1 SD card, DATA_STAT_AFTER_ERASE=0 and the vendor is
> not lying about this, so I managed to cut down the time needed to
> install an OS image by more than 50%. Hopefully this can apply on a
> wider basis...

I would not trust the register in general, I've seen too many cards
that report incorrect settings elsewhere. I do believe that trying
it out on a single erase block should show you reliably what the same
command will do on all other erase blocks.

	Arnd



More information about the Devel mailing list