f_lseek returning FR_INT_ERR

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

f_lseek returning FR_INT_ERR

1,596 Views
neilporven
Senior Contributor I

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.

Labels (1)
0 Kudos
2 Replies

1,022 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Neil:

Are you still having this issue?

It is hard to explain but if the error description points in the right direction, then I would try increasing the project's stack size.

This can be done from the linker file (.ld file) and in KDS it should be called __stack_size__. Sometimes however the value is overwritten by a flag in the project linker options (Project -> Properties -> C/C++ Build -> Settings -> Cross ARM C++ Linker -> Miscellaneous -> Other linker flags). See this tutorial.

Regards!

Jorge Gonzalez

0 Kudos

1,022 Views
neilporven
Senior Contributor I

Hello Jorge,

Thank you for replying on this issue.  I was able to get the copying to recover and continue.  I am still bothered that

I don't understand why f_lseek is still reporting this issue??  If you have the handle to the file this shouldn't happen

and if you loose it and recover from it, it shouldn't occur repeatedly?

This also is really concerning, I am aware that this was written by someone else, but is troubling that nobody has ran

into this issue?  Maybe as usual I am doing something wrong or forgot to include something, I am referring to this:

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

I don't know if that is what your addressing above with the linker file and __stack_size__

Please let me know what you find on this. 

Neil

0 Kudos