Hello all,
I guess some of you have already run into the huge memory consumption of FatFS, especially when used from different threads. So I've set out and wrote a wrapper using a worker thread. The result can be found here:
https://github.com/mabl/ChibiosFatFSWorkerWrapper
Feedback is always welcome
FatFS Wrapper
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: FatFS Wrapper
It is a good idea and looks very good.
I have been thinking for a while to create a file system abstract interface, there are already abstract files, it could be used as implementation.
Giovanni
I have been thinking for a while to create a file system abstract interface, there are already abstract files, it could be used as implementation.
Giovanni
Re: FatFS Wrapper
This looks nice, but could you also upload some example code to show how to use it?
~ Tectu
~ Tectu
-
- Posts: 417
- Joined: Tue Dec 21, 2010 10:19 am
- Location: Karlsruhe, Germany
- Been thanked: 1 time
- Contact:
Re: FatFS Wrapper
Hi Tectu,
it should be straight forward to use the wrapper. Just
As end result, all fatfs access will now go over one single thread, so that only this thread needs to have a big working area - and not each thread doing file system access.
it should be straight forward to use the wrapper. Just
- Include the wrapper source directory and add fatfsWrapper.c to the C files
- Call wf_init() before you do any work wit fatfs
- Replace all calls to fatfs, those starting with f_ with wf_. So i.e. f_mount becomes wf_mount.
- Disable all functions you do not need in fatfsWrapperConfig.h. This is because now the compiler will not be intelligent enough (because of the wrapped calls in the worker) to detect which functions you will actually use - and your program size will increase dramatically.
- If you have replaced ALL calls to fatfs with the wrapped calles, you might also just deactivate the reentrancy of FatFS, since it will be only called from one single thread sequentially.
As end result, all fatfs access will now go over one single thread, so that only this thread needs to have a big working area - and not each thread doing file system access.
Re: FatFS Wrapper
I'll give it a try in a few days!
I am currently working on a project with uses SD card, and I had some serious issues with the working areas and also the "syncronisation". It looks like you just did what I need.
Thank you for your great work!
~ Tectu
I am currently working on a project with uses SD card, and I had some serious issues with the working areas and also the "syncronisation". It looks like you just did what I need.
Thank you for your great work!
~ Tectu
Re: FatFS Wrapper
finaly got some time to try it. Works really good!
Thanks you for sharing your excellent work!
~ Tectu
Thanks you for sharing your excellent work!
~ Tectu
Re: FatFS Wrapper
This was something I was planning to do, but never got around to. Now you've done it for me
I will integrate into my projects and provide feedback soon.
thanks!
I will integrate into my projects and provide feedback soon.
thanks!
-
- Posts: 104
- Joined: Wed Feb 22, 2012 11:39 am
- Location: Austria
Re: FatFS Wrapper
mabl, thank you - it works out of the box!
Just one suggestion - the worker thread priority should be part of the configuration file.
Just one suggestion - the worker thread priority should be part of the configuration file.
Re: FatFS Wrapper
I suggest to pass the priority to the init.
Made a pull request, maybe he will add it
~ Tectu
Code: Select all
wf_init(tprio_t priority);
Made a pull request, maybe he will add it
~ Tectu
Who is online
Users browsing this forum: No registered users and 46 guests