Skip to main content
Clament John
Associate II
May 11, 2017
Solved

SD card no response for CMD0

  • May 11, 2017
  • 10 replies
  • 4959 views
Posted on May 11, 2017 at 11:09

A device I had been testing for over two months suddenly started giving FR_DISK_ERR (I'm using Elm Chan's FAT-FS) [

http://elm-chan.org/fsw/ff/00index_e.html

]. When I tried debugging, the command (CMD0) which must be clocked in to set the SD card into SPI mode (as described in the SD card spec sheet - SDcard.org [

https://www.sdcard.org/developers/overview/sdio/sdio_spec/Simplified_SDIO_Card_Spec.pdf

)  return 0xFF and not 0x01, i.e. it failed. 

My question is:

*If CMD0 fails does that mean the SD card controller is not working?

*Will it still work in SDIO mode even if CMD0 fails? (I couldn't test it as my uC does not support SDIO)

*Can an OS (Linux, Windows, Mac) format this SD card to make it working again? If so how does it do it?

--Linux's (I'm using Ubuntu) gparted was giving an error while it was trying to read the disk. I got an error 'input/output error during read on /dev/sdb' Does this mean the SD card is a 'gonner'/ never going to work?

#sdio-chan-fatfs #fat-fs #micro-sd-card
This topic has been closed for replies.
Best answer by Clament John
Posted on May 11, 2017 at 17:40

My first question was answered.

If CMD0 fails does that mean the SD card controller is not working?

Yes, this means the SD controller isn't working. Thanks,

Turvey.Clive.002

‌

meyer.frank

‌

Will it still work in SDIO mode even if CMD0 fails?

I'm going to assume SDIO won't work, as the controller might be 'broken'

Can an OS (Linux, Windows, Mac) format this SD card to make it working again? If so how does it do it?

In my cas,e gparted was unable to read the disk. But I have come across many cases where the SD card was unusable with respect to STM32 + FAT-FS, but I was able to format the SD card in a PC and reuse it in the device. Thus a PC was able to do something the device's firmware was unable to do. Have to find what this was.

10 replies

Tesla DeLorean
Guru
May 11, 2017
Posted on May 11, 2017 at 14:14

If a Linux/Windows box can't read it, then that suggests the card or contacts are damaged. Try a different card.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Clament John
Associate II
May 11, 2017
Posted on May 11, 2017 at 14:37

The device worked with two other cards. But it was just this card that failed. 

I have similar cases like this for multiple devices. When Chan's FS returns an error as its return value, I power down the device (basically remove its power source, not setting it into sleep) and after some time when I power ON, everything starts working again. Why is that?

And when it can't be fixed by the firmware I debug and see that I'm receiving an FR_DISK_ERR. Might be some connection/ connector issue?

AvaTar
Senior III
May 11, 2017
Posted on May 11, 2017 at 14:18

A device I had been testing for over two months suddenly started giving FR_DISK_ERR ...

I would not rule out a contacting issue, either with the card slot, or the card itself.

But yes, it is not so difficult to damage the file system.

--Linux's (I'm using Ubuntu) gparted was giving an error while it was trying to read the disk. I got an error 'input/output error during read on /dev/sdb' Does this mean the SD card is a 'gonner'/ never going to work?

There are quite a lot tutorials around on the web, for Ubuntu as well. IMHO at least worth a try. I have done this some time ago, but unfortunately tend to forget the exact individual steps ...

For Window$, the 'HP USB Disk Storage Format Tool' is around for a long time, and works well.

And the sdcard.org website has a formatting tool for free download (Win and Mac) as well.

Clament John
Associate II
May 11, 2017
Posted on May 11, 2017 at 14:30

Is there a way to fix this remotely? Can the device detect a physical error, like FR_DISK_ER has occurred and sent a certain SD command to reset everything? Currently, Chan's FAT-FS has no method to solve a physical error.

AvaTar
Senior III
May 11, 2017
Posted on May 11, 2017 at 15:32

Not that I know of, and the FatFS implementation I worked with. Resource constraints of the targets prohibit all file system features. But I never went very deep into the SD command specs.

I not yet managed to break a SD card in a STM32 (or Cortex M) device, but pulling a card or switching off during operation is a 'good' way. Reformatting with mentioned tools saved the cards I managed to mess up otherwise.

Clament John
Clament JohnAuthorBest answer
Associate II
May 11, 2017
Posted on May 11, 2017 at 17:40

My first question was answered.

If CMD0 fails does that mean the SD card controller is not working?

Yes, this means the SD controller isn't working. Thanks,

Turvey.Clive.002

‌

meyer.frank

‌

Will it still work in SDIO mode even if CMD0 fails?

I'm going to assume SDIO won't work, as the controller might be 'broken'

Can an OS (Linux, Windows, Mac) format this SD card to make it working again? If so how does it do it?

In my cas,e gparted was unable to read the disk. But I have come across many cases where the SD card was unusable with respect to STM32 + FAT-FS, but I was able to format the SD card in a PC and reuse it in the device. Thus a PC was able to do something the device's firmware was unable to do. Have to find what this was.

Tesla DeLorean
Guru
May 11, 2017
Posted on May 11, 2017 at 20:46

I think you are confused about what software is involved. FatFs has a formatting module as I recall, most people don't aenable it, but these are all very thin implementations. The Windows system has significantly more software to both format/partition the media and do file system checking (ie CHKDSK, SCANDISK, FSCHK). There is also a difference between file system structures on the medium, and the ability to read/write the media itself. Your problem, as described by you appears to be the latter.

SDIO uses 1-bit mode to walk itself into 4-bit and extended modes.

Do ANY commands work? You focus on CMD0.

Is it possible you over-voltaged the card and damaged it that way?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Clament John
Associate II
June 6, 2017
Posted on June 06, 2017 at 13:53

None of the commands work, not just CMD0. But according to the SD standards, we must send and get a valid reply for CMD0 which would set it to SPI mode.