Skip to main content
Visitor II
June 2, 2021
Question

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

  • June 2, 2021
  • 2 replies
  • 1770 views

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?

    This topic has been closed for replies.

    2 replies

    Super User
    June 2, 2021

    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.

    GJohnAuthor
    Visitor II
    June 2, 2021

    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.

    Super User
    June 2, 2021
    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.