32Gb SDHC with bad sectors
I recently bought a generic 32Gb card on
Ebay and got what I paid for - a bunch of bad sectors which makes my recorded videos unplayable when it reaches a bad frame.
The actual fraction of bad blocks is pretty low ~ 0.001, but I can't get format to recognize them as bad. I tried using the badblocks program to detect them:
badblocks -b 512 -v -w /dev/mmcblk0p1 4296000 4096000
Checking for bad blocks in read-write mode
From block 4096000 to 4296000
Testing with pattern 0xaa: done
Reading and comparing: 4169376
After running the test twice on the same range of 200k 512byte blocks, I get about ~167 bad blocks, but the problem is that the block #s are different due to wear leveling, so I don't think the blocks can be marked bad at the file system level. The persistent # bad blocks suggests the card doesn't remap bad blocks, which would be a real bummer.
Is there anything I can do about them, or am I out of luck? Namely, does anyone know the details of wear leveling, so I can mark all logical sectors that can map to a bad physical block as bad?
Wear levelling is new to me.
For normal hard disks, I usually create a partition comprising the bad sectors, and use the rest.
If the camera can manage multiple partitions, try creating a hidden partition containing the bad sectors.
"Wear levelling" is probably handled differently by different chip manufacturers, and they are unlikely to publish or share their methods, as this would be sensitive commercial information.
Also, levelling is hidden from the hardware interface - the device itself re-maps blocks somehow, and I don't even know if it does this with hard, firm- or software. Without an electron microscope and an unreasonable amount of work, I am not going to be able to know.
So, I think your device is basically broken. Sorry for the bad news.
Maybe you could try to reformat the card using the option to check for and mark bad sectors.
Surprisingly, the 1st 2Gb of space has virtually no bad sectors. Maybe this "quality control" helps unsuspecting customers from noticing corrupt images and from totally ruining the company's reputation.
A full format doesn't detect any bad sectors. I think this is because the format just writes 0s to every sector and expects the drive to report an error if it doesn't succeed. I don't know if flash storage is supposed to report errors to the software - maybe it never does because it masks write errors and remaps the block silently.
Either way, I'm quite convinced this SD card doesn't do bad block remapping nor raise errors. Meanwhile, I've written a tool (attached) to test the sectors by doing a write/read for each free FAT32 cluster and marking them bad if the read back is wrong. I've found a region becomes practically error free after ~4% - ~20% of the clusters have been marked bad. Based on the program execution, it seems a physical block is usually remapped within ~32M of some logical position and only at certain alignments. It's not as clear as a set associative cache, but there definitely is a pattern. An estimate for # logical locations a physical sector can map to is 20% / .001 = ~200.
|All times are GMT -5. The time now is 10:22 PM.|