Getting started with FAT Filesystem on SD/MMC cards over SPI

Sebastian Huber sebastian.huber at
Thu Sep 25 07:04:00 UTC 2008

Robert S. Grimes wrote:
> Hi Sebastian,
> I'm having some success, but of course, not total!
> I haven't powered on my oscilloscope to verify that way, but I do think 
> I've got your spi-sd-card.c driver talking with my powerpc/virtex SPI 
> driver, in that I'm getting some believable data, before it breaks. What 
> I did was start with the MPC5566EVB init code you mentioned:
> c/src/lib/libbsp/powerpc/mpc55xxevb/startup/sd-card-init.c
> and customized it to talk via my SPI driver. I finally got things to 
> build execute, at least to the following point, which is output from the 
> spi-sd-card.c driver:
>     sd_card_driver_init: *** Card Identification ***

Every card that I tested so far (~10 different cards) and came to this
point worked.

>     sd_card_driver_init: Manufacturer ID : 3
>     sd_card_driver_init: OEM/Application ID : 21316
>     sd_card_driver_init: Product name : S1G€
>     sd_card_driver_init: Product revision : 0
>     sd_card_driver_init: Product serial number : 2696421888
>     sd_card_driver_init: Manufacturing date : 136
>     sd_card_driver_init: 7-bit CRC checksum : 27
>     sd_card_send_command: Error: Command error [07]: 0x7f
>     sd_card_send_command: Error: Response: ff:ff 49:ff 00:ff 00:ff 00:ff
>     00:ff 95:82 ff:[7f] ff:ff ff:ff f
>     f:ff ff:ff ff:ff ff:ff ff:ff ff:ff ff:00 ff:00

The response output format is: <transmitted byte>:<received byte>.  The
[XX] indicates the unexpected or error position in the response.

The 49 00 00 00 00 95 is the SD_CARD_CMD_SEND_CSD command (95 is the
CRC7 of the SD_CARD_CMD_GO_IDLE_STATE command because CRC calculation is
disabled by default in SPI mode and this is the only command prior SPI
mode).  I do not know why your card responds in that way.  You may
consult the manual if the initialization sequence and supply voltage is
correct.  You can modify the code to ignore some response errors and
look how far you come with that.

>     sd_card_driver_init: Error: RV = -27: Send: SD_CARD_CMD_SEND_CSD

You can turn on more debug output if you define DEBUG before including

> Looking at the SanDisk manual seems to suggest the first two fields are 
> correct (Man. and App IDs), and the Man Data corresponds to August 2008, 
> which makes sense (I just bought the card last week). The Product name 
> looks semi-sensible - it is a 1 GB SD Card.
> [...]

Sebastian Huber, Embedded Brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at
PGP     : Public key available on request

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

More information about the users mailing list