What is the best way to organise the source?

ardroliat wrote on Thursday, May 03, 2012:

I am starting a project and am forward thinking how to organise the FreeRTOS folders so that I can easily integrate future versions.
When I unzip the latest release it creates a folder  …\FreeRTOS\FreeRTOSV7.1.0
Which means in future it will be …\FreeRTOS\FreeRTOSVX.Y.Z

That change in subfolder name is going to create build problems that I will  need to fix.

Is there a folder structure that people have gravitated to?

Look forward to hearing from your opinions and thank you in advance

Kind regards

davedoors wrote on Thursday, May 03, 2012:

I guess the first “FreeRTOS” in that file path was a directory that you created, and the second “FreeRTOSV7.1.0” came from the zip file. You can just move the files from FreeRTOSV7.1.0 down one directory level and rename the directory to remove the version number. Most of the files in the directory you don’t need anyway. Any new project will only need FreeRTOS\Source. Take a look at http://www.freertos.org/a00017.html

toddatm wrote on Thursday, May 03, 2012:

I’m interested in this topic as well, since I’m organising a brand new project together with application code as we speak.

In particular, the demo I chose did not use CMSIS (I’m doing a Cortex M3 port), and the overall structure of the FreeRTOS project is OS-centric (understandbly so). In trying to add in CMSIS and my application code, I’m thinking about different directory structures. Without thinking I started with the “Demo” subdirectory name and a subdirectory named after the tools/processor and it makes no sense when you’re doing an actual application (at least in my case very unlikely to have different processor ports and tools), so I will change that.

Do most people end up compiling the RTOS and CMSIS into libraries and then link their application against the libraries?

My current plan is to have the FreeRTOS “Source” directory be more flat, and be compiled into a library and link my application against that. When it changes I’ll just update the files that changed. It’s a rather small number of files in any case.

rtel wrote on Friday, May 04, 2012:

In short, you can organise the source code however it best works for you.

My preference is to keep any code that is common across multiple projects in a single location on my computer, and then have all projects reference that.  That is why the FreeRTOS distribution has two root directories, one to hold a single copy of the code, and one to hold x number of projects that all reference the single copy.  If you are using Eclipse however, that kind of directory structure is nearly impossible to use, distribute or maintain unless you use it with standard makefiles (because Eclipse doesn’t include a proper project management/build system).

FreeRTOS configuration is done at the application level, using FreeRTOSConfig.h, which should be somewhere in your application directory structure, not in your FreeRTOS source tree.  That way, the FreeRTOS code can remain unchanged across all applications that are using it.  Building FreeRTOS to a library is ok, and quite common, but if you have a single library for all applications you loose that flexibility in configuration.

A lot of people will have FreeRTOS as a directory in their project directory structure.  That can be flat, or, maintain the same directory structure as the FreeRTOS distribution.  The benefit of the latter is that you can drop updated FreeRTOS versions in without having to move any files around first.

Generally, the only source files you need are:

timers.c (optional)
portable///portable.c (and maybe an asm file from the same directory, depending on the port)

and the include path required is


That is not many, and easy to manage.


toddatm wrote on Friday, May 04, 2012:

Thanks. Your suggestions are helpful and made me change some things around. I’m going to keep the structure of the RTOS “Source” directory so I can drop in updates. I had moved the FreeRTOSConfig.h over to the OS area, but now I’ll move it back. I’ll still use a library, but have the objects all put in the application area because of the potentially different FreeRTOSConfig.h files. I will plan to have multiple “projects” under what is called Demo in the distribution (looking forward to potentially other projects), but will change the name. I’m not an Eclipse fan (for the reason you mention, among others). Had decided against it after trying it out. I’ve been using Source Insight and will use that with standard makefiles. We use Tortoise SVN to control our source code.

stephman wrote on Saturday, May 05, 2012:


From my side, without saying this is the best method :

- I prefer to copy the FreeRTOS in my project directory that I can thus have several projects not using the same version.
If you keep FreeRTOS in a single directory it becomes impossible to maintain your projects (old projects will not compile anymore when you will update freertos). This is indeed mandatory to keep the source files of your projects that you can compile them at anytime without touching the code, especially in the industry

- For the project, I like this organisation in layers :
     HAL (Hardware Abstratction Level)
          adc.c, gpio.c, spi.c, and any very low level drivers (register drivers)
     HIL (Hardware Independent Layer)
          high level driver
          FreeRTOS,  ethenet stack, usb stack, modbus, FAT system, terminal, ….
          My user code

THis is the same organisation than Freescale does in its demo projects I guess…

it has the benefit to organise well, to be easier to port on a new platform (just change the HAL layers)