FreeRTOS and Filesystem integration

Hi Folks, i was wondering how to integrate a Filesystem within FreeRTOS. The question is, does the filesystem needs its own task where it runs in or is it allowed to run outside of any tasks and is it still safe then, to call the FS functions from a task? Probably someone knows a link where a sample implementation or documentation is available? Kind regards, Peter

FreeRTOS and Filesystem integration

Hi Peter, I´ve used the Chan´s FAT implementation for FAT filesystems 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). http://www.sistemasembebidos.com.ar/forum/index.php?topic=730.0 Also I place it in google code: http://code.google.com/p/sistemasembebidos/ With a AT91SAM7S at 47.9 Mhz I get 370Kbytes/sec for read and write files (maybe because I use old MMCs…) Regards!

FreeRTOS and Filesystem integration

Hi Darukur, thanks for your answer. Iam already using FatFS 0.07c with MMC/SD/SDHC and USB MSD. Now i’ve wanted to integrate the FatFS with Free RTOS. I’ve found the following options in ff.h: FS_REENTRANT 1 || 0 and the following macros: ff_req_grant, ff_rel_grant, ff_del_syncobj /  and ff_cre_syncobj. My questions are: Do i have to place the FatFS in one task or do just the tasks call the FatFS functions? How should th tasks to be organized? Should i use one task for card and filesystem initialization, and if this task completes it should start my two other tasks who want to access the filesystem? I’ve hoped, that someone could tell me, how to implement that correctly ;-) Besides that, I’ve already had a look to your project: Where do you excatly lock the resource (disk_init, disk_read and disk_write) if you have multi task access? Because you don’t use FatFS in reentrant mode enabled. Regarding your MMC/SD-Card speed: Probably you loose the same time on the SPI than i do with my PIC32MX3xx/MX4xx. The time of processing the received bytes takes nearly the same time than reading a byte. I’ve even could not optimize that quite well. So the speed on the 80MHz PIC32 is the same than on a 8-Bit SiLabs c8051F340 with 48MHz. I have a raw speed of about 520kB/s. Kind regards, Peter

FreeRTOS and Filesystem integration

Hi, i’ve found a documentation about using the syncronization objects in FatFS. Its placed in the file syncobj.c which is located in the sample projects of chan. Thanks anyway! Peter

FreeRTOS and Filesystem integration

Hi Peter, I have to look to that flag you say because I surely may be corrupting something but about your question about where I lock the resource, is in the SPI routines where Freertos is used. FatFs and the diskIO are not aware of the RTOS handling and it shouldn´t do it anyway. The serialization is made at SPI level.

FreeRTOS and Filesystem integration

Hi Peter, if you have implemented the Re-Entrent functionality for FAFS to access it from multiple tasks, then you have the freedom to design your system as you wish!!!! I have implemented the Disk-Init and FS initilization and Mutex creation before the scheduler startup. i.e in the prvSetupHardware() function of the FreeRTOS. FATFS functions can be kept outside the task so that any task can access the FS whenever required. Note: If you like to implement the hot-insertion (Auto SD-Card detection), then change the design so that all the Initilization will come under a new task-create and mutex-del/fsclose should be done and a task-delete at the end of card removal. Regards, Prithwee.