cancel
Showing results for 
Search instead for 
Did you mean: 

SD Card On SDIO, Command Response fails after ACMD 41

slagment
Associate II
Posted on February 29, 2012 at 22:19

The original post was too long to process during our migration. Please click on the attachment to read the original post.
16 REPLIES 16
hpipon957
Associate III
Posted on March 03, 2012 at 00:42

Hi

Check the errata for the STM32F4xx - there are two points to respect when working with the SDIO.

The response to CMD41 doesn't include a CRC (this is normal) but the SDIO will flag a CRC error. This needs to be ignored in the code when the response is received.

The second errata is that the HW flow control when reading/writing data has a glitch problem and the recommended workaround is to disable this and handle overruns/overruns at the application level. This however leads to high overhead and a bit of a mess and I found that I could leave it enabled when reading and disable it only when writing and ensuring that the write loop couldn't be interrupted, avoiding awkward handling of such underruns/overruns at a higher level.

You can get SDIO code (and SPI based driver) together with FAT (with LFN support) in the uTasker project - it supports USB-MSD (allowing the SD card to be used as an external disk drive by a PC) [on F4 but not on F1 because the USB driver is quite different] as well as a DOS like command line interface via UART, TELNET and/or USB-CDC. The SD card can be used together with a web server (for big web sites) and maintained via FTP. It also supports SW updates when the SD card is inserted with a new software on it (serial loader - also supports SW upload via UART, web browser, FTP or USB-MSD).

Finally its simulator allows SD card operation to be simulated, making learing SD card operation, FAT much easier, as well as developing full applications based on it and other resources.

There are some videos of these in operation (not necessaryily on STM but they work there the same):

http://www.youtube.com/watch?v=H4TYM9jY2-g

http://www.youtube.com/watch?v=2Rbz1SOoJVI

search on youtube for ''uTasker'' for various others.

The utFAT (supports FAT16/FAT32 on SPI or SDIO of various processors, including STM32F1..4) is documented here:

http://www.utasker.com/docs/uTasker/uTasker_utFAT.PDF

The project works with GCC, IAR, Keil, Atollic and Rowley Crossworks.

Regards

Mark

uTasker project:

http://www.uTasker.com

slagment
Associate II
Posted on March 09, 2012 at 19:06

Thank you for the information. uTasker looks interesting, but I need to get my could working.

I'm not checking the crc flag, and haven't transferred any data.  I'm must trying to initialize.

I casted the response to uint8_t and now it shows:

CMD 0 Resp1 -0

CMD 55 Resp1 -32

CMD 41 Resp1 - 0  and getcommand returns 63

CMD 2 Resp1 -0  and getcommand returns 63

CMD 3 Resp1 -0  and getcommand returns 63

thank you

hpipon957
Associate III
Posted on March 10, 2012 at 17:05

Hi

I don't know what the response codes mean (you will need to look up the values that can be returned from the calls).

However, note that the SD card responds very slowly during the initialisation phase and so will be returning ''busy'' quite often. The busy case means that you need to retry again after a short pause until it can finally return the correct answer.

Regards

Mark

torturecell
Associate II
Posted on May 19, 2012 at 18:49

Hello jeff,

Did you get any solution for your problem.

I am facing exactly the same problem as you have mentioned. I will really appreciate if you can give me some pointers to solve it.

regards

sam

bjfree
Associate II
Posted on May 21, 2012 at 12:42

I am working on understanding SDIO, so I thought I would use your problem to trouble shoot.

cmd 55 return 0x37

from stm32f4xx_sdio.h

that is an ored response of

SDIO_FLAG_CCRCFAIL

SDIO_FLAG_DCRCFAIL

SDIO_FLAG_CTIMEOUT

SDIO_FLAG_TXUNDERR

SDIO_FLAG_RXOVERR

what that all means I have yet to learn.

so finding out why this command had these errors is where I would start.

might I suggest you change you print out of returns in Hex.

it is easier to look up.

bjfree
Associate II
Posted on May 21, 2012 at 12:44

I am working on understanding SDIO, so I thought I would use your problem to trouble shoot.

cmd 55 return 0x37

from stm32f4xx_sdio.h

that is an ored response of

SDIO_FLAG_CCRCFAIL

SDIO_FLAG_DCRCFAIL

SDIO_FLAG_CTIMEOUT

SDIO_FLAG_TXUNDERR

SDIO_FLAG_RXOVERR

what that all means I have yet to learn.

so finding out why this command had these errors is where I would start.

might I suggest you change you print out of returns in Hex.

it is easier to look up.

bjfree
Associate II
Posted on May 21, 2012 at 13:28

though my modifications don't change the results of the code, I used

SDIO_StructInit(&SDIO_InitStructure);//set to default

so that if upgrade to the library the structure is filled. then

SDIO_InitStructure.SDIO_ClockDiv = 120;//SDIO_INIT_CLK_DIV;

SDIO_Init(&SDIO_InitStructure);

I followed the same for each command.

    SDIO_CmdStructInit(&SDIO_CmdInitStructure);//set default

    SDIO_SendCommand(&SDIO_CmdInitStructure);

    SDIO_CmdStructInit(&SDIO_CmdInitStructure);//set to default

    SDIO_CmdInitStructure.SDIO_CmdIndex = 55;

    SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;

    SDIO_SendCommand(&SDIO_CmdInitStructure);

since one of the errors is a time out I am wondering about

SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;

should be

SDIO_Wait_IT

Note: 1 After a data write, data cannot be written to this register for three SDIOCLK (48 MHz) clock

periods plus two PCLK2 clock periods.

bjfree
Associate II
Posted on May 21, 2012 at 21:06

SDIO_CmdInitStructure.SDIO_CmdIndex = 55;

seems to be decimal but the code expect hex.

the register for Index is 6 bits so max index is 0x40

Index CMD55 Abbreviation is APP_CMD =0x37

if the Return has errors you should not do the next SDIO_SendCommand.

To regress a bit, there should be code to check the status of the Card before this is started.

bjfree
Associate II
Posted on May 22, 2012 at 01:27

not sure if the same person but they believe they found the problem

http://forum.sparkfun.com/viewtopic.php?f=11&t=31759

I also came across code that seems to be a full implementation.

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/19078/stm32_eval_sdio_sd.c