cancel
Showing results for 
Search instead for 
Did you mean: 

FatFS+FreeRTOS+ continuous SD write is failing with FR_DISK_ERR or FR_INVALID_OBJECT

kishore R
Associate II
Posted on January 13, 2017 at 08:23

Hi,

I am using STM32L4 controller. I am using FatFS+FreeRTOS example project to make sure that SD read and write is working properly. But i am facing problem when i do continuous SD write to the SD card.

I have four thread in my application in that one thread will do continuous SD write function. But randomly after writing some junk of data 'f_write()' function is returning FR_DISK_ERR or FR_INVALID_OBJECT error. The same project before starting FreeRTOS (oskernalstart();) if i do continuous SD write  i am not facing any problem. able to write 2GB of data without any fail. problem is only if i run f_write with FreeRTOS thread.

Able to do continuous SD write operation in two scenario:

1) FatFS f_write() and without FreeRTOS  

2) FatFS+FreeRTOS+taskENTER_CRITICAL

#fatfs+freertos+-continuous-sd-write-is-failing
3 REPLIES 3
Posted on January 13, 2017 at 10:51

Fatfs and the SDIO driver are not thread safe, you would need to serialize access to this resource, or keep it all in one thread.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 13, 2017 at 11:17

Thank you for the Quick reply.

Yes. I am doing serialize access only. only one thread is doing continuous write to the SD card. No other threads are doing SD write operation.

I have verified the available stack size of the thread when the error was happened, enough free stack was available when f_write is returned FR_DISK_ERR or FR_INVALID_ERR.

Please give me some suggestion to over come this issue. Got stuck with this issue. 

Posted on January 13, 2017 at 15:31

Then you'll need to dig into the DISKIO layer to understand why you get the error. You'd want to look at the interactions with the SDIO peripheral, and the IRQ handling for SDIO & DMA, and for the FIFO to clear.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..