Used microSD cards have errors

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh,   I love this Forum software.    Get half-way through writing a message and it disappears.

 

I bought some Used microSD cards from Ebay.     They give write errors on the PC.

So I bought some 'new' microSD from Ebay.    They turn out to be Used too.   (but error-free)

 

So I thought.   Let's go through each sector on the duff microSD card(s):

Read it into a buffer.   XOR it.   Write it back.   Read the written sector.   XOR it.   Compare with the original.

Then write the original sector back.    Verify it.

 

Rinse and repeat for 4M sectors.

 

Surely this would show any problems with a sector.    If the problem sector is in the FAT area,   this is nasty.    But for the DATA area,   I could just mark as BAD cluster in the FAT and the PC or FATfs would be happy.

 

Since the PC found errors in the first few files written,    my sector 'test' should find bad sectors pretty early.

 

Anyway,   the MEGA2560 has been happily reading and writing sectors for the last few hours.    sector #439000 at the moment.    i.e. about 15% through the card.    It has not found any errors yet.

 

David.

Last Edited: Tue. May 26, 2015 - 03:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David,

 

That's not going to work. The card itself has a micro running an intelligent wear levelling and bad block strategy of it's own.

 

If you ever write to an SD sector and the card itself detects an error during the commit it will internally mark that sector as bad then find the next free one in its own remap table. It will then write (and verify) the data in that one. So now when you write to LBA 12345 it says to itself "ah 12345, I had problems with this before, I've got it in the remap pool and it's really held in sector 87654321". So you write 12345 but it's data is held in 87654321. Similarly when you issue a read request on 12345 you get back what's actually in 87654321.

 

Of course there are two levels to errors - physical and logical. The cards own remapper will only handle physical errors. It does not care what kind of junk is actually being stored in the sectors it write/(remaps). But say 12345 was actually a FAT sector or a root directory sector and you wrote absolute garbage then, yes, chkdsk/scandisk/whatever will tell you that this is "one really screwed FAT filing system" but the error is just in the logical content of the (safely stored) sectors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So the PC would not see the write error either.

 

Chkdsk can read the FAT and Directory sectors for consistency.    It only seems to read the existing entries.

I would think that the microSD's internal MCU would have checked the CRC of each sector that it is asked for.

 

Ah-ha.   Perhaps the CV disk_read() and disk_write() don't ask the right questions.

 

Anyway,    I am going to take Ralfie out for his walk.    Then bin the known duff "Sandisk 2GB" cards.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I bought some Used microSD cards from Ebay.     They give write errors on the PC.

Tell us more about those write errors. Are you talking about fopen()/fwrite() and so on? Perhaps even lower level - the issue of a CMD24 maybe? Or something at a higher level (like drag drop a file to it in Windows exploder?). What I'm trying to get at where the errors physical or logical? In fact anything above the raw CMD24 is more than likely a FAT error - so logical.