FreeRTOS - The hardware
FreeRTOS is a popular real-time kernel for microcontrollers. It has been ported to a variety of architectures with comprehensive demo applications.
So I decided to try it out with this MCBSTM32F400 board I have at hand. The board has an ARM® Cortex™-M4 based STM32F407IG with a bunch of peripherals fitted.
The FreeRTOS download contains demo projects as combinations of "Eval board + Dev tool". So for example to develop with MSP430 using GCC, the demo project "ES449 + GCC" could be used as a starting point. What really matters is the portable layer files in "FreeRTOS/Source/Portable/Compiler/Device/", specifically port.c and portmacro.h plus a couple of other files depending on the port.
For my STM32F407IG these files are included in the download for a selection of compilers - GCC, IAR, Keil etc. With this Eval board I chose to give Keil a try, and the portable files needed are in "FreeRTOS/Source/Portable/RVDS/ARM_CM4F/". Porting FreeRTOS to an architecture not included in the download will be difficult.
Therefore according to the documentation at www.freertos.org, to get a couple of LED flashing all I need are:
- FreeRTOS core files (in "FreeRTOS/Source/"): list.c, queue.c and tasks.c
- A portable file (in "FreeRTOS/Source/Portable/RVDS/ARM_CM4F/"): port.c
- A basic memory allocation file (in "FreeRTOS/Source/Portable/MemMang/"): heap_1.c
- FreeRTOSConfig.h - copied to the application directory
That's it! For my very first LED flasher I also copied a couple of application files from the Demo directory ("FreeRTOS/Demo/CORTEX_M4F_STM32F407ZG-SK/" to be specific), and of course a couple of STM32 library files. Here is a screen snap of the files to compile:
This is in Windows. But since the download comes with the portable files for GCC, it shouldn't be too hard to hook up something like Eclipse in Linux.