2017-08-02 01:17 AM
Hello, the STM Community !
I recently update all my libraries in my project, including the FatFS library, and the bsp_driver_sd.c.
I also followed this page :
https://community.st.com/docs/DOC-1546-cubemx-sdio-dma-fatfs-configuration
to configure everything properly, so the code in my library is exactly like in this page.
In my project, I have two main parts :
- a selftest, which I use to check that all the components of my board are working properly
- the firmware
So whatever I work with, the libraries that are used are the exact same, it's the same files. Only the user's application files change.
When I decide to compile the selftest, and to run it, my uSD card works fine, without any issue. I mount :
f_mount(uSD_fatfs, _T(''0:''), 1);
open :
f_open(&file, _T(''0:test.uSD''), FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
write :
f_write(&file, test_uSD, test_length, &bytesRead);
And everything's fine.
But for the firmware, even though I use the same lines, the same opening options, and the f_open returns FR_OK, the first f_write will fail, because of a timeout in the very first call of BSP_SD_WriteBlocks_DMA().
Here is the call stack :
With the selftest, when I'm in this position in the code, with the very same call stack, with the same arguments for the address (40960) and the NumOfBlocks (1), there is no problem, no timeout. But with the firmware, which is initialized in the same way, with the same library, the HAL_SD_GetState() function always returns HAL_SD_STATE_BUSY after the call of HAL_SD_WriteBlocks_DMA(), so the timeout threshold is reached (SD_WAIT_TIMEOUT = 0xFFFFFF).
After this, impossible to close the file, so impossible to open it again and try again, so impossible to recover. Unmounting the uSD is not a solution, because in the future, some other files could be open as well.
I spent two days on this, trying to make either the firmware work, either the selftest not work, to understand the difference, but so far, no good result.
Does anyone have an idea about the reason why I have this timeout ?
Thank you.
Antoine
#timeout #stm32f4 #dma #sd-card