Generating Static FreeRTOS Source Code

Using Processor Expert is an awesome tool: it generates source code for me, and I can can ‘dynamically’ tune my projects to my needs. Still, sometimes it is better or desirable to have a ‘normal’ or ‘static’ project. This is very well possible with Processor Expert (see “Sneaking from Processor Expert” or “Disable my Code Generation“): I can generate the code one time, and then use it without Processor Expert.

To make this even easier, I have added an option to the FreeRTOS Processor Expert component to generate ‘static’ code I can copy-paste to projects and tool chains which are either not supported by Processor Expert, or just for ‘static’ projects.

FreeRTOS Custom Port Settings

FreeRTOS Custom Port Settings

Custom Port Settings

In FreeRTOS terms, a ‘port’ are the RTOS sources with the specific support files for an architecture, e.g. an ARM Cortex-M0+. With Processor Expert I can dynamically detect which microcontroller architecture is use in the project, and generate code just for that ‘port’.

Compiler

If I want to generate ‘static’ sources, then I need to enable the ‘Custom Port’ settings. One important setting is the compiler:

Custom Port Compiler Setting

Custom Port Compiler Setting

This sets the compiler in the FreeRTOSConfig.h which I can change later in my ‘static’ sources:

/* -------------------------------------------------------------------- */
/* Macros to identify the compiler used: */
#define configCOMPILER_ARM_GCC               1 /* GNU ARM gcc compiler */
#define configCOMPILER_ARM_IAR               2 /* IAR ARM compiler */
#define configCOMPILER_ARM_FSL               3 /* Legacy Freescale ARM compiler */
#define configCOMPILER_ARM_KEIL              4 /* ARM/Keil compiler */
#define configCOMPILER_S08_FSL               5 /* Freescale HCS08 compiler */
#define configCOMPILER_S12_FSL               6 /* Freescale HCS12(X) compiler */
#define configCOMPILER_CF1_FSL               7 /* Freescale ColdFire V1 compiler */
#define configCOMPILER_CF2_FSL               8 /* Freescale ColdFire V2 compiler */
#define configCOMPILER_DSC_FSL               9 /* Freescale DSC compiler */

#define configCOMPILER                            configCOMPILER_ARM_GCC

Clock Settings

For now I mainly support the ARM Cortex with the static code generation, and for ARM I need to set the clock settings (bus clock and cpu clock), as they are used for the SysTick settings:

Manual Clock Settings

Manual Clock Settings

portBASE_TYPE

FreeRTOS uses the portBASE_TYPE as ‘architectural basic type’ which is typically an 8bit type for 8-bit microcontroller, and 32bit for a 32-bit microcontroller like ARM. You have the opportunity to change this:

custom portBASE_TYPE

custom portBASE_TYPE

❗ Be careful with this one: only change it if you now what you are doing 😉

Static Source Folder Settings

Instead to generate everything into the ‘Generated_Code’ folder, you can configure sub folder names:

Static Folder Settings

Static Folder Settings

With this, the FreeRTOS files are in separate sub folders:

Generated Sub Folders

Generated Sub Folders

Generating the sources is easy:  just have a ‘base’ project where I generate the sources from. I have one on GitHub here.

Using the Static FreeRTOS Files

Now I can copy that generated ‘FreeRTOS’ folder (with its sub folders) and for example use it in another tool chain or project.

Static FreeRTOS Sources in another project

Static FreeRTOS Sources in another project

Summary

Processor Expert can be used to generate static source code: with this I have the power of code generation, only need to support one ‘master’ source base, and can use the software IP either dynamically or statically. I avoid to have different version of the source base. Processor Expert then is like a data base or system which generates the needed software in the needed format.

I have used that approach with CodeWarrior, Eclipse Kepler and IAR projects successfully. I have used it for ARM (Cortex-M0+, Cortex-M4, Cortex-M4F), but with some further tuning that approch is suitable for any architecture. It is just that my work now is nearly everything on ARM 😉

The sources of the ‘master database project’, plus examples of generated sources and their ports/projects are available on GitHub: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FreeRTOS_Ports

Happy Generating 🙂

Advertisements

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s