[SDIO] SD2.0 protocol analysis summary (1) - Introduction to the basic probability of SD card

related articles

"[SDIO] Index of articles related to SDIO, SD card, FatFs file system"

1 Introduction

Since the currently used hardware platform STM32 only supports SD2.0 , the following introduction mainly refers to the study summary of "Part1_Physical_Layer_Simplified_Specification_Ver2.00.pdf" .

2. Introduction to SD Card

SD card (Secure Digital Memory Card) is very common in our lives. There are generally two communication interfaces for the controller to read and write communication operations on the SD card, one is the SPI interface, and the other is the SDIO interface. The full name of SDIO is a secure digital input/output interface. Multimedia cards (MMC), SD cards, and SD I/O cards all have SDIO interfaces. The SD I/O card itself is not a card used for storage, it refers to a peripheral device that uses the SDIO transfer protocol. For example, Wi-Fi Card, which mainly provides Wi-Fi function, some Wi-Fi modules use serial port or SPI interface for communication, but Wi-Fi SDIO Card uses SDIO interface for communication.
Insert picture description here
SD cards are classified by memory capacity as follows:

Abbreviation Full name Capacity SD version
SDSC Standard Capacity SD Memory Card <=2GB Version 2.0 or higher
SDHC High Capacity SD Memory Card 2GB~32GB Version 2.0 or higher
SDXC Extended Capacity SD Memory Card 32GB ~ 2TB Version 3.0 or higher
SDUC Ultra Capacity SD Memory Card 2TB~128TB 8.0 or above

The bus speed modes are classified as follows:

SD version Bus speed Bus interface
2.0 Maximum speed < 25 MB/sec 1. Support 4 3.3V data lines High Speed mode
3.0 Maximum speed < 104 MB/sec 1. Support 4 3.3V data lines in High Speed mode
2. Support 4 1.8V data lines in UHS-I mode
6.0 Maximum speed < 6.24Gbps per lane 1. Support 4 3.3V data lines High Speed mode
2. Support 4 1.8V data lines UHS-I mode
3. Support UHS-II, UHS-III different interface bus modes
8.0 Maximum speed < 3938MB/s 1. Support 4 3.3V data lines High Speed mode
2. Support 4 1.8V data lines UHS-I mode
3. Support UHS-II, UHS-III different interface bus modes
4. Support PCIe Gen 4 2 lanes different Interface bus mode

3. SD bus Pin and Register distribution

One sheet SD cardIt includes 5 parts: storage unit , storage unit interface , power detection , card and interface controller and interface driver . The storage unit is a data storage component. The storage unit performs data transmission with the card control unit through the storage unit interface; the power detection unit ensures that the SD card is working at a suitable voltage. If there is a power failure or an up state, it will cause the control unit and Unit interface reset; 5 parts of the card and interface control unit control the running state of the SD card, which includes 8 registers; the interface driver controls the input and output of the SD card pins.

  • The functional block diagram of the SD card is as follows:

The pin of the SD card is defined as follows:

  • The functional block diagram of the microSD card is as follows:

The pin definition of the microSD card is as follows:

  • SD card registers have a total of 8 registers, which are used to set or represent SD card information, as follows:
name bit width description
CID 128 Card identification number (Card identification number): the individual number of the card used to identify (unique)
RCA 16 Relative card address: The card's local system address, which is dynamically suggested by the card and approved by the host during initialization
DSR 16 Driver Stage Register: configure the output driver of the card
CSD 128 Card Specific Data: Information on the operating conditions of the card
SCR 64 SD Configuration Register: SD card special characteristics information
OCR 32 Operation conditions register
SSR 512 SD Status: Information about the unique characteristics of the SD card
CSR 32 Card Status: Card status information

4. SD bus protocol

The communication on the SD bus is based on Command and Data transmission, initiated by a start bit ("0") and terminated by a stop bit ("1"). SD communication is generally that the host sends a command (Command), and the slave device responds (Response) after receiving the command. If necessary, data (Data) transmission will participate.

  • Command: Command is the token that initiates the operation. Command is sent from the host to a single card (addressing command) or all connected cards (broadcasting command). In Command CMD data line serial transmission on.
  • Response: Response is a token, which is sent from an address card or from all connected cards to the host as a response to the previously received command. Response in the CMD data line serial transmission on.
  • Data: Data can be transferred from the card to the host or vice versa. Data is transmitted through the DAT data line .

4.1 Introduction of SD bus CMD and DATA interaction

The basic interaction of SD bus is command and response interaction, as shown in the following figure:

SD dataIt is transmitted in the form of block (Black) . The data block length of SDHC card is generally 512 bytes, and the data can be from the host to the card or from the card to the host. The data block requires CRC bits to ensure successful data transmission. The CRC bit is generated by the SD card system hardware. The following figure shows how the host writes data blocks to the SD card :

SD dataTransmission supports single-block and multi-block reads and writes, which correspond to different operation commands, and multi-block writes also need to use commands to stop the entire write operation. It is necessary to check the busy status of the SD card before writing data, because the process of programming the SD card to the storage area after receiving the data requires a certain amount of operating time. The SD card busy state is indicated by pulling down the D0 line .

The data block read operation is similar, except that no busy state detection is required.

4.2 Command format of SD bus Command and Response

  • The command token format is as follows:

The actual waveform of CMD8 captured by the logic analyzer is as follows:
Insert picture description here
each Command has a start bit (0) in front of it, and an end bit (1) in the back, and the total length is 48 bits. Each Command is protected by a CRC bit, so that transmission errors can be detected and the operation can be repeated.

  • Response length 48 or 136 bit, depending on theR1, ,R2...R3Content of size, will be detailed later in the definition of Command and Response. The response token format is as follows:

In the CMD data line , the most significant bit (MSB) is transmitted first, and the least significant bit (LSB) is transmitted last.

4.3 SD Bus Data Packet Format

When using 4 data lines for transmission, each transmission4bitFor data, each data line must have a start bit , a stop bit and a CRC bit . Each data line of the CRC bit must be checked separately, and the check results shall be summarized and then fed back to the host through the D0 line after the data is transmitted .

SD card data packageThere are two formats, one is a conventional data (8bit wide), which then send the starting low byte high byte and each byte is the low starting high recurrence, or a schematic view of the transmission line 14 as follows:
Insert picture description here
4 Line synchronous transmission, each line sends two bits of a byte, the data bits are arranged in the order of four lines and sent, the DAT3 data line sends the higher bit, and the DAT0 data line sends the lower bit.

Another data packet sending format isWide packetFormat, the SD card for data packet transmission Wide embodiment is directed to an SD card SSR(SD 状态)寄存器transmission content, SSR 寄存器total 512bit, issued in the host ACMD13 SD card command SSR 寄存器content to the host through the DAT line. The schematic diagram of the wide data packet format is shown in the figure below: The actual waveform diagram of the data transmitted by the SD card
Insert picture description here
captured by the logic analyzer is as follows:
Insert picture description here

5. References

The information referenced by SDIO is as follows: The
Insert picture description here
download address is as follows:
https://download.csdn.net/download/ZHONGCAI0901/14975835

Guess you like

Origin blog.csdn.net/ZHONGCAI0901/article/details/113190393