2020-03-27 06:05 AM
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.
[3]: https://1drv.ms/u/s!AjRo7Nr2rz_hieVt08nsAxzAhp9dmQ?e=u7eGvk
Solved! Go to Solution.
2020-03-30 02:35 AM
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().
2020-03-30 02:35 AM
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().
2021-07-19 12:36 AM
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.