cancel
Showing results for 
Search instead for 
Did you mean: 

Need help configuring SDIO to read SD card on STM32F405 using STM32CubeIDE.

DLim.16
Associate II

Hi,

I am trying to use the STM32F405 microcontroller to log data into an SD card using STM32CubeIDE. Specifically, this MCU from adafruit: https://www.adafruit.com/product/4382?gclid=EAIaIQobChMI3qONnpCJ5wIVD_DACh2XCQY7EAAYASAAEgL4QvD_BwE

I found a few resources online and integrated that into the my source code, which can be found in "main.zip". My SDIO and FATFS configurations are shown in the attached figures. I did not change anything under 'Set Defines'.

Regardless of whether I have an SD card in the MCU or not, the results are the same: the program doesn't go beyond the line of code that calls "f_mkfs". I would appreciate it if someone could help me troubleshoot this.

Thanks.

This discussion is locked. Please start a new topic to ask your question.
18 REPLIES 18

Formatted cards should not need MKFS, one should avoid using it at all until DISKIO layer read function is fully tested/validated.

Unfortunately I lack the will to trawl through broken code, especially from Cube.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
DLim.16
Associate II

Hi clive1,

Thank you for your answer!

I removed "f_mkfs" and my program gets stuck in the next line of code, which is 'f_open'. It fails to open/create a file.

Also, what did you mean by "until DISKIO layer read function is fully tested/validated"? How can I test/validate that function?

Thanks.

dbgarasiya
Senior II

you are missing sd card initializartion and configuring of bus width functin missing in you project

and according to @Community member​  , you do not need to use f_mkfs

Hi Dbgarasiya,

I thought the IDE already initialized the module after configuring it using the GUI in Device Configuration Tool. It even created a function call: 'MX_SDIO_SD_Init'.

Do you think maybe the module wasn't initialized properly? If so, what are the right function calls I should be using?

Thanks.

dbgarasiya
Senior II

BSP_SD_Init()

dbgarasiya
Senior II

bsp_driver_sd.c in this file

Hi Dbgarasiya,

I added that, but I am still getting the same result. Am I missing something else?

Thanks.

dbgarasiya
Senior II

you have not enable DMA, for rx and tx also

then try

Hi Dbgarasiya,

Looks like I can only choose to either use SDIO or SDIO RX & TX but not all three of them, otherwise I get an error say "No available DMA requests for this peripheral".

Was DMA required? I enabled both variations i.e. only SDIO and then only SDIO RX & TX, nothing worked. Let me know if I'm doing something wrong.

Thanks.