SDIO with STM32L4 (Nucleo-64 board)

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
jms23134
Posts: 1
Joined: Thu Mar 17, 2016 12:12 pm

SDIO with STM32L4 (Nucleo-64 board)

Post by jms23134 »

Hi,
First of all, let me congratulate you Giovani for your excelent work with ChibiOS RTOS.
I am developing an application with an SD card and I was using the SPI peripheral to read/write the card. But now with this new board, I was trying the SDIO interface (4 bits), but unfortunately I was unable to read or write from the card. The SD cards are 8GB class 10 and 8GB class 4.

So is there any particular option to set in this microcontroller to make this working properly?
Thanks in advance for your help.

I attached the chibios project that I was using. It is adapted from the STM32F4 discovery board. To test the code, the CHIBIOS var in makefile must be set to the proper path (I am using chibios 16.1.4).
In this particular board, I had to set the SDIO pins to their alternate functions (12, according to the datasheet)

palSetPadMode(GPIOC, 11, PAL_MODE_ALTERNATE(12));
palSetPadMode(GPIOD, 2, PAL_MODE_ALTERNATE(12));
palSetPadMode(GPIOC, 12, PAL_MODE_ALTERNATE(12));
palSetPadMode(GPIOC, 8, PAL_MODE_ALTERNATE(12));
palSetPadMode(GPIOC, 9, PAL_MODE_ALTERNATE(12));
palSetPadMode(GPIOC, 10, PAL_MODE_ALTERNATE(12));

The shell outputs the following text after sending this command "sdc all".

ChibiOS/RT Shell
ch> sdc all
Connecting... failed
ch> sdc all
Connecting... failed
ch> sdc all
Connecting... failed
ch> sdc all
Connecting... OK

Card Info
CSD : 400E0032 5B590000 3B377F80 0A4040AE
CID : 03534453 4C303847 8029795F 7100F89C
Mode : SDV20
Capacity : 7580MB
Single block aligned read performance: failed
ch> sdc all
Connecting... failed
ch>
Attachments
SDC_L4.zip
Project file for the STM32L4 to test the SDC interface
(15.23 KiB) Downloaded 261 times
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SDIO with STM32L4 (Nucleo-64 board)

Post by Giovanni »

Hi,

It is hard to test for me, I have not a connector to attach. You could try to step in sdcConnect() and see where it fails.

Note that a common problem are wires, this happened a lot in the past using SDIO. Another source of problems is card clock, you could try to measure it.

Giovanni
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: SDIO with STM32L4 (Nucleo-64 board)

Post by rew »

Yeah. Sounds very much like a "hardware problem". Think clock signals not working (e.g. a whip like effect can clock the stuff on the other end twice on each clock cycle), or corruption on the data lines.
Post Reply