2026-05-04 4:09 AM - last edited on 2026-05-04 5:45 AM by Sara BEN HADJ YAHYA
Hello,
Is there a way to generate code with MX2 by using the CMSIS-RTOS2 API vs the FreeRTOS API? I cannot find a setting in the FreeRTOS configuration to specify that I would like to use the CMSIS-RTOS2 API.
Thank you,
-GIl
Solved! Go to Solution.
2026-05-05 3:05 AM
Hello @gil_dobjanschi ,
No. In the current STM32CubeMX2 flow for STM32C5, code generation exposes the native FreeRTOS kernel API directly and does not provide a CMSIS-RTOS2 abstraction layer. That’s why there is no setting to select CMSIS-RTOS2 in the FreeRTOS configuration.
Kind regards,
DHIF Khaled
2026-05-05 3:05 AM
Hello @gil_dobjanschi ,
No. In the current STM32CubeMX2 flow for STM32C5, code generation exposes the native FreeRTOS kernel API directly and does not provide a CMSIS-RTOS2 abstraction layer. That’s why there is no setting to select CMSIS-RTOS2 in the FreeRTOS configuration.
Kind regards,
DHIF Khaled
2026-05-05 3:46 AM
As @Khaled_DHIF said, ST do not provide this.
But FreeRTOS is an independent, 3rd-party product - so there's nothing to stop you doing it yourself.
eg, see: Where to find if specific STM32 MCU supports specific CMSIS-RTOS version?
2026-05-05 5:25 AM
Thank you @Khaled_DHIF and @Andrew Neil !
2026-05-05 7:15 AM - edited 2026-05-05 7:17 AM
Option to generate for CMSIS-RTOS can be interesting, especially for education users.
Some people already tried to fiddle the generation templates. Maybe it still is possible with MX2.
If not - perhaps the usual AI coding things can be tasked to convert FreeRTOS code to CMSIS-RTOS?
2026-05-05 9:58 PM
Hi @Pavel A.
For what is worth I ended up using FreeRTOS API. In my case the benefit to have the API mapping wasn't that great because I do not expect users to switch RTOS. Additionally, I am using xQueueCreateSet which I could not map to an API in CMSIS-RTOS2 as far as I can tell.
Your suggestion to use AI to generate the code is a viable one. I used Claude to generate the code and it looks reasonable. I did not look at it in detail but with a bit of determination it can be done. One just needs the clear motivation.
Regards,
-GIl