This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SD Card Lock / Unlock

I am trying to add support for the SD card  lock / unlock feature using a C5515.  I have some code based loosely on the CSL MMC_write routine.  Unfortunately, I'm consistently getting a CRCWR error, which I find surprising.

Essentially, the pseudo-code is:

1) Send SET_BLOCK_LEN to change the block length for the password data.  Wait for response.

2) Reset the FIFO, and set it up.

3) Send CMD 42 (0x282A) with zero for arguments. 

4) While bytes remain, push onto FIFO if it is not full.

5) Wait for RSPDNE.

When ST0 has RSPDNE set, it consistently also has CRCWR set.

Does anyone have any experience with implementing this feature they would like to share?

 

  • I figured out the problem.  It seems that the command to set the bus width to 4 bits (ACMD6) is illegal when the card is locked.  I was trying to send the password information using 4 bit mode, assuming that ACMD6 had succeeded.  I've since broken that code into a separate function which I execute after unlocking the device, and everything works well.