Hey all, I’m just starting to get comfortable with FreeRTOS and have encountered the challenge of needing to integrate a filesystem (littleFS) for embedded microcontroller (ARM CM4). I was hoping I could lean on some of the expertise hear to help guide me with regards to designing my system.
The filesystem will uses the embedded mcu flash and I am currently able to read/write. However, I’m hoping for some guidance with regards to how to manage file I/O with the RTOS. Is it best to create a single task that manages file I/O? Is it okay to have all tasks read/write when they please and protect the FS with a semaphore?
Any suggestions on how to make these decisions and what I should look out for would be much appreciated!
The simplest scheme would be to have only a single task access the file system, then you don’t have my concurrency issues. Next simplest would be to have a semaphore protect the entirety each file system api function - that is what the popular ChaN FATfs system
does (if you set a #define it takes a semaphore on entry to an api function and returns it on exit) effective but crude as some file system operations take a long time and the mutex protects the whole function rather than just the bits of the function that
actually need concurrency protection. Finally the most complex but also the most efficient is to have a fully thread aware file system that only has concurrency protection in the portions of the api functions that actually require it rather than the whole
function.
Does your file system have any thread awareness at all?
I’m not sure as I don’t have much familiarity with littleFS but I haven’t seen any references to that in the documentation. What would be required for it to have thread awareness?
I’m afraid I have no experience with that FS so suggest you post your question on the vendors forum - a quick google search did bring this up as the first link: https://github.com/ARMmbed/littlefs/issues/156