within my project I am using a nrf52840 and attached a SD card that is communication through the SDBlockDevice and SPI interface. While the SD communication and operations like rear, write, erase work all flawlessly I am having an issue with the SDBlockDevice Init function - especially in Bootloader mode. It is working and always ends with 0 but it takes about 5 seconds to complete the initialization. Is it an expected behavior? If I ran init again from my application (after bootloader was successfully passed) initialization of the blockdevice is immediately finished. I wonder if there is something else that I need to do before initializing the SDblockDevice? Anyone else experiencing this behavior?
I have run it on 3 different test boards - all with the same result. My code looks basically like this:
It is the default timeout which Mbed OS uses to wait for SD response. Maybe following this macro in the source code will be helpful.
By the way, I experience the same, it seems that MCU is able to initialize before the SD card and needs one failing attempt to init it, if I restart the device without removing power supply SD starts immediately.
Thank you for the hint!!! I will play with the timeout a bit.
What you have described is also exactly the behavior I am facing too. When restarting without removing power supply the SD starts right away. I was wondering if this is the preferred behavior and/or if there is a specific setting for certain MCUs to avoid that 5 second delay?
If you need a faster startup, maybe you can play with timeout and retry attributes. In my case, 5 seconds delay for first startup is not a problem, I think it depends on your application!
Changes in the timeout (e.g. setting the macro within custom_target.json to 2000) seem to be skipped or macro not accepted during compilation. A fast startup for my application is crucial. Up to a second delay (for SD BD init) would be ok but everything above is out of parameter I would wish for.
Had a typo. Changing the timeout and the retries solved this one for me. I would just want to understand the impact of it a bit better as I believe that there must be a reason for the 5s timeout and 5 retries. Anyway - thank you a lot for your help with this! Really appreciate it.
I did already but the specifications (SD Host Controller Simplified Specification Ver4.20) on page 175 - card initialization - state a timeout of 1 second to exit the loop.