FreeRTOS+FAT SL benchmarking

Hello, I am trying to do some bench marking of FreeRTOS+FAT SL using Atmel SAM4S and Atmel Studio IDE. I am trying to measure the time required to write to a SD card. For this purpose I am using a simple bit toggling before and after the f_write function. The results are not very clear to me since the timing is not constant all the time. Does someone know how to measure this more accurately or if this is the expected behavior. Moreover, I have a task with a vTaskDelay(1000) and it performs the same writing function over again. Any suggestion or help is appreciated. Regards, Owais

FreeRTOS+FAT SL benchmarking

The majority of the time during an fwrite will be the time taken to write to SD card – which includes the time taken for the card to program the flash it contains. There is a lot going on inside the SD card, and it is possible that will generate some jitter – it handles all the ware levelling, etc. for you. If you want to measure something without any other FreeRTOS tasks getting in the way then I would suggest setting FFSTHREAD_AWARE to 0 and performing the write before the scheduler has started. The SL in FreeRTOS+FAT SL stands for ‘super lean’, and just like TCP/IP stacks, there is an inverse relationship (up to a point) between RAM footprint and performance. Regards.

FreeRTOS+FAT SL benchmarking

Thank you for your response. My application will require me to write to the SD card during the operation and since I have to perform this in a task, I need to be sure if the writing function will successfully finish its job before the task is interrupted by some other task. I am also aware that toggling a pin is not the best solution so I am open for suggestion. Regards

FreeRTOS+FAT SL benchmarking

I need to be sure if the writing function will successfully finish its job before the task is interrupted by some other task
If this is just a sequencing issue, then you can temporarily raise the priority of the task performing the write – but that will naturally impact the real time responsiveness of your application. If FFSTHREAD_AWARE is set to 1 then you need not worry about another task accessing the file system at the same time, no matter what the task priorities. Regards.

FreeRTOS+FAT SL benchmarking

Thank you once again. I have read some comments in the comments in the code and according to them it is not possible to access the file system from more than one task, is this true? Also it is suggested that the idle hook be used and FFSTHREAD_AWARE should be set to 1. In my case I need to write to the SD card from more than one task and idle hook solution is not a good option since it may happen that the idle hook is never called due to other tasks. One more thing I need to ask is that, is it possible to create two different files on SD and write simultaneously, so what I mean is that once a file is created a space is allocated for it and when another task creates a different file it should not overlap the first one and also a file should not be allowed to be written until it is closed. Is there such a mechanism implemented in FreeRTOS+FAT SL? Regards.

FreeRTOS+FAT SL benchmarking

If FFSTHREAD_AWARE is 1 then file system access is protected by a semaphores. However, in the super lean product only one file can be open at a time.

FreeRTOS+FAT SL benchmarking

So it will not be a problem if I access SD card from more than one task? as long as the file is opened and closed in the first task the second task can open and write to the same or a different file? What if there is a third task that tries to access the file that is not yet written what happens in this case? Regards.

FreeRTOS+FAT SL benchmarking

The third task won’t be able to access it until it can obtain the semaphore, which is managed by the FAT API.

FreeRTOS+FAT SL benchmarking

Hello, Thanks for clearing that. Is it also possible that we leave a file open in a task and then write to that same file from a different task? Regards.

FreeRTOS+FAT SL benchmarking

Thanks for clearing that. Is it also possible that we leave a file open in a task and then write to that same file from a different task?
I think that should be fine. Regards.

FreeRTOS+FAT SL benchmarking

Thank you for the response. Is there a more efficient way to measure the time taken by the task that is writing to the SD card since bit toggling is not at all useful. Any suggestion will be appreciated. Regards.