AnsweredAssumed Answered

f_open error 11 (can't find FR_INVALID_DRIVE)

Question asked by pollack.brandon on Mar 2, 2015
Latest reply on Mar 3, 2015 by pollack.brandon
My issue is with fatfs in the following code:

retSD = FATFS_LinkDriver(&SD_Driver, SD_Path);
if(retSD == 0)
     {
          if(f_mount(&sdcard,(TCHAR const*)SD_Path,1) != FR_OK) //works great
          {
               Error_Handler();
          }
          else
          {
               //HAL_SD_WideBusOperation_Config(&hsd,SDIO_BUS_WIDE_4B);
               retSD = f_mkfs((TCHAR const*)SD_Path,0,0); //formats just fine, i even took the SD card out and put it in my laptop, formatted 100% ok
               if(retSD != FR_OK)
               {
                    Error_Handler();
               }
               else
               {
                    retSD = f_open(&file,"0:test.bin",(FA_CREATE_ALWAYS | FA_WRITE)); //trying to just create a file, i tried with and without 0:, in debug I found that is what SD_Path ends up being, I also tried with and without a / at the end.  I always get error 11!!!
                    if(retSD != FR_OK)
                    {
                         Error_Handler();
                    }
               }
          }
     }

After stepping through my code for a few hours, I have also found a strange error that occurs in the middle of the f_open below:

if (res == FR_OK) {
          INIT_BUF(dj);
          res = follow_path(&dj, path);     /* Follow the file path */
          dir = dj.dir;

INIT_BUF(dj) simply calls malloc(size) where size is about 514 (2*some buffer size in ffconf.h)

I certainly have this much memory available...but when it returns the function f_open jumps to the end with a return code error (optimization is off so I can see every step, but this still happens...)

Any pointers?

Outcomes