wire / wire-format / sd-card-protocol
SD cards use SPI or SD bus (1-bit or 4-bit). Initialization: CMD0 (GO_IDLE_STATE), CMD8 (SEND_IF_COND), ACMD41 (SD_SEND_OP_COND), CMD2 (ALL_SEND_CID), CMD3 (SEND_RELATIVE_ADDR), CMD9 (SEND_CSD), CMD7 (SELECT_CARD). Data transfer: CMD17 (READ_SINGLE_BLOCK), CMD18 (READ_MULTIPLE_BLOCK), CMD24 (WRITE_SINGLE_BLOCK), CMD25 (WRITE_MULTIPLE_BLOCK). Status: R1 (1 byte), R3 (5 bytes, for ACMD41), R7 (5 bytes, for CMD8).
aka: SD card protocol
spec: SD card specification
SD cards use SPI or SD bus (1-bit or 4-bit). Initialization: CMD0 (GO_IDLE_STATE), CMD8 (SEND_IF_COND), ACMD41 (SD_SEND_OP_COND), CMD2 (ALL_SEND_CID), CMD3 (SEND_RELATIVE_ADDR), CMD9 (SEND_CSD), CMD7 (SELECT_CARD). Data transfer: CMD17 (READ_SINGLE_BLOCK), CMD18 (READ_MULTIPLE_BLOCK), CMD24 (WRITE_SINGLE_BLOCK), CMD25 (WRITE_MULTIPLE_BLOCK). Status: R1 (1 byte), R3 (5 bytes, for ACMD41), R7 (5 bytes, for CMD8).
| field | size | meaning |
|---|---|---|
| CMD0 (GO_IDLE_STATE) | 6 bytes | 0x40 + arg (0) + CRC. Puts card in idle state. |
| CMD8 (SEND_IF_COND) | 6 bytes | 0x48 + arg (voltage + check pattern). Checks if card supports 3.3V and returns echo. |
| ACMD41 (SD_SEND_OP_COND) | 6 bytes | 0x69 (CMD41 with APP_CMD prefix 0x37). Initializes card. Arg: host capacity support (HCS) + voltage window. |
| CMD2 (ALL_SEND_CID) | 6 bytes | 0x42 + arg (0). Returns CID (Card ID, 128 bits). |
| CMD3 (SEND_RELATIVE_ADDR) | 6 bytes | 0x43 + arg (0). Returns RCA (Relative Card Address, 16 bits). |
| CMD9 (SEND_CSD) | 6 bytes | 0x49 + arg (RCA). Returns CSD (Card Specific Data, 128 bits: capacity, speed, etc.). |
| CMD7 (SELECT_CARD) | 6 bytes | 0x47 + arg (RCA). Selects card for data transfer. |
| CMD17 (READ_SINGLE_BLOCK) | 6 bytes | 0x51 + arg (block address). Reads one 512-byte block. |
| CMD24 (WRITE_SINGLE_BLOCK) | 6 bytes | 0x58 + arg (block address). Writes one 512-byte block. |
| R1 (response) | 1 byte | Status: in_idle_state, erase_reset, illegal_command, crc_error, erase_sequence_error, address_error, parameter_error. |
| CSD (Card Specific Data) | 16 bytes | Capacity, max speed, read/write block sizes, erase sizes, etc. |
| CID (Card ID) | 16 bytes | Manufacturer ID, OEM ID, product name, product revision, serial number, manufacturing date. |
example:
40 00 00 00 00 95
SD card: CMD0 (GO_IDLE_STATE) with CRC 0x95
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/sd-card-protocol
or /wire-format/sd-card-protocol.json