Can't find CMSIS RTOS2 on Nucleo-L452RE with stm32cube framework

Hello,
I’m trying to figure out the cleanest way to resolve a small dependency issue. Basically, I would like to use CMSIS ROTS2 in my project so I can have access to their threading library. Fortunately, it seems this is actually included with the stm32cube framework itself, When I go to .platformio\packages\framework-stm32cubel4\Drivers\CMSIS I can clearly see the library is there:

However, there are 2 issues. The first (and most pressing) issue is that for some reason none of these files are compiled into my project so the linker fails to find the function definitions. I get a ton of messages from the linker saying undefined reference to 'osKernelInitialize'.

The second issue (which seems very related) is that the header files aren’t found.

I tried copying the source files into lib/ but there are a bunch of extra steps with this that each felt more and more like I was making the wrong decision. There were files such as arm_bitreversal2.c and arm_bitreversal2.S that confused the compiler since it didn’t know which to build. I needed to add -I includes for all the subdirectories inside all the CMSIS subdirs. I’m also not a fan of the fact that these files will be ‘competing’ with the built-in headers that ARE included from the Include directory. I’m worried about what might happen if we updated the built-in library and its now different from the version I copy/pasted.

Does anyone know the best way I might be able to get this compiling?

I assume you’re using framework = stm32cube in your project?

The thing is that the builder script for STM32Cube does not support including / building the CMSIS-RTOS component by default. It just uses the Device and DSP folder in there, see source.

Which means that firmwares wishing to use CMSIS-RTOS2 must include the source-code and configuration for it themselves.

Config isn’t that hard though once some caveats have been figured out (which timer to use as a tick-base, which compiler options, …). An example project is available at GitHub - maxgerhardt/OSProject: Project that uses RTOS on the stm32l476g_discovery board for a disco_l476vg. Note that the CMSIS-RTOS2 version is also 2 years old there and some things might have changed.

I’ll do the following:

  • file a feature request in Issues · platformio/platform-ststm32 · GitHub so that the build script might be expanded to allow easy inclusion and configuration of CMSIS-RTOS2
  • recreate my simple project above with the newest CMSIS-RTOS2 version and your target board.

Okay, there’s an actual problem here. The stm32cube package used by PlatformIO doesn’t contain the actual source files for CMSIS-RTOS2.

The entire RTX core files is missing, and this is where the real juice is, compare CMSIS_5/CMSIS/RTOS2 at develop · ARM-software/CMSIS_5 · GitHub.

This issue will be tracked in Expand stm32cube builder script to build CMSIS-RTOS2 component · Issue #481 · platformio/platform-ststm32 · GitHub, too.

Thanks for the response. Pasting my response to the github issue so others can find it:

The code that STMCubeMx generates also doesn’t include that. I think that it tries to use FreeRTOS for all of the internals. I believe all the code is there, its just not setup to build that code. I could be wrong though.