-
Notifications
You must be signed in to change notification settings - Fork 17
Build the FreeRTOS CMake template with IAR
Felipe Torrezan edited this page Jul 1, 2025
·
4 revisions
This interactive example describes how to build the FreeRTOS template example with IAR.
For this example we will use the FreeRTOS official cmake_example
project sources from https://github.com/freertos/freertos-kernel and build it for an Arm Cortex-M4 target:
Project files |
---|
examples/cmake_example/CMakeLists.txt |
examples/cmake_example/main.c |
examples/template_configuration/FreeRTOSConfig.h |
The main()
function starts the FreeRTOS Kernel and runs a periodic task. For more information, refer to the FreeRTOS Beginners Guide.
Prepare the template by filling the missing information in examples/cmake_example/CMakeLists.txt
(click to show/hide answers):
TODO 1: Enable Assembly.
project(example C ASM)
TODO 2: Set the FREERTOS_PORT to the desired target.
set(FREERTOS_PORT "IAR_ARM_CM3" CACHE STRING "" FORCE)
TODO 3: Compile the library for the desired target CPU.
target_compile_options(freertos_kernel PRIVATE
### Previous options
### IAR C Options
$<$<COMPILE_LANG_AND_ID:C,IAR>:--cpu=cortex-m4> )
TODO 4: Add compiler flag for building the application for the desired target CPU.
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<COMPILE_LANG_AND_ID:C,IAR>:--cpu=cortex-m4> )
TODO 5: Add linker flag for enabling Arm semihosting for printf().
target_link_options(${PROJECT_NAME} PRIVATE
$<$<COMPILE_LANG_AND_ID:C,IAR>:--semihosting> )
TODO 6: Set C_STANDARD to a compatible value.
In CMake, the C_STANDARD is computed automatically for the language standard provided by the IAR Compiler.
# set_property(TARGET freertos_kernel PROPERTY C_STANDARD 90)
The template configuration needs to be updated adequately for the desired target. In the examples/template_configuration/FreeRTOSConfig.h
perform the following tasks (click to show/hide answers):
TODO 1: Update configTICK_TYPE_WIDTH_IN_BITS.
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS
TODO 2: Update configMAX_SYSCALL_INTERRUPT_PRIORITY.
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 5
NOTES See https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/ARM-Cortex/RTOS-Cortex-M3-M4 for more information.
- Finally, build and test the project. Refer to the tutorial for more information.
This is the cmake-tutorial wiki. Back to Wiki Home
- Setting language-specific target options
- Selecting build types
- Using Ninja Multi-Config
- Filing a build log
- Multi-file compilation
- Invoking IAR binary utilities
- Use the IAR ELF Tool to convert executable targets to their binary formats