2017-05-11 02:09 AM
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-cardSolved! Go to Solution.
2017-05-11 08:40 AM
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.
2017-05-11 05:14 AM
If a Linux/Windows box can't read it, then that suggests the card or contacts are damaged. Try a different card.
2017-05-11 05:18 AM
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.
2017-05-11 07:30 AM
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.
2017-05-11 07:37 AM
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?
2017-05-11 08:32 AM
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.
2017-05-11 08:40 AM
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.
2017-05-11 10:26 AM
The cards are pretty stupid, they might have an 8051 type core to manage the NAND array and command sequencing, and caretake the hardware/state-machines. There isn't some magic reset button or command to fix things. At the level where it is non-responsive to commands you have likely broken the contacts, cracked the substrate or wirebonds internally.
I have cracked at least one microsd card, and had several fail over the years. They are cheap enough that it is not worth spending a lot of time/effort on, and doing QA on them to understand exactly why they failed internally is going to be very expensive in time/equipment. Perhaps the card vendor has a guarantee/warranty process where you can return the card for replacement?
Edit: Why is this going to moderation!
2017-05-11 01:46 PM
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?
2017-06-06 06:53 AM
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.