Multi-tasking FAT Filesystem for FreeRTOS.

prithwee wrote on Friday, January 23, 2009:

Dear All,

I have ported the FreeRTOS on our proprietary DSP core.
Also ported an open source FAT File system and its working fine with my SD card driver.

But FATFS do not support multitasking environment.

FATFS Application note says that

“Porting to RTOS-When use FatFs module from only one task, no consideration is needed.
However when make access to a logical drive from two or more tasks simultaneously, any exclusion control will be required.”

Even after doing the semaphore control using mutex, I could not access multiple files from different tasks.

Example: File-A is opened in Task-A and doing some operation on it (f_lseek),
         simultaneously I can not access to the file pointer of File-B in Task-B.

Do you have any suggestions on this?

Have anyone of you ported FATFS or any other File system for FreeRTOS and working in multitasking environment?

My target:
           A: Audio files playing with audio decoder in Task-A.
           B: JPG files displaying with JPG decoder in Task-B.          




woops_ wrote on Friday, January 23, 2009:

go to

prithwee wrote on Monday, January 26, 2009:

Yes, that was a good referance for my project. Thnak you.

But my actual problem lies in the implementation of FATFS for RTOS.

–>Problems and Ideas–>Porting to RTOS.

Because of this shared resource filesystem, after mutex locking am not able to access the 2nd file on a 2nd Task while 1st file on 1st task is already open. It will give the access to the 2nd file only after 1st file will be operated with "f_close".

Any solution to do operation on both the files simaltanously on differnt tasks?




jakbird wrote on Monday, January 26, 2009:

From your description the 1st task is not releasing the mutex between file accesses, so the 2nd task is always blocked while waiting for the mutex.  Either release the mutex between file system calls or implement the file system as a separate task and send filesystem requests to the FS task in a queue, which will serialize access to the resource, replacing the mutex.

darukur wrote on Monday, August 17, 2009:

Hi, I´ve used the Chan´s FAT implementation for FAT filesystems (FATTF) succesfully with Freertos.
This FAT driver only need the diskio implementation for your device (SD, MMC, NANDFlash etc), so in my case I developed an SD driver with SPI handling.
In my SPI driver I use FreeRTOS, so Chan´s Fat becomes FreeRTOS enabled (thread safe).

You can see the code in this forum (in spanish but the code is english commented).

Also I place it in google code:

With a AT91SAM7S at 47.9 Mhz I get 370Kbytes/sec for read and write files (maybe because I use old MMCs…)


darukur wrote on Monday, August 17, 2009:

Sorry for the misspell I mean FATFS

prithwee wrote on Tuesday, August 18, 2009:

Hi darukur,

Can you access your sd-card READ/WRITE simaltanously from different tasks?

Your example code shows copy operation in a single task-vFatFsDemo.

How about "READ" in Task-A and Write in Task-B?
Did you consider the Re-Entrant functionality and resource locking for FATFS?