AnsweredAssumed Answered

Unable to mount a µSD card with STM32F7 (FR_DISK_ERR)

Question asked by A guy on Jun 21, 2018
Latest reply on Jun 21, 2018 by A guy

Hi everyone,


I went through a lot of discussions regarding SD card issues this past few days, but even with that I was unable to solve my problem.

I am trying to write file(s) to an SD card but I am always getting an FR_DISK_ERR, either in f_mount if I choose to mount instantly, or with f_open if I choose to mount later.

I have tried to use different SD card (SD 2Go/GB, SDHC 16 & 32Goa and SDXC 64Go but it always ends up with the FR_DISK_ERR.

I have tried those SD cards on two different STM32F769NI discovery boards and two identical custom board with an STM32F769BI microcontroller.


The error happens when the disk_read function is called(f_mount instantly - find_volme - check_fs - move_window- disk_read), disk_read fails and in the comment it's written "invalidate window if data is not reliable"). So move_window return 4, so does check_fs and finally find_volume returns FR_DISK_ERR.

 However in debug I can also see that there is a problem with SD_read in sd_diskio.c. At the line 206 there is "      while((HAL_GetTick() - timeout) < SD_TIMEOUT)   " and this lead to HardFault_Handler.


Finally in SDMMC2 - STA register, RXOVERR is checked ("Received FIFO overrun error").


 I used Cube MX to generate the code. My configuration is STM32F769NI or BI, FATFS, SDMMC2, 1 bit SD Mode, RCC (HSE), and I15 input pin to detect SD card.


In main.c the code is :








        if(f_mount(&SDFatFS, "", 1) == FR_OK)


            if (f_open(&SDFile, "lscp.txt", FA_CREATE_ALWAYS|FA_WRITE)==FR_OK)




                    return 0;// success



                    return -4;  //close failed



                return -3; // open failed



            return -2;    // mount failed



        return -1;

    }// SD init failed


 If someone has a project mounting SD card with an F7 discovery board please share it so that I can try it to see it what is wrong.


PS: I tried the USB Host example where the USB is used to write on the SD card but even it the card appears in my PC it's impossible to write on it because as soon as I try to do that the card is disconnected from the PC and then connects itself back again.


Thanks a lot for you help !