AnsweredAssumed Answered

f_write  is giving FR_DISK_ERROR

Question asked by yalamanda dosakayala on Feb 8, 2018
Latest reply on Feb 8, 2018 by Clive One

Hi STM community,

 

I am working with STM32F779i board , using system workbench for stm IDE. in my project I am using freertos ,fatfs ,sdcard drivers and CAN drivers. Initially as per project requirement we need more RAM, so we have implemented SDRAM as RAM.

 

We have two tasks , one for fatfs and another for CAN . I am receiving a file from PC over CAN and writing it to a buffer(buffer size is sizeof file created with malloc) on to SDRAM, another task is waiting till we received whole file over CAN and then I am writing the buffer to file in the SDCARD .

 

I am able to write small files(10kB, 40KB) successfully,But for large files (more than > 50KB) the f_write is returning FR_DISK_ERR.

 

I dig into the f_write function and it is failing at below ABORT(fs, FR_DISK_ERR);

and the value of clst is 0xFFFFFFFF;

{
                        clst = create_chain(&fp->obj, fp->clust);    /* Follow or stretch cluster chain on the FAT */
                    }
                }
                if (clst == 0) break;        /* Could not allocate a new cluster (disk full) */
                if (clst == 1) ABORT(fs, FR_INT_ERR);
                if (clst == 0xFFFFFFFF) ABORT(fs, FR_DISK_ERR);

}

 

Can anyone tell me why which case I will get this error ?

 

and   how to resolve this error ?

Outcomes