cancel
Showing results for 
Search instead for 
Did you mean: 

Hi Everyone ! I have a problem with FAT filesystem. Can you help me ?

İbrahim Cenger
Associate

Im trying to write a text in SD Card with stm32F746g-disco. So i check for example application and i found one in STM32CubeMx repository. When i try that code it works perfectly . So i tried to do it my own with STM32CubeMx , i selected stm32f746g-disco, set FATFS defines and generated the code. This is my code :

 if(FATFS_LinkDriver(&SD_Driver, SDPath) == 0)

 {

  if (f_mount(&SDFatFs, (TCHAR const *)SDPath, 0) != FR_OK)

  {

   Error_Handler();

  }

  else

  {

   if (f_mkfs((TCHAR const *)SDPath, FS_ANY, 0, workBuffer, sizeof(workBuffer)) != FR_OK)

   {

    Error_Handler();

   }

   else

   {

    if (f_open(&MyFile,/*(TCHAR const*)*/"STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)

    {

     Error_Handler();

    }

    else

    {

     f_write(&MyFile,wtext,sizeof(wtext),(void *)&byteswritten);

     f_close(&MyFile);

    }

   }

  }

 }

FATFS_LinkDriver working, f_mount working but in f_mkfs code gives me an error.

do { /* Fill FAT sectors */

n = (nsect > sz_buf) ? sz_buf : nsect;

if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) return FR_DISK_ERR;

mem_set(buf, 0, ss);

sect += n; nsect -= n;

} while (nsect);

I followed the code and found that the error was here. disk_write api gives me FR_DISK_ERR.

What can i do ? Can you help me ?

Regards.

İbrahim

0 REPLIES 0