Skip to content

Fix RTOS_V2 cmsis_os2.h search path for newer STM32Cube packages#362

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-cmsis-os2-search-path
Draft

Fix RTOS_V2 cmsis_os2.h search path for newer STM32Cube packages#362
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-cmsis-os2-search-path

Conversation

Copy link

Copilot AI commented Jan 11, 2026

FindCMSIS.cmake searches for RTOS files only in Middlewares/Third_Party/FreeRTOS/Source/CMSIS_${RTOS_COMP}. This works for RTOS (cmsis_os.h) but fails for RTOS_V2 (cmsis_os2.h), which lives in Drivers/CMSIS/RTOS2/ in newer STM32Cube packages (e.g., STM32CubeH5).

Changes

  • Added Drivers/CMSIS/RTOS2/Include to header search paths for cmsis_os2.h
  • Added Drivers/CMSIS/RTOS2/Template to source search paths for cmsis_os2.c
  • Maintains backward compatibility by keeping original Middlewares path
find_path(CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_PATH
    NAMES "cmsis_os${RTOS_COMP_VERSION}.h"
    PATHS
        "${STM32_CUBE_${FAMILY}_PATH}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_${RTOS_COMP}"
        "${STM32_CUBE_${FAMILY}_PATH}/Drivers/CMSIS/RTOS2/Include"
    NO_DEFAULT_PATH
)

Both RTOS and RTOS_V2 components now resolve correctly across all STM32Cube package versions.

Original prompt

This section details on the original issue you should resolve

<issue_title>RTOS_V2's cmsis_os2.h is searched for incorrectly</issue_title>
<issue_description>Currently, FindCMSIS.cmake searches for it like so.

        find_path(CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_PATH
            NAMES "cmsis_os${RTOS_COMP_VERSION}.h"
            PATHS "${STM32_CUBE_${FAMILY}_PATH}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_${RTOS_COMP}"
            NO_DEFAULT_PATH
        )

This code is correct for cmsis_os.h, but not for cmsis_os2.h. That file lives under ${STM32_CUBE_${FAMILY}_PATH}/Drivers/CMSIS/RTOS2/Include. That's at least true for STM32H5; see here.</issue_description>

Comments on the Issue (you are @copilot in this section)

@Hish15 Hello @tcbennun, is changing this path enough to make it work for you ? If it is, the fix on this repo is just to add the path like so : ```cmake find_path(CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_PATH NAMES "cmsis_os${RTOS_COMP_VERSION}.h" PATHS "${STM32_CUBE_${FAMILY}_PATH}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_${RTOS_COMP}" "${STM32_CUBE_${FAMILY}_PATH}/Drivers/CMSIS/RTOS2/Include" NO_DEFAULT_PATH ) ```

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Hish15 <29129731+Hish15@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incorrect search path for cmsis_os2.h Fix RTOS_V2 cmsis_os2.h search path for newer STM32Cube packages Jan 11, 2026
Copilot AI requested a review from Hish15 January 11, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTOS_V2's cmsis_os2.h is searched for incorrectly

2 participants