ChibiOS/RT Integration Guide

This guide describes what is needed in order to integrate ChibiOS/RT or ChibiOS/NIL in a build environment different from the default one provided in ChibiOS distribution.

What this guide does not cover

This guide has a limited scope, the following topics are handled elsewhere:

  • Porting the OS to different architectures or different compilers is not covered in this guide, see the “ChibiOS/RT Port Guide” article instead.
  • This guide does not describe any specific environment or development tool, it is assumed you already know in detail the environment you want to work with.

Note about ChibiOS/NIL

This guide also applies to ChibiOS/NIL, just replace /rt/ with /nil/ in paths and replace chconf.h with nilconf.h.

Integrating the Kernel

This section covers the scenario where you want to use the ChibiOS/RT kernel into an existing application. In order to accomplish this you need to import in your project two components:

  • The portable RT kernel.
  • The RT port layer for your microcontroller.

You need also to consider the port-specific requirements, random startup files and linker files are not going to work. It is advised to use the provided support files before trying to use alternatives.

Portable RT Kernel

You need to add the following files to your build process:

  • ./os/rt/src/*.c

Also add to the search paths for headers the RT portable headers located in:

  • ./os/rt/include
RT Port Layer

Port layers can differ from each other but the general layout is the same. You need to include the source code from:

  • ./os/rt/ports/<architecture>/*.c (note some files could be optional here)
  • ./os/rt/ports/<architecture>/compilers/<compiler>/*.c
  • ./os/rt/ports/<architecture>/compilers/<compiler>/*.s

The directory containing pertinent headers are:

  • ./os/rt/ports/<architecture>
  • ./os/rt/ports/<architecture>/compilers/<compiler>

The port layer can, and usually does, have architecture-specific requirements. Usually a small header must be provided to the port containing the MCU-specific parameters. This file is named:

  • cmparams.h for the ARM Cortex-M port
  • armparams.h for the ARM port
  • ppcparams.h for the Power e200Z port

Additionally the ARM Cortex-M port also requires the vendor-provided CMSIS-compliant registers definition headers. The headers is usually included from cmparams.h.

Templates of the parameters headers are provided under:

  • ./os/common/ports/<architecture>/devices/<device>/xxxparams.h

CMSIS headers for the supported Cortex-M MCUs are also provided under:

  • ./os/ext/CMSIS/include
  • ./os/ext/CMSIS/<vendor>/[<family>]

You should add the proper CMSIS path to you project search paths.

Other Files

The RT kernel requires a configuration file, it is usually placed under the project root directory but it can be placed in any directory reachable by the compiler. The file is named chconf.h and a template can be taken from:

  • ./os/rt/templates/chconf.h

Do not use the file directly, copy it in your project and edit the copy.

Notes

If in doubt remember that the provided makefiles are the ultimate guide for the integrator, all required the paths and options are necessarily present there. It is a good idea to look at the Makefile present in all demos if some detail is not clear. By compiling the demo all compiler options are printed on the console, that should remove any doubt about the required paths, files and options.

More articles and guides are available on the technical wiki.

learn more

Need Tutorials?

Try the video tutorials and guides on Play Embedded.

learn more

Need Support?

The forums is the best place, registration required.

learn more