So the issue is narrowed down to prvGetFromFATBuffers
giving error code 0x80000004.
This is happening because FF_GetBuffer
fails to allocate an available cache buffer.
FF_GetBuffer()
is the only function issuing caching buffers.
So, it might be the case that all available cache buffers are occupied , when the task calls FF_Close
You should check now 2 things to make sure you are providing sufficient cache memory.
-
The recommended size for cache memory size = 9 X 512 bytes
-
Look at how many files are open at the same time and how many tasks are accessing the same volumes (RAM-disk, SD-card). It should not get locked-up; task waiting for either tasks.
There is a time-out when waiting for a free cache buffer: grep for
FF_GETBUFFER_WAIT_TIME_MS, by default 20 seconds.
You can refer to this issue for more detailed explanation on optimal FreeRTOS + FAT Cache memory.