f_lseek returning FR_INT_ERROR in stm FATFS
Hello,
I am trying to interface the sdcard FAT32 based on SPI with STM32F429ZI MCU. I am using the FATFS library (R0.12c) provided in the stmcube ide.
I am able to successfully initialize the sdcard using f_mount() function.
I want to implement the below mentioned code. f_open is sending the FR_OK response that means file is opened successfully but f_lseek command is not responding correctly.
fres = f_open(&fil,"HEADER.TXT", FA_READ | FA_OPEN_EXISTING);
if(fres == FR_OK)
{
fres = f_lseek(&fil,2);
fres = f_read(&fil,&temp,3, &ptr);
fres = f_close(&fil);
}
It is also came to my notice that when I send the command fres = f_lseek(&fil,0); then it responds FR_OK. Any non zero value in f_lseek function responds to the FR_INIT_ERROR.
During Debugging: in my case ofs =2
bcs = (DWORD)fs->csize * SS(fs); /* Cluster size (byte) */ --> this line results in bcs= 0 since the fs_csize is 0
ofs -= bcs; fp->fptr += bcs; --> Due to bcs=0 this line does not have any effect
clst = get_fat(&fp->obj, clst); --> this function return 0, here clst is passed as 24
if (clst <= 1 || clst >= fs->n_fatent) ABORT(fs, FR_INT_ERR); --> since clst = 0 it result in FR_INIT_ERROR
I am not able the infer the error from this debugging process. Please help me to find the issue and solution to resolve the issue.
I am attaching the I/O level implementation files and middleware is same as provided by stmcube ide while building the code using .ioc file.
