The SD/MMC card of doom!

Discussion in 'General Electronics Chat' started by THE_RB, Nov 7, 2011.

  1. THE_RB

    Thread Starter AAC Fanatic!

    Feb 11, 2008
    I thought you might like to hear a story about my recent fight with a SD card!

    It is a 4Gb normal sized SD card, used from new in a camera for a few months. The camera battery got low and there was a "card error" message. No new files (photos) could be written to the card.

    OK, easy enough, diagnosed it in Windows scandisk and re-format. After reformat, scandisk says card is now ok. Check card in Windows, there are still 6 folders and hundreds of photos, all readable! Card is still faulty, trying to write files to it.

    OK, then "format" and "low level format" using the camera. Both times camera says "format completed ok", both times folders and photos are still on the card! :eek: What the??? This is a card straight from the twilight zone!

    OK, downloaded a plethora of SD card low level diagnosis and formatting programs from the internet. Some say "card fault" some say "card formatted ok" some format and diagnose the card, then say it is ok, then the *&^*$ folders and photos are still on the card and the card has the same fault! Windows XP tricks also say it has re-formatted ok, but to no avail. The card is now upgraded from "twilight zone" to official "demon card" status.

    OK, so me being a smartypants I get my PIC18 development board out, the one with the SD card socket built in... Can you guess what is coming? I write a PIC program, that directly writes 0xFF over EVERY sector (every 512byte block in the cards ROM) at the lowest addrssing level. No subservience to the FAT, nothing can go wrong. :) The PIC code writes 0xFF to all 512 bytes in the sector, then checks the card gives a "write was ok" message, then writes over every subsequent sector on the 3.89gB card... There are 7.7 million sectors! I add a LCD display and a message to show what sector it is up to (every 30 seconds or so).

    Now writing to a SD card is a little slow as the card has an internal eeprom write cycle. So the process to manually overwrite (erase) EVERY sector on the card takes 45 hours. I plug in a wallwart and leave it running for 2 days, secure in the smug feeling that NOW every damn sector on the card will be manually erased whether the card likes it or not. Haha! FAT16 who? We don't need no stinking FATs. I feel like a conquering hero. ;)

    45 hours later... LCD message shows all 3.98Gb overwritten with no faults. I plug the card into Windows, and huh????? The folder and photos all still there!! NOOOOOO! This is ElDiablo the SD card of DOOM!

    I re-write my PIC code to write 0xFF to each sector, then manually read the whole sector back, and compare every single byte to make sure it wrote ok. Guess what? Sector 0 = FAIL. Sector 1 = FAIL. Sector 2 = FAIL, every damn sector write->read = FAIL. Every byte = FAIL.

    The moral of the story. Well, sometimes you just get beat. :(

    At this point I know the card is going through the write cycle normally, writing normally, and issuing "write was ok" message normally. Which is why all the programs (inlcuding my own) said it was reformatted or erased ok. But there must be a hardware fail inside the card write electronics, so even though the card itself *thinks it wrote ok* the write does not happen at all. Never. Possibly the charge pump that makes the Vpp programming voltage inside the card.

    Well, I learned a bit more about FAT16, FAT32 and the utilities you can use to save (some) dead cards, but you can't save the ElDiablo SD card of DOOM!

    (update) My woman rang the place we bought the camera from. "Sure! No problem!" The happy lady replied. "We'll replace the faulty card under warranty!".
    Roman says AAARRRGGGGH! ;)
    R!f@@ likes this.
  2. nerdegutta


    Dec 15, 2009
    Sometimes, the easy is the best...

    Entertaining story.
  3. Wendy


    Mar 24, 2008
    See, you should asked the misses how to handle it!
  4. tom66

    Senior Member

    May 9, 2009
    It is also possible the flash memory has reached its write limit, although that would usually only apply for a few sectors.

    You could try a raw drive editing utility on Windows or Linux. In Linux, it is usually as simple as opening the device (e.g. /dev/sdb1) as root in a hex editor, making sure it is unmounted... Also be careful you are writing over the SD card and not parts of your HDD!!!! In Windows I'm sure it's possible too, but no idea how.
  5. THE_RB

    Thread Starter AAC Fanatic!

    Feb 11, 2008
    :D She fixed it with a 1 minute phone call. Darn it. I think she felt too sorry for me to say "I told you so"... ;)

    Tom66- Thanks for the tip about manually editing the card contents, some of the utilities I downloaded basically did the same thing and did low level format, re-create and write the FAT fresh etc. The problem was the card kept saying all the writes and the changes were made ok, when of course not a byte ever got successfully written to ROM. Tricky little card.

    I'm about to take pleasure in connecting its power pins to a 50v DC 6 amp PSU, to fuse it's brain good and proper before returning it. :D
  6. thatoneguy


    Feb 19, 2009
    I have a couple 8G Micro SD cards with adapters, they are under $10 now for 8G, and 16G are $18.

    I must admire your tenacity at trying to wipe those files, one makes me wonder what the images were of. :D

    Maybe you could try opening up the case with an Xacto and bypass the addressing chip to get directly to the flash chip, in the event they are two separate parts still.
  7. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    RB..u are my kinda guy...
    It was good laugh.
  8. THE_RB

    Thread Starter AAC Fanatic!

    Feb 11, 2008
    Haha! No if it was just a matter of erasing cheeky photos for privacy, I would have hit it with a hammer and thrown it in the bin.

    The goal was to make the card working again! It was the card that came with the camera and I only wanted to use it for that. I have other cards but they have their own tasks.

    To NewbieEm- What is your goal with the software? If you just want to erase or reformat a working card you can do it with Windows. Also there are free PC software utils that can reformat the card or fix bad FAT and recover files etc.

    To Riff- Thanks! Glad you enjoyed it. :D

    ElDiablo card was fried in the electric chair for his sins, then was completely forgiven and now relaxes up in MMC heaven, surrounded by pretty MP3 players...
  9. Wendy


    Mar 24, 2008
  10. THE_RB

    Thread Starter AAC Fanatic!

    Feb 11, 2008
    Thanks Bill, I'll check there. :)