Cannot detect SD card on STM32-P107 board

Started by laurentgom, September 25, 2012, 03:34:36 PM

Previous topic - Next topic

laurentgom

Hi

The SD_CARD code example always gives me a "Pls, Insert card" error.

I've tested it with two SD cards, and tried to get as much information as possible about what happens:

- With a 2GB non-HC card, the _SdInitMedia function returns _SdNoResponse at line 414 on the second iteration of the loop; the status returned by the _CMD58 command is 5 (IDLE_STATE + ILLEGAL_CMD). Note that, on both iterations, the _CMD8 command returns 9 (IDLE_STATE + CRC_ERROR).

- With a 4GB HC card, the 100 iterations of the loop inside the _SdInitMedia function complete, and thus _SdNoResponse is returned at line 452. _CMD8 also always returns 9 (IDLE_STATE + CRC_ERROR).

I also tried with another STM32-P107 board, to make sure that it was not broken. Same results.

LubOlimex

Hello,

Part of the test we do of STM32-P107 before shipping is testing the microSD card slot on hardware and software level.

Furthermore, I just used the Micrel example from the P107 page and it recognized both cards I used: http://i.imgur.com/ozquC.png

Note that the libraries for SD card handling get frequently updated and it is quite possible that updating sd_ll_spi1.h and sd_spi_mode.c (both dated 2008 in the demo project) with newer version would increase SD card compatibility and will lower the fail ratio.

Best regards,
Lub/OLIMEX

Technical support and documentation manager at Olimex

laurentgom

Thanks for the reply.

I confirm that the Micrel example from the P107 page, with no modification, directly compiled and downloaded to the board, doesn't work with our two SD cards. Are there known incompatibilities? Or is there a configuration or environment thing that could cause this kind of error?

We tried with the latest STM libraries (3.5.0), the results were the same.

In the meantime we also tried ChibiOS, and their SD card API works perfectly.

LubOlimex

Hello again laurentgom,

We corrected the spi library a bit. Now your card should be recognized you can get the replacing file from here:
https://docs.google.com/open?id=0B7WHuNCASY8cSVhfY0VxalkzaUk (File -> Download). The changed part is from the "SPP +" in a comment section.

There was a problem with cards which OCR register started with 1.

I have also updated the web page with the newer project.

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

laurentgom

Thank you very much for the fix :)

The 2GB non-HC card now works perfectly, however the problem for the 4GB HC card remains.