Troubleshooting SD memory cards

On November 26, 2011 by sebastien.lelong

This is a recurrent issue: “my SD card won’t work, I tried the sample, I triple check hardware, it just won’t work”. The main problem here it’s hard to get feedback and report it to jallib library’s author (namely Matt). Different issues were previously found:

  • some brands seem to work better than others. For instance, SanDisk is reported to work nice, whereas there seems to have troubles using Kingston’s.
  • some SD cards will require pull-up resistors, some won’t.
  • and SDHC, high capacity SD card, aren’t supported.

When experiencing SD card for the first time, it’s hard to understand where the issue comes from. You first have to check hardware, make sure connections are OK, add pullups resistors on at least on /SS pin. I’ve recently experienced a hardware issue, whereas I knew for sure it had previously worked. The problem was coming from a non-working connection on microSD socket. Soldering pins again fixed the issue.

Once hardware is checked, you’ll have to make sure your software is properly written, proved to work. Luckily you’ll find fully tested HEX files for Jaluino Bee board on project’s SVN (see hex files). Check correspoding uncompiled Jal files in order to know what’s expected. If your board is following standards (same MCU, Xtal,…), these HEX samples must work. If not, well, check your hardware. If it’s still doesn’t work, maybe it’s coming from your SD card.

You should now run the reporting sample, named “jaluino_bee_sd_card_report.hex” (click on “View raw file” to download it). This is a Jaluino Bee sample that will print, through serial (9600 1N8), some debugging informations while initializing SD card. While this won’t fix your issue, it’ll at least help understanding where you’re stuck, helping developpers fixing the bug (hopefully).

Following is an example showing a successful SD card init:

Basically, sd_init() is called, it tells the card it’ll use SPI protocol. It resets the card, and the card replies “ok” (0×01). It’ll then wait the card to be ready. This means until the card doesn’t reply “00″, it’s not good. In this case, “00″ was returned after seveteen “01″. So far so good, the init is done. More subsequent information is then displayed. Typically, in this case, it’s been reported by Matt that when the card replies “FF” instead of “01″ after resetting the card, it’s mostly a hardware issue. I can confirm this from my last experiment :)

On the other hand, using the same program with a SDHC card gives:

Unfortunately in this case, we’re getting stuck while waiting for the card to be ready. We’re constantly reading “01″ as a response, while we should have “00″. (careful, don’t mess up with “reply” and “response” terms here. “reply” is the first returned value after reset, while “response” are the returned values while waiting for the card to be ready).

If you’re experiencing SD card problems, please run this sample on your Jaluino Bee board and report your results. Let’s hope with enough data, from different brands & card types, we’ll find how to handle them all !

 

Comments are closed.