Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

What is the best way to organise the source?

Posted by Ard Roliat on May 3, 2012
Hi
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
Ard

RE: What is the best way to organise the source?

Posted by Dave on May 3, 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

RE: What is the best way to organise the source?

Posted by Todd on May 3, 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.

RE: What is the best way to organise the source?

Posted by Richard on May 4, 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:

tasks.c
list.c
queue.c
timers.c (optional)
portable/[compiler]/[microcontroller]/portable.c (and maybe an asm file from the same directory, depending on the port)

and the include path required is

source/include
portable/[compiler]/[microcontroller]

That is not many, and easy to manage.

Regards.

RE: What is the best way to organise the source?

Posted by Todd on May 4, 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.

RE: What is the best way to organise the source?

Posted by Stephane Rey on May 5, 2012
Hello

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
Services
FreeRTOS, ethenet stack, usb stack, modbus, FAT system, terminal, ....
Application
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)

Regards
Stephane


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists