Getting FR_INT_ERR when using f_seek in ff.c
Hello!
I was opening a file and trying to read from a specific index of a file on my SD card. I used the following code:
FIL fHandle_filename_file;
char SDFileName[256] = "filename_1234.BIN";
res = f_open(&fHandle_filename_file, SDFileName, FA_OPEN_EXISTING | FA_READ);
res = f_lseek(&fHandle_filename_file, 1024);I receive an FR_OK when I open the file, so it seems to be finding the file and is able to open it. When I try and move to index 1024, I receive the error FR_INT_ERR .
I stepped through the f_seek function and below is the code:
FRESULT f_lseek (
FIL* fp, /* Pointer to the file object */
FSIZE_t ofs /* File pointer from top of file */
)
{
FRESULT res;
FATFS *fs;
DWORD clst, bcs, nsect;
FSIZE_t ifptr;
#if _USE_FASTSEEK
DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
#endif
res = validate(&fp->obj, &fs); /* Check validity of the file object */
if (res == FR_OK) res = (FRESULT)fp->err;
#if _FS_EXFAT && !_FS_READONLY
if (res == FR_OK && fs->fs_type == FS_EXFAT) {
res = fill_last_frag(&fp->obj, fp->clust, 0xFFFFFFFF); /* Fill last fragment on the FAT if needed */
}
#endif
if (res != FR_OK) LEAVE_FF(fs, res);When i use the offset value of 0, it works fine. When I use anything else, it seems to get the FR_INT_ERR code from the "fill_last_frag" function (I am using an exfat formatting SD card).
The file itself is 800 Kb,so I'm not exceeding the file size. Not sure if I have a setting incorrect on the SD card, if I'm using the function incorrectly, etc. I thought someone in this forum might have seen this issue before but haven't ran into any posts.
If someone can help me understand what might be going on or how to resolve this error, I'd appreciate it. Thanks for the help!
