Skip to main content
Graduate II
October 2, 2025
Solved

CMSIS RTOS v2 projects - confusion about headers: cmsis_os.h or cmsis_os2.h ?

  • October 2, 2025
  • 4 replies
  • 785 views

Hi

 

In the past 6 months, I created a project for an STM32H755. For middleware, I selected CMSIS RTOS v2 (using FreeRTOS underneath).

I noted that the header file is cmsis_os.h, which at first seemed wrong. I (maybe naively) asked the "AI", and with it's usual confident tone, suggested I change them (however, this is hard to maintain if you change your .ioc file).

Looking at past posts on these forums, and inside cmsis_os.h, I confirmed that cmsis_os2.h is indeed included within it (despite the AI not finding this).

So, I challenged the "AI", stating what I had found. Of course, in it's somewhat complimentary way, it agreed with me, but still insisted that if I am using entirely v2 APIs, I should change the headers.

Of course, such responses derive from human content written elsewhere, and I fear it may not backed by actual facts. I have left the headers as they are for now. I have a bad feeling about changing them as ST might have reasons to do things the way they have.

 

So, is it good practise (or a bad idea) to change all #include "cmsis_os.h" to "cmsis_os2.h" ? 

 

 

 

    This topic has been closed for replies.
    Best answer by Khaled_DHIF

    Hello @NickO ,

    In recent and upcoming versions of STM32CubeMX, "#include cmsis_os2.h" is now used directly for CMSIS-RTOS v2 projects.

    • For older projects or STM32 families, cmsis_os.h is still common and remains fully compatible, as it internally includes the newer cmsis_os2.h.
    • For new projects, simply follow the header file generated by CubeMX—use cmsis_os2.h if that’s what is provided.
    • Both headers are valid, but cmsis_os2.h is becoming the new standard for CMSIS-RTOS v2 development.

    Kind regards, 

    DHIF Khaled

    4 replies

    Super User
    October 2, 2025

    @NickO wrote:

    I noted that the header file is cmsis_os.h, which at first seemed wrong.


    Was this actually causing any problems, or is this just a semantic concern about the name?

    NickOAuthor
    Graduate II
    October 2, 2025

    No problems. It's more a safety issue for me, and knowing why things are the way they are.

    • On the one hand, I don't want to accidentally mix v1 and v2 APIs if that might cause a problem (which is sometimes suggested).
    • Equally, I don't feel informed enough to change the headers just because some AI robot says I should.

     

    Super User
    October 2, 2025

    It's not uncommon for stuff like this to include backwards compatibility with previous versions.

    If it doesn't cause any problems, I'd leave it.

    I don't think that the name "cmsis_os.h" necessarily implies any specific version?

    October 2, 2025

    From my experience, it's usually safer not to change the headers manually unless there is an official note in the documentation. Since cmsis_os.h already includes cmsis_os2.h, it looks like ST made this intentional for backward compatibility. Unless you see real conflicts or errors, leaving it as is should avoid unnecessary issues.

    Super User
    October 2, 2025

    @Jessica_Alleen wrote:

     it looks like ST made this intentional 


    Could even have been ARM ...

    Super User
    October 2, 2025

    Hi,

    cmsis_os2.h is for Version 2 of the CMSIS-RTOS API. File cmsis_os.h is for version 1.

    Version 2 is *not* a drop-in replacement of v.2, so if you have code written for v.1 and want to upgrade to v.2, you have to review and fix incompatibilities. AI usually are great for this task, but yours seems to be broken :(

    If you are new to the CMISIS RTOS, you may want to start with version 2 - or bypass the wrappers and directly work with FreeRTOS. After all, it is not so horrible as some say. If the AI robot makes trouble, you can find real live humans here

     

     

    NickOAuthor
    Graduate II
    October 2, 2025

    Thanks for responding.

    The CMSIS API appeals as it makes it easier to switch OS (e.g. as part of a strategy for adding diversity into safety critical applications).

    I do appreciate what you say, but when I created the project, I specifically selected v2 of the API. However, the include headers generated by Cube IDE are the same for v1 which seemed odd at first.

    The consensus is that this is not a bug as some (human and otherwise) suggested elsewhere. The suggestion to change it to cmsis_v2.h might seem sensible, but until I see a definitive statement to say this is safe and best practise from ST, I shall leave it and just check I am using the latest APIs myself.

     

     

    Super User
    October 3, 2025

    Indeed, the devil is in details, and every tiny bit of change can be yes/no for the unprepared. 

    Note that FreeRTOS is bundled in the "cube" library packages for older MCUs (including H7). For these packages you cannot choose a version, just get what is available in the package. Of course, user can later update FreeRTOS to whatever version they want to. 

    For newer MCUs FreeRTOS is a separate package "X-CUBE-FREERTOS" https://github.com/STMicroelectronics/x-cube-freertos , it can be added to Cube-generated projects via the "software pack" GUI. These packages can have several versions to choose.

     

     

     

    ST Employee
    October 2, 2025

    Hello @NickO ,

    In recent and upcoming versions of STM32CubeMX, "#include cmsis_os2.h" is now used directly for CMSIS-RTOS v2 projects.

    • For older projects or STM32 families, cmsis_os.h is still common and remains fully compatible, as it internally includes the newer cmsis_os2.h.
    • For new projects, simply follow the header file generated by CubeMX—use cmsis_os2.h if that’s what is provided.
    • Both headers are valid, but cmsis_os2.h is becoming the new standard for CMSIS-RTOS v2 development.

    Kind regards, 

    DHIF Khaled

    NickOAuthor
    Graduate II
    October 2, 2025

    Hi

     

    Many thanks for this.

    I just checked Cube IDE 1.19.0, Cube 1.12.1 for STM32H755 (maybe Cube MX is different?).

    It is still using cmsis_os.h

    Maybe the next version will change this. I shall look out for it.

     

    Regards