SD card doesn't return its CardInfo.

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

I'm using Chan's FAT-FS. And I use an SD card by a German manufacturer "NuDisc". This card works perfectly fine in my Linux distro and works fine with f_mount, f_read, f_write (I tested it by creating a file, writing it, and reading to see if the written data was actually written). But when I used f_mkfs I receive an FR_DISK_ERR. This is because the getCardInfo (line 223, user_diskio.c) returns 0 after a time out. We send CMD9 and wait to receive 0xFE which we never get, so timeout.

*Why is this card not responding to CMD9? 

*How was the Linux OS able to format this SD card if CMD9 does not respond? Is the OS waiting for a longer time?

 

This topic has a solution.

Clament John | Still in school 

Last Edited: Mon. May 29, 2017 - 09:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The command CMD9 is not supported by SDIO, can the card be SDIO only?

Clament John | Still in school 

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

Can't help thinking this is really a question for "NuDisc". Do they offer support?

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

Contacted them, no response yet. 
Will SPI protocol work on an SDIO only card? If that's the case, it explains why every other file system command seem to work (f_open, f_write, f_read, etc).

Clament John | Still in school 

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

I thought all cards had MMC (SPI) backward compatibility (the reason being someone might by the card and plug it into a very old device).

 

I suppose there will come a point where card manufacturers might say "Why bother with MMC from 15+ years ago?" and drop support.

It will be a sad day for a lot of AVR (and other micro) based applications if that occurs.

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

Clement.J wrote:
Will SPI protocol work on an SDIO only card? ...

 

I only use "vanilla" SD cards in my AVR8 apps, with FATFS driver.  I had to use Google to narrow down "SDIO" and what it means.

 

Now, I thought that if using other than SPI interface for an SD-card, that one then needed to be a member of the association and/or pay license/royalties and like that.  That would be the "4-bit mode", right?  Does this apply to "SDIO"?

 

I found one summary site in my Google search.  Of course that random info may not be worth the paper it is printed on.  But an excerpt seems to indicate that all SDIO flavours have SPI support:

https://yannik520.github.io/sdio...

2.1 SDIO Card Types

  • Full-Speed card:
  • supports SPI, 1-bit SD and the 4-bit SD transfer modes at the full clock range of 0-25MHz.
  • Over 100Mb/second (10MB/Sec)
  • Low-Speed SDIO card:
  • Requires only the SPI and 1-bit SD transfer modes. 4-bit support is optional.
  • Support a full clock range of 0-400 KHz

 

So even though SPI-mode is supported, there is still a different set of CMD that is supported?  Dunno.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Since this SD card wasn't returning its CardInfo I hard-coded the needed value into the code. Which was just the number of sectors the card has, and mine being a 2GB SD card I used the same number of sectors of another SD card (2GB) that was working, so now FAT-FS is working and everything seem to be fine. This might be a bad solution, but it's solved for now.

 

I have a new question:

My device detects an SD fail when I'm unable to access it (the SD card) until a certain threshold. And when it fails I reset the SD card by - de-Init SPI, de-Init FAT-FS, then toggle the Enable pin with a 1-second delay between them. Then try to "init" the SD card again. But recently there has been many cases where this SD fail does not go away. And in this case, I power down the whole device, give it some time for the battery to discharge, then power up the device. This sequence of steps seems to work. 

*But why? What is the difference between me resetting the SD card through code and power resetting the device?

 

And I came across a "CMD7" in the SDIO Simplified card specification (Link) which will help us shift between Transfer Mode and Stand-By mode. Which the SD SPI driver I'm using in my code is not using.

*Should this command be used before I switch off the SD card? 

Clament John | Still in school 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Clement.J wrote:

*But why? What is the difference between me resetting the SD card through code and power resetting the device?

Solved! It was my mistake. When I try powering down the SD card through my SD_EN_Pin I forgot about the CS pin that was pulled up. So even though I was going LOW over to VCC of the SD card, the CS pin was powering the uC inside the SD card. So I never did reset the SD card through code.

Clament John | Still in school