Is there a comprehensive SD card SPI command reference? - Page 1
Forum section: electronics / general

author: Dan Moos
author_rank: Frequent Contributor
timestamp: July 26, 2020, 10:08:25 pm
content: 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.htmlTo 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.

author: amyk
author_rank: Super Contributor
timestamp: July 27, 2020, 01:17:55 am
content: Look at the official SD card spec.

author: Dan Moos
author_rank: Frequent Contributor
timestamp: July 27, 2020, 02:50:36 am
content: 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.

author: lucazader
author_rank: Regular Contributor
timestamp: July 27, 2020, 02:54:06 am
content: 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

author: Peabody
author_rank: Super Contributor
timestamp: July 27, 2020, 02:50:54 pm
content: 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.

author: westfw
author_rank: Super Contributor
timestamp: July 27, 2020, 10:13:17 pm
content: QuoteYeah; that. :-(

author: amyk
author_rank: Super Contributor
timestamp: July 28, 2020, 12:40:27 am
content: Quote from: lucazader on July 27, 2020, 02:54:06 am...and those who know how to search"SD specifications part 1 physical layer ver3.00"

author: Dan Moos
author_rank: Frequent Contributor
timestamp: July 28, 2020, 02:58:45 am
content: YES!

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: July 28, 2020, 09:29:44 am
content: My favourite site:http://elm-chan.org/docs/mmc/mmc_e.htmlThere are many, many more treasures there... :-)