AnsweredAssumed Answered

f_lseek returning FR_INT_ERR

Question asked by Neil Porven on Oct 1, 2015
Latest reply on Oct 12, 2015 by Neil Porven

Hi everyone,

 

I am trying to read from an SD card and I am using the FatFs driver on the SDK.  I am using a demo

 

FatFs + SDHC data logger demo with KSDK By: Jorge Gonzalez

 

It seems that at any random given time after a f_lseek the function is returning FR_INT_ERR

 

FR_INT_ERR -

Assertion failed. An insanity is detected in the internal process. One of the following possibilities is suspected.

  • Work area (file system object, file object or etc...) has been broken by stack overflow or any other tasks. This is the reason in most case.
  • There is any error of the FAT structure on the volume.

Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.

 

The above was taken from FatFs - Return Codes , I have no idea what the above means, but better yet, it doesn't explain what to do in the event you get

this error????

 

Why am I getting this error, if everything works fine for about say 80K, then the above starts happening???

 

I don't think it has to do with my opening and closing the dir (which I am having an issue with, because it doesn't let me place f_closedir(&dir); anywhere)

 

Here is the sample code for the directory bit:

 

DIR  dir;

 

 

    //Initialize

  iDir_Return = 0; //We collected info

 

 

  fr = f_opendir(&dir, ""); // Open the directory

 

 

  //Check if the directory open

  if (fr == FR_OK)

   {//Begin if (directory open)

 

 

     fr = f_readdir(&dir, &DirInfo); // Read a directory item

 

 

     //Read the directory

     if (fr == FR_OK)

      {//Begin (read directory)

 

 

      //Extract SD card directory filename

      for(int i=0; i <= 13; i++)

      SD_info.file_name[i] = DirInfo.fname[i];

 

 

      SD_info.file_attribute = DirInfo.fattrib;

      SD_info.file_size =  DirInfo.fsize;

 

 

      //info = DirInfo.fdate;

      //strftime(SD_info.date_modified,8,"%x", info);

      //strftime(SD_info.time_modified,8,"%X", DirInfo.ftime);

 

 

      }//End (read directory)

     else

      {

       SD_info.FatFs_status = &ccRead_dir[0]; //Report status (could not read directory)

       iDir_Return = 1; //Couldn't collect info

      }

 

 

 

 

 

 

   }//End if (directory open)

  else

   {

    SD_info.FatFs_status = &ccOpen_dir_f[0]; //Report status (could not open directory)

    iDir_Return = 1; //Couldn't collect info

   }

 

 

//f_closedir(&dir);      <----------------------------************* notice this I have to comment or else the compiler complains ****************************

 

  //printf("\nDate(mm/dd/yy):%02u/%02u/%02u\r\n",DirInfo.fdate.Bits.month,DirInfo.fdate.Bits.day,(DirInfo.fdate.Bits.year + 1980));

  //printf("\nTime:%02u:%02u:%02u\r\n\r\n",DirInfo.ftime.Bits.hour,DirInfo.ftime.Bits.minute,DirInfo.ftime.Bits.second);

return(iDir_Return);

 

Not sure if it has to do anything with the f_lseek issue I am having...........Need help

 

Thank you.

Outcomes