FreeRTOS for Infineon MCUs

December 11, 2025 · View on GitHub

Overview

FreeRTOS is supplied as standard C source files built along with the other C files in your project. This repository contains a port of the FreeRTOS kernel for Infineon MCUs based on Arm® Cortex®-M0 (CM0), Cortex®-M0+ (CM0P), Cortex®-M4 (CM4), Cortex®-M33 (CM33), Cortex®-M55 (CM55), Cortex®-R4 (CR4) and Cortex®-M7 (CM7) cores.

See the FreeRTOS API documentation at FreeRTOS web page.

Note: Cortex®-R4 (CR4) is currently supported only on GCC_ARM

Warning: Due to CVE-2024-28115 vulnerability in older versions, please use FreeRTOS v10.6.202 release or later.

Features

  • Simple, small, and easy to use – a typical RTOS kernel binary image is in the region of 6K–12K bytes
  • Flexible scheduler configuration – preemptive, cooperative, and hybrid options with optional time-slicing
  • RTOS objects (tasks, queues, semaphores, software timers, mutexes, and event groups) can be created using either dynamically or statically allocated RAM
  • Tickless mode for low-power applications
  • Mutexes with priority inheritance
  • Supports both real-time tasks and co-routines
  • Efficient software timers
  • Stack overflow detection options
  • Royalty-free

Configuration considerations

To configure FreeRTOS, copy the pre-configured FreeRTOSConfig.h file from the freertos/Source/portable folder to your project and modify the copied configuration file as needed.

See the Customization documentation for configuration options available in the FreeRTOSConfig.h file.

The following configuration values are especially important to CM0, CM0P, CM4, CM33, CM55, CR4 and CM7 FreeRTOS ports:

configCPU_CLOCK_HZ

This parameter passes the frequency of the MCU core required for the FreeRTOS system timer configuration to FreeRTOS. The pre-configured FreeRTOSConfig.h file provided with this FreeRTOS package sets the configCPU_CLOCK_HZ value as SystemCoreClock calculated by the MCU system startup code.

configMAX_SYSCALL_INTERRUPT_PRIORITY

This parameter sets the highest interrupt priority to call interrupt-safe FreeRTOS functions from. Calling the FreeRTOS functions from an interrupt with a priority higher than configMAX_SYSCALL_INTERRUPT_PRIORITYcauses FreeRTOS to generate an exception.

Warning: All unused LSB bits in configMAX_SYSCALL_INTERRUPT_PRIORITY need to be "0" beginning from FreeRTOS kernel v10.6.2

Do the following to avoid this problem:

  1. Reduce all interrupt priorities to configMAX_SYSCALL_INTERRUPT_PRIORITY or lower.

  2. Trigger an interrupt with a priority less than or equal to configMAX_SYSCALL_INTERRUPT_PRIORITY and call the FreeRTOS functions from this interrupt handler.

  3. Call the FreeRTOS functions from the traceTASKSWITCHEDOUT() macro. See FreeRTOS support.

Note: If your system pipe (IPC) interrupt priority is less than or equal to configMAX_SYSCALL_INTERRUPT_PRIORITY, be careful with code that writes to the flash (including the flash/Bluetooth® LE/Emulated EEPROM/DFU). The duration of critical sections must be kept short. For details, see the flash driver section of the PDL. For more details on PDL drivers, refer to the PDL section of ModusToolbox™ tools package user guide.

The interrupt priority parameters are ignored by the Cortex® M0/M0P ports because these CPUs use a simpler nested vectored interrupt controller (NVIC):

  • configKERNEL_INTERRUPT_PRIORITY
  • configMAX_SYSCALL_INTERRUPT_PRIORITY
  • configMAX_API_CALL_INTERRUPT_PRIORITY

See Link for more information on interrupt priority.

configHEAP_ALLOCATION_SCHEME

This parameter specifies the heap memory management scheme.

Each scheme is documented in the FreeRTOS heap memory management topic. The heap memory management implementation files are in the mtb_shared/freertos/release-vX.Y.Z/Source/portable/MemMang directory.

The following heap memory management schemes are available:

FunctionDescription
HEAP_ALLOCATION_TYPE1 (heap_1)The simplest; does not permit memory to be freed. Active by default
HEAP_ALLOCATION_TYPE2 (heap_2)Permits memory to be freed, but does not coalesce adjacent free blocks
HEAP_ALLOCATION_TYPE3 (heap_3)Simply wraps a standard malloc() and free() for thread safety
HEAP_ALLOCATION_TYPE4 (heap_4)Coalesces adjacent free blocks to avoid fragmentation. Includes the absolute address-placement option
HEAP_ALLOCATION_TYPE5 (heap_5)As per heap_4, with the ability to span the heap across multiple non-adjacent memory areas
NO_HEAP_ALLOCATIONDisables heap memory management; used for applications with static memory allocation

In the heap_3 memory scheme, your linker file must specify a sufficient size of the heap and stack, and your firmware must implement and use malloc() and free() to allocate and release memory.

In the other memory schemes, the RTOS itself allocates a stack and heap. For these schemes, the stack defined in the BSP linker file is used only by the main() function and the functions it calls.

HEAP_ALLOCATION_TYPE3 is the default heap memory management scheme enabled in FreeRTOSConfig.h. It is suggested for use with the applications that rely on malloc() and free() implementations provided by the standard C library (for example, GCC + newlib).

To avoid a possible corruption of the heap storage pool due to simultaneous calls to malloc from multiple threads, it is strongly recommended to enable the configUSE_NEWLIB_REENTRANT configuration parameter, and include the CLib FreeRTOS support library in the application.

Note: In ModusToolbox™ software, clib-support has been added as a dependency to this FreeRTOS library so that you do not need to import it separately.

For more details on heap memory management schemes, see the FreeRTOS documentation.

configTOTAL_HEAP_SIZE

This parameter specifies the total amount of RAM available for the FreRTOS heap. This parameter ignored when the heap_3 memory scheme is used.

configMINIMAL_STACK_SIZE

This parameter specifies the size of the stack used by the idle task. It is not recommended to reduce the default parameter value. Please note that when DS-RAM feature is enabled, the minimum value of this parameter should be 256.

configMINIMAL_SECURE_STACK_SIZE

This parameter specifies the size of the Secure context for nonSecure task while use NSC. The minimum value of this parameter must be 256.

configUSE_TICKLESS_IDLE

This parameter configures the tickless idle functionality required for low-power mode support.

The tickless mode is enabled automatically if the ModusToolbox™ device configurator power personality parameter "System idle power mode" is set to either "CPU Sleep" or "System Deep Sleep". The correct operation of the tickless mode depends on the vApplicationSleep hook provided by the application. See the RTOS abstraction library for the compatible implementation of the vApplicationSleep hook. The low power assistant library provides additional portable configuration layer for low-power features supported by PSoC™ 6 MCU devices.

See the following resources for more details on low-power support:

configUSE_NEWLIB_REENTRANT

This parameter enables the allocation of newlib reentrancy structures for each RTOS task. The system behavior is toolchain-specific.

  • GCC toolchain: The application must provide the implementation for the required newlib hook functions: __malloc_lock, __malloc_unlock, __env_lock, and __env_unlock. FreeRTOS-compatible implementation is provided by the clib-support library.

  • Arm®/IAR/LLVM toolchains: The application must provide the reent.h header file to adapt FreeRTOS's configUSE_NEWLIB_REENTRANT to work with the toolchain-specific C library. The compatible implementations are provided by the clib-support library.

See the following resources for more details on newlib reentrancy support:

configMAX_PRIORITIES

This parameter specifies the maximum number of discrete priorities for RTOS tasks, which are numbered 0 to configMAX_PRIORITIES-1.

  1. If timer functionality is enabled, configTIMER_TASK_PRIORITY parameter in FreeRTOSConfig.h should have value in the range of 0 to configMAX_PRIORITIES-1.

  2. Any user created RTOS-tasks should have priority value from 0 to configMAX_PRIORITIES-1.

Note: If the task priority is defined equal to or greater than configMAX_PRIORITIES then in case of Release mode the priority will be adjusted to configMAX_PRIORITIES - 1, in case of Debug mode the application will assert.

configENABLE_FPU

This parameter enables or disables the Floating Point Unit (FPU) support in the system.

FREERTOS_CONFIG_BWC_DISABLED

This define disable BWC configuration compatibility. By defining in Makefile user can check if his current configuration has no BWC issue.

Quick Start

The Quick Start section of the FreeRTOS Middleware API Reference Guide describes step-by-step instructions to set up a FreeRTOS application.

More information


(c) (2019-2025), Infineon Technologies AG, or an affiliate of Infineon Technologies AG. All rights reserved.