Skip to main content
Graduate
September 10, 2018
Question

SDIO timeout in ReadBlocks/WriteBlocks looks bogus

  • September 10, 2018
  • 4 replies
  • 1836 views

currently I'm implementing a sdio device in mbed-os for STM32F4. This is using the HAL and I had problems with setting the timeout for Read/Write Blocks.

This line looks bad for me:

https://github.com/ARMmbed/mbed-os/blob/920db63453b6aae7ccaa992fe7c9107f6664347f/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_sd.c#L592

The function is returning an error if timeout=0 is passed as argument. Reading or writing the blocks has no chance to succeed, if timeout is = it will fail. Usually, a timeout=0 means infinit waiting and the function should look like if ((timeout != 0) && (...)).

Is this right?

    This topic has been closed for replies.

    4 replies

    Graduate II
    September 10, 2018

    Yes, this doesn't look like the intent they wanted

    ST on occasions uses 0xFFFFFFFF (49.5 days), or 30 seconds for SDIO

    Honestly something like a second should be sufficient for SDIO were interactions should be taking less than 100ms

    JojoSAuthor
    Graduate
    September 10, 2018

    Thanks for your very fast reply.

    You are right, the timeout value should be something greater than 0, but a 0 should not return an error after a successfull read or write.

    The timeout should also depend on the amount of data, 1 MB takes much more time than 1 kB to write. The HAL function uses the timeout value for the whole operation, so the user application should calculate a size dependent limit.

    Graduate II
    September 10, 2018

    Arguably, the command/response time is very large compared to the data phase, and it's always fetching much large blocks from the array, don't expect time to be linear. The timeout loop is so you don't dwell there forever, but given the lack of downstream recovery/retry, somewhat moot.

    Visitor II
    February 20, 2019

    Hey @JojoS​ ,

    Just wanted to ask about this. Did you have the same issue with the timeout where the sdcard driver just seems to be stuck in there forever?

    I had constant successful reads and writes, but every once in a while, the sdcard driver will get stuck in what seems to be an infinite loop in the timeout when doing tasks like creating a file, reading,writing, etc.

    Visitor II
    March 6, 2024

    Hi @JojoS

    Facing the same issue as @con3 

    Our SD card read write works well for like minutes, but then it gets stuck and remains there till the MBED_CONF_SD_TIMEOUT value.

    Do you have any solution to this issue? We are observing that the SDIO DMA transfer is still ongoing, even though we see a STOP TRANMISSION CMD12 on the logic analyzer

    Visitor II
    March 15, 2024

    Hi, On observing the CLK & CMD lines of the SD card connected via the SDMMC interface to our STM32U5 board, could confirm that the commands were triggered at the falling edge of the clock.

    But on the SDMMC interface init settings, the setting for the sdmmc clock edge was Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING; so here was the error.

    On chaning the clock edge to SDMMC_CLOCK_EDGE_FALLING, all our previous errors related to write halts and timeout errors vanished! We are running at 4 MHz on the SDMMC interface..