AnsweredAssumed Answered

call to fmount fails in stm32f779I eval board

Question asked by yalamanda dosakayala on Jan 4, 2018
Latest reply on Jan 5, 2018 by Clive One

Hi STM Community, I am working on one project , for reading a file from sd card and  writing it back, And I am using STM32F779I Eval board for it. I am using STM CUBE Mx for generating the code for fatFs and SD card. I am using System workbench for STM32(Ac6) IDE for it. I referred some sample examples. So I made  code for like below. But it is always failing at call  f_mkfs() goes to error_handler. When I debug into f_mkfs it is failing at disk_write function(

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

 

 

 

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 */

 

    /*##-1- Link the micro SD disk I/O driver ##################################*/
    if(FATFS_LinkDriver(&SD_Driver, SDPath) == 0)
    {
        if(BSP_SD_Init() == MSD_OK)
        {
      /*##-2- Register the file system object to the FatFs module ##############*/
      if(f_mount(&SDFatFs, SDPath, 0) != FR_OK)
      {
        /* FatFs Initialization Error */
        Error_Handler();
      }
      else
      {
//        ##-3- Create a FAT file system (format) on the logical drive #########
//         WARNING: Formatting the uSD card will delete all content on the device
        if(f_mkfs(SDPath, FM_ANY, 0, workBuffer, sizeof(workBuffer)) != FR_OK)
        {
//           FatFs Format Error
          Error_Handler();
        }
        else
      {
          /*##-4- Create and Open a new text file object with write access #####*/
          if(f_open(&MyFile, "STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
          {
            /* 'STM32.TXT' file Open for write Error */
            Error_Handler();
          }
         

Outcomes