Electrical – microSD Class 4 card in SPI mode returns 0x000000021F after `CMD8`

fpgasd

I am trying to read an microSD card through an unbranded SD slot and a Basys3 FPGA. The microSD card, Kingston microSD HC 8GB Class 4, is used via an SD card adapter, also Kingston.

I am having trouble with getting past CMD8 of the initialization process. After I sent CMD0 it responded with 0x01 which is normal. After CMD0 I sent the CMD8 command; it responded with 0x000000021F. I wasn't able to find anything related to this code in any documentation.

To test, I tried using a SanDisk Ultra SDHC 32GB Class 10 with the same code. It successfully initialized.

Other things I have tried:

Please help.

Waveforms

The first one shows all of the initialization process. SD_CD is Card Detect (Active Low) and SD_WP is Write Protect (Active Low). SD_CLK is running at 390 kHz, 256 times slower than _cpuClock. Please note that the SD_MISO, SD_CD, SD_WP and _cpuClock are all simulated manually (i.e. doesn't receive any signal from the SD module). After card is detected, 1 millisecond is waited, followed by 74 SD_CLK's.

enter image description here

The second image is a zoom in of CMD0 and its response.

enter image description here

The third image is a zoom in of CMD8 and its response.

enter image description here

The final image is a zoom in of CMD55 and its response.

enter image description here

Update 1 (Prior to @Annoymous Answer) I managed to get my hands on a couple more cards. After testing it seems that only SanDisk Class 10 SDHC (both SD and microSD) returns an initialization finished state. The Kingston Class 4 SDHC SD returns a timeout after CMD0 while the Kingston Class 4 SDHC microSD returns a 0x000000021F. Changing the adapter made no difference in all cases. In the image below, the successful ones are in green and the unsuccessful ones are in red.

enter image description here

Update 2 (Response to @Annoymous Answer) After changing MOSI from posedge to negedge, the Kingston Class 4 SD card seems to initialized (which was previously timeouted). However, the Kingston Class 4 microSD card still respondsed with 0x000000021F.

Best Answer

Attached CMD8 picture shows normal response 1AA (2.7 - 3.6 V, and check pattern AA).

Several notes on things I see:

  • do not start command immediately after you activate CS. Wait 8 spare clock cycles, and only then start the command;
  • same at the end. Do not deactivate CS just after you think you got complete response for the command. Perform 8 more spare clock cycles before you deactivate CS;
  • I am not sure but pictures show that you put data onto the SD-card inputs on positive edge of the SD-card clock. As I recall SD-card latches data on positive edge of its clock, thus putting data there at the same time may violate timing. In my implementation, if I recall properly, I put data onto SD-card input lines on negedge, so that it samples it on next posedge.