cancel
Showing results for 
Search instead for 
Did you mean: 

FATFS with SDRAM in STM32cubeIDE 1.3 cause STM32f746g-discovery to not responding

mohammadsd
Associate II

STM32f746g-Discovery have external SDRAM and I want to use it by FatFs.

Then I have enabled FMC in cubeIDE according to BSP (Board Support Package) driver [stm32746g_discovery_sdram.c][1], except one parameter "Write recovery time" which IDE does not allow me to set it on 2 and its minimum value is 3.

 then I have configured "FATFS->external SDRAM" middleware according to FatFs_RAMDisk project's [ffconf.h][2], Note this project also uses the same external SDRAM.

Now I'm trying to execute this code in main():

   FRESULT res;                                         /* FatFs function common result code */

     uint32_t byteswritten, bytesread;                    /* File write/read counts */

     uint8_t wtext[] = "This is STM32 working with FatFs"; /* File write buffer */

     uint8_t rtext[100];                                  /* File read buffer */

     if(FATFS_LinkDriver(&SDRAMDISK_Driver, RAMDISKPath) == 0)

       {

         /*##-2- Register the file system object to the FatFs module ##############*/

         if(f_mount(&RAMDISKFatFs, (TCHAR const*)RAMDISKPath, 0) != FR_OK)

         {

           /* FatFs Initialization Error */

           Error_Handler();

         }

         else

         {

           /*##-3- Create a FAT file system (format) on the logical drive #########*/

           if(f_mkfs((TCHAR const*)RAMDISKPath, FM_ANY, 0, buffer, sizeof(buffer)) != FR_OK)

           .

           .

           .

But it hangs on "f_mkfs". through debug i discovered it hang exactly on ff.c:

   if (disk_write(pdrv, buf, b_vol, 1) != RES_OK) return FR_DISK_ERR;   /* Write it to the VBR sector */

and further on sdram_diskio.c:

   DRESULT SDRAMDISK_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)

[There][3] is complete stm32cubeIDE 1.3 project.

 [1]: https://github.com/STMicroelectronics/STM32CubeF7/blob/master/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_sdram.c

 [2]: https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM32469I-Discovery/Applications/FatFs/FatFs_RAMDisk/Inc/ffconf.h

 [3]: https://1drv.ms/u/s!AjRo7Nr2rz_hieVt08nsAxzAhp9dmQ?e=u7eGvk

1 ACCEPTED SOLUTION

Accepted Solutions
mohammadsd
Associate II

Right after configuring cubeMX in proper manner, Then I should add the sdram .c and .h of my dicovery BSP driver to my project. now everything works well.

And this drive the __weak function BSP_SDRAM_Init().

View solution in original post

2 REPLIES 2
mohammadsd
Associate II

Right after configuring cubeMX in proper manner, Then I should add the sdram .c and .h of my dicovery BSP driver to my project. now everything works well.

And this drive the __weak function BSP_SDRAM_Init().

EKari.2
Associate II

Hi

I work on stm32f746 discovery and I want to configure FATFS on external sdram. I use STM32CubeIDE 1.6.1. when I create my project and mount disk, return error (value 13 = FR_NO_FILESYSTEM). does everone know about this problem or is there any sample code to solve this problem ?

thanks.