Author Topic: Is there a comprehensive SD card SPI command reference?  (Read 1641 times)

0 Members and 1 Guest are viewing this topic.

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: us
Is there a comprehensive SD card SPI command reference?
« on: July 26, 2020, 10:08:25 pm »
Before the inevitable links to existing libraries are posted, understand, I specifically DO want to re-invent the wheel. This is for my own education.

Working on a home rolled sd card interface using SPI. Haven't found a comprehensive description of the various arguments the command set takes. Best I've found is this : http://www.chlazza.net/sdcardinfo.html

To understand my issue, look at the description of cmd8 in my link. It tells you which parts of the argument bit field are for what info, but nothing about what valid arguments exist. In this case, I know from other places that 0x01 written to bit 7-8 is the correct supply voltage argument I need, but I'm looking for a comprehensive explanation of ALL the valid arguments. I found the 0x01 argument randomly on a different site, with no explanation of where it came from.

I don't want to put magic numbers in my code. I want to know where they came from.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8276
Re: Is there a comprehensive SD card SPI command reference?
« Reply #1 on: July 27, 2020, 01:17:55 am »
Look at the official SD card spec.
 

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: us
Re: Is there a comprehensive SD card SPI command reference?
« Reply #2 on: July 27, 2020, 02:50:36 am »
Been looking for that. Can't find it. Literally typed "official sd card spec" in google just now. Found an official Sandisk page with no relevant info. Nothing else.

I've found lots of physical spec pages, but nothing that lays out comprehensively the SPI interface. I'm sure I suck at Googling, but I assure you its not for lack of trying.
 

Offline lucazader

  • Regular Contributor
  • *
  • Posts: 221
  • Country: au
Re: Is there a comprehensive SD card SPI command reference?
« Reply #3 on: July 27, 2020, 02:54:06 am »
Here is the simplified specifications from the SD card association.
I think the full specs are only available to association members.

https://www.sdcard.org/downloads/pls/index.html
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Is there a comprehensive SD card SPI command reference?
« Reply #4 on: July 27, 2020, 02:50:54 pm »
I wrote an SD card bootloader for a couple MSP430 controllers without using a library, and in assembler.  I was struck by this lack of information on what exactly is going on.  In the end, I just used the same magic numbers everybody else uses.  For each command, you send certain parameters, and you get back certain responses.  CMD8 is always sent the same way, but it's not clear what it means.  And as far as I can tell, it all works pretty well in the end.  I found the attached flow chart which was very helpful in dealing with the various kinds of cards you may need to handle.  But I think it only goes up through SDHC.

I would just say that based on my experience, which was limited to only SD and SDHC, and FAT16 and FAT32, this is not a trival thing to write.  You have the differences in card types, and the differences in the file systems that have to be dealt with.  And magic numbers have their benefits.
 
The following users thanked this post: ebclr

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Is there a comprehensive SD card SPI command reference?
« Reply #5 on: July 27, 2020, 10:13:17 pm »
Quote
the full specs are only available to association members.
Yeah; that.  :-(
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8276
Re: Is there a comprehensive SD card SPI command reference?
« Reply #6 on: July 28, 2020, 12:40:27 am »
Here is the simplified specifications from the SD card association.
I think the full specs are only available to association members.

https://www.sdcard.org/downloads/pls/index.html
...and those who know how to search ;)

"SD specifications part 1 physical layer ver3.00"
 
The following users thanked this post: Dan Moos, lucazader

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 357
  • Country: us
Re: Is there a comprehensive SD card SPI command reference?
« Reply #7 on: July 28, 2020, 02:58:45 am »
YES!
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
Re: Is there a comprehensive SD card SPI command reference?
« Reply #8 on: July 28, 2020, 09:29:44 am »
My favourite site: http://elm-chan.org/docs/mmc/mmc_e.html



There are many, many more treasures there... :-)
The further a society drifts from truth, the more it will hate those who speak it.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf