SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Post Reply
k_vijay
Posts: 20
Joined: Mon Apr 04, 2022 7:06 am

SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by k_vijay »

Hello Team,

I want to integrate the micro sd card reader for my application to detect/read/write/erase of the SD card.

Which driver should i use to proceed ahead 1. SDCD1 or 2 MMCDriver ?

Details of hardware is using.

STM32 Board :: STM32F4029disc-1
MicroSD Card Adaptor :: CATALEX MicroSD Card Adaptor. This SD Card reader has 6 pins (CS,MISO,MOSI,SCK,VCC,GND).

What should be the connection between STM32 board and this SD Card adaptor ?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by Giovanni »

Hi,

That adapter requires an SPI port not SD/MMC ones. The driver you need is "MMC_SPI" which wraps the SPI port driver. An example is in RT-STM32F103-OLIMEX_STM32_P103-FATFS.

Giovanni
k_vijay
Posts: 20
Joined: Mon Apr 04, 2022 7:06 am

Re: SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by k_vijay »

Hello Sir,

In the file "chibios203/os/various/fatfs_bindings/fatfs_syscall.c" there is include present "ff.h" and at the time of compilation it is saying "ff.h" no such file or directory.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by Giovanni »

Hi,

It is part of FatFS, you need to unzip it under /ext

GiovanniHi,
k_vijay
Posts: 20
Joined: Mon Apr 04, 2022 7:06 am

Re: SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by k_vijay »

Hello Sir,

This issue is solved.

I want to know about the mapping of pins between MMC driver and SPI ?

I mean MMC driver is using which SPI whether SPI1 or SPI2 or any other for STM32f429 disc board ?
k_vijay
Posts: 20
Joined: Mon Apr 04, 2022 7:06 am

Re: SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by k_vijay »

Hello Sir,

mmcIsCardInserted(&MMCD1) always return TRUE, whether SD is available or not doesn't matter.

What may be the root cause for this ?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by Giovanni »

Look in board.c, there is a function to be implemented for card detection, the implementation depends on where you connect the card detection pin of your connector, usually a free GPIO pin, you may need a pull-up resistor too.

Giovanni
k_vijay
Posts: 20
Joined: Mon Apr 04, 2022 7:06 am

Re: SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by k_vijay »

Hello SIr,

Now I have understood why "mmcIsCardInserted" function returns always true.
Now I have added a gpio to detect the card insertion/remove event. But now the issue is coming in mmcConnect().

It is going in infinite while loop in wait function which is called from "send_hdr()".

Can you please suggest the steps in order to established the communication from MCU to SD Card via chibios.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: SD Card Integration || MicroSD Card Adaptor || STM32F4029disc-1

Post by Giovanni »

Apparently the card is not answering, the cause could be anything, I can't tell from here.

Consider that the driver could not support all kind of cards, it is quite old and modern high speed cards could not work at all in SPI mode.

Giovanni
Post Reply