Switch to full style
CompactFlash, SD, MMC, USB flash storage. Anything that does not have moving parts inside.
Post a reply

Random corrupt bytes in JPEGS

October 25th, 2022, 14:33

Hi,

I'm dealing with a camera SD card with many jpegs/movs. The card has no read errors (just slow) and the filesystem appears fine.
Almost all of the jpegs are corrupt. Analyzing the files show that there are random corrupt bytes scattered around the files. They do not appear to follow a regular pattern of corruption or spacing (although it looks like it might be just *bit* corruption - some bytes have an extra high nibble where a reference file has a zero high nibble).

I've tried multiple rereads of a few 'bad' sectors of a file (about 10 times) but never see a difference (do SD cards have a cache that needs to be dropped somehow?)

Any ideas as to the cause or ideas how to diagnose?

Thanks.

Re: Random corrupt bytes in JPEGS

October 25th, 2022, 14:58

Just to rule out the possibility of an interface problem, try reading the card in single-bit mode or SPI mode.

That said, if a sector were bad, wouldn't the card report a read error?

I have written a tool to count the frequency of 1's and 0's in each bit of a file:

http://users.on.net/~fzabkar/FreeBasic_W32/Utils/bitcount32.exe
http://users.on.net/~fzabkar/FreeBasic_W32/Utils/bitcount32.bas

I have also written an entropy calculator:

http://users.on.net/~fzabkar/FreeBasic_W32/Utils/entropy.exe
http://users.on.net/~fzabkar/FreeBasic_W32/Utils/entropy.bas

Re: Random corrupt bytes in JPEGS

October 25th, 2022, 15:45

Try a different reader too, just to be sure.

Re: Random corrupt bytes in JPEGS

October 25th, 2022, 16:45

I'll have to dig out my Raspberry Pi and flash the appropriate image for using an SPI SD reader.

Re: Random corrupt bytes in JPEGS

October 26th, 2022, 5:29

fzabkar wrote:Just to rule out the possibility of an interface problem, try reading the card in single-bit mode or SPI mode.

That said, if a sector were bad, wouldn't the card report a read error?

I have written a tool to count the frequency of 1's and 0's in each bit of a file:

http://users.on.net/~fzabkar/FreeBasic_W32/Utils/bitcount32.exe
http://users.on.net/~fzabkar/FreeBasic_W32/Utils/bitcount32.bas

I have also written an entropy calculator:

http://users.on.net/~fzabkar/FreeBasic_W32/Utils/entropy.exe
http://users.on.net/~fzabkar/FreeBasic_W32/Utils/entropy.bas


It should report bad sector yes. So then it's not far fetched to assume data corrupted either before ECC was computed during writing to card, or after ECC was computed while reading. Running Franc's bitflip tool is good idea.

Re: Random corrupt bytes in JPEGS

October 26th, 2022, 10:01

Can you perhaps share a few JPEGs (joep@disktuna.com), how badly corrupted are they?
Post a reply