FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2009 Threads] FATFS and FreeRTOS againPosted by Sergio Sider on March 11, 2009 Hi All,
Does anyone ported successfully Elm Chan's FATFS to FreeRTOS ?
The author suggested using mutexes for using fatfs from more than 1 thread, but where do I really have to use them?
a) just to protect the hardware dependent calls ? b) to protect every call to the fatfs api ?
I searched this forum and found some messages from a person that apparently used mutexes in a higher level (just freeing the resource when the file was closed).
Any ideas? Thanks, Sergio P. Sider
RE: FATFS and FreeRTOS againPosted by Prithwee on March 11, 2009 Yes, FATFS need a mutex if your are accesing the filesytem from different Tasks.
FATFS is Global declaration for the entire Filesystem.
So, you must protect the all calls with mutex. (f_open,f_read,f_readdir,f_lseek,f_write,f_close... etc)
Meanwhile give a try to access without mutex for 2 tasks, it should welcome an error FR_INVALID_OBJECT or FR_NO_FILESYSTEM.
Please post your results.
Regards, Prithwee.
RE: FATFS and FreeRTOS againPosted by Sergio Sider on March 11, 2009 Hi Prithwee,
Thanks for your response,
I wraped all fatfs api calls (f_open, f_read....) with a mutex ,
I wraped all access to SPI port (that I plan to use for another device) in the hardware dependant calls (disk_initialize,disk_read, etc) with another mutex.
To mimic the timer interrupt routines (disk_timerproc), I created a task to fire at 10ms intervals:
void vFATFSTimerTask (void* pvParameters) { portTickType xLastWakeTime = xTaskGetTickCount(); for (;;) { disk_timerproc(); vTaskDelayUntil (&xLastWakeTime, (10 / portTICK_RATE_MS)); //each 10ms } }
I did not have time to test it from multiple threads, but as soon I do, I will post my results...
Thanks again! Sergio P. Sider
RE: FATFS and FreeRTOS againPosted by Sergio Sider on March 11, 2009 Hi again,
Just to post my results.
I made a test, 2 task writing to different files , 1000 lines of text, one writing 1 line each 100ms and the other at 200ms, both tasks started at the same time, but obviously file1 took half long to complete.
Both files writen successfully, no aparent problem.
Regards, Sergio
RE: FATFS and FreeRTOS againPosted by Prithwee on March 12, 2009 Hi Sergio,
Congratulations.
Just a Note: If you have planed to use SPI for other device and not using FATFS in multiple tasks simaltanously, then its sufficient to lock/unlock just SPI calls.
Aceesing the FATFS calls for writing to a SDcard from multiple tasks with mutex, decreses the card read/write speed in realtime.
Example:Writing a PCM Audio data @44.1Khz is not possible in realtime with SPI interface.
Regards, Prithwee.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|