cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to initialize the SD card interface without a SD card being present?

GJohn
Associate II

The HAL SD Card initialization routines queries the uSD Card for various pieces of information

in the initialization routine. If a uSD card not present, the initialization fails. Further, this means that it is not possible to remove and replace the uSD card once the device has started running.

I'm using a STM32F429 device. Is anybody aware of a workaround for this limitation?

4 REPLIES 4
TDK
Guru

Initialization of an SD card requires it to be present in order to communicate with the device in order to read and set various parameters such as card size, clock speed, and number of data lines. Thus, it cannot be done if a card is not present.

If a card is removed a reinserted, the initialization needs repeated with the new card.

You could write code to do initialization only when a card is inserted, but if you're using the CubeMX generator, you must live within its limitations.

If you feel a post has answered your question, please click "Accept as Solution".
GJohn
Associate II

The uSD/SD cards were designed to be removable media. The way the HAL initialization routines were implemented, this capability is destroyed. I'm sure I'm not the first person to run up against this limitation. I am hoping that someone has written a set of routines this separates the driver and card initialization so that

the uSD/SD cards can be used as designed.

I get what you're saying, but the initialization requires a card. There's nothing to split up. Hook up a GPIO pin to detect if a card is present and gate the HAL_SD_Init calls behind that.
Without a card present, there is nothing that needs to be done.
If you feel a post has answered your question, please click "Accept as Solution".

@GJohn​ SD card sockets usually come with a "Card detect" pin, that mechanically latches to GND when SD card pussed inside the socket.

https://github.com/sparkfun/ESP32_Motion_Shield/issues/2

we dont need to firmware by ourselves, lets talk