FreeRTOS – targets

One of the strenghts of FreeRTOS is the portability. In this installment, we will look at the available targets, and how to get up and running easily. Perhaps you already have a FreeRTOS compatible board in your lab.

FreeRTOS is officially ported to a range of platforms. These are usually reference kits or such. For instance, it has been ported to Arm processors of various sizes: Cortex M3, ARM7 and ARM9 with support for boards from Actel (SmartFusion, an Arm and FPGA combined), NXP, ST and TI. TI’s MSP430 is also supported. Xilinx’ Virtex-4/5 PowerPC processors and the soft-core MicroBlaze are also supported. On the classic side, the 8051 is supported (the supported board is from Cygnal). If you are into Rensas processors, the RX62N, SH2A, H8/S, V850 and 78K0R are supported on various boards. For the desktop users, there is no excuse, as x86 is supported, and there are simulators for both Windows and Posix operating systems such as Linux.

In addition to the platforms mentioned above, there are also a large amount of contributed ports, i.e. non-official ports. These targets systems such as various PIC processors from Microchip, the Altera Nios II, and more. Chances are that you already are running a CPU supported by FreeRTOS.

Porting FreeRTOS to a new platform can be either hard or easy. If the CPU isn’t supported yet, the task at hand can be complex. It is also hard to verify that the new port actually works in all corner cases. However, if the CPU support already exists, the exercise can be easier.

Having downloaded and extracted the FreeRTOS source code, the directory FreeRTOS/Demo contains sub-directories with demos. An interesting example is contained in the MicroBlaze sub-directory. Before we continue looking at the code, let me just explain why I choose the MicroBlaze as an example.

The MicroBlaze, from Xilinx, is a soft CPU implemented in an FPGA. This means that the instruction set is (almost) identical between all processors, but the memory layout, clock frequency and other configuration settings can differ quite a lot.

Returning to the software side of the solution, all the settings of the system are stored in the FreeRTOSConfig.h file. In there, the system setup, as well as the FreeRTOS API can be fine tuned. Some of the settings used in the MicroBlaze project are explained below. This should give you an idea of the effort involved.

  • configUSE_PREEMPTION 1 enable pre-emptive multitasking, i.e. tasks are interrupted without actively yeilding the CPU.
  • configUSE_IDLE_HOOK 0 do not use a hook function which is called everytime the idle task is run.
  • configUSE_TICK_HOOK 0 do not use a hook function that is called for every tick
  • configCPU_CLOCK_HZ ((unsigned long)100000000) the CPU clock frequency is 100MHz.
  • configTICK_RATE_HZ ((portTickType)1000) there are a thousand ticks to each second.
  • configMINIMAL_STACK_SIZE ((unsigned short)120) a minimal stack size is 120B.
  • configTOTAL_HEAP_SIZE ((size_t)(18*1024)) the total heap size is 18kB.

The configuration options above demonstrate how the hardware related settings can be tuned. For instance, the scheduler relies on the tick frequency, as well as the CPU clock. Using the defines INCLUDE_vTaskPrioritySet, INCLUDE_uxTaskPriorityGet, INCLUDE_vTaskDelete, etc, the API can be tuned. Leaving out functions, e.g. vTaskDelete in the MicroBlaze demo, minimizes the memory footprint of the system. This allows you to run FreeRTOS on minimal embedded systems, as very little overhead is brought into the system.

As you can see, it is easy to setup FreeRTOS for your own platform – especially if you are relying on a supported CPU. Given the vast amount of supported CPUs, the structure of FreeRTOS is also proven to be portable between architectures. Thus, using a different CPU should not be considered a show-stopper.

This entry was posted in FreeRTOS. Bookmark the permalink.