fix: include CMSIS device header unconditionally in freertos_os2.h#184
Open
KnoerleMaTLS wants to merge 1 commit intoARM-software:mainfrom
Open
fix: include CMSIS device header unconditionally in freertos_os2.h#184KnoerleMaTLS wants to merge 1 commit intoARM-software:mainfrom
KnoerleMaTLS wants to merge 1 commit intoARM-software:mainfrom
Conversation
Move `#include CMSIS_device_header` outside the `#if defined(_RTE_)` guard so it is included for all toolchains, not only Keil MDK. Previously the device header was only included when _RTE_ was defined, which meant the SysTick macro was never available on GCC/CMake builds and SysTick_Handler in cmsis_os2.c was silently compiled out. Add an `#elif !defined(CMSIS_device_header)` error guard for non-RTE builds, matching the pattern used in os_systick.c from the CMSIS_6 repository (ARM-software/CMSIS_6). Note: handlers.c and Config/FreeRTOSConfig.h have a similar unconditional `#include "RTE_Components.h"` but are RTE-only components (Cortex-A IRQ handler / template config) and are not addressed in this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
We are integrating CMSIS-FreeRTOS into a CMake-based project using the CMSIS RTOS2 adapter layer. When building with GCC via CMake (without Keil MDK),
SysTick_Handlerwas silently missing from the final binary, causing the RTOS to never tick. The root cause turned out to be the device header include being gated behind a Keil-specific macro.Problem
In
CMSIS/RTOS2/FreeRTOS/Include/freertos_os2.h,#include CMSIS_device_headeris guarded by#if defined(_RTE_). The_RTE_macro is Keil MDK-specific and is not defined when building with GCC, CMake, or other non-Keil toolchains. As a result, the CMSIS device header is never included incmsis_os2.c, theSysTickmacro is never defined, andSysTick_Handlerinside the#if defined(SysTick)block is silently compiled out.Fix
Move
#include CMSIS_device_headeroutside the#if defined(_RTE_)guard so it is included unconditionally. Add an#elif !defined(CMSIS_device_header)error guard for non-RTE builds, matching the pattern used inos_systick.cfrom ARM-software/CMSIS_6.Validation
Build
cmsis_os2.cwith a GCC-based toolchain using-DCMSIS_device_header=\"<device>.h\"(without-D_RTE_) and verify:SysTick_Handleris present in the object file._RTE_) are unaffected.Note
handlers.candConfig/FreeRTOSConfig.hhave a similar unconditional#include "RTE_Components.h"but are RTE-only components (Cortex-A IRQ handler / template config) and are not addressed here.References