Using FreeRTOS in PlatformIO

Alright so I’ve got myself thoroughly confused - maybe someone here can show me the light?

I’m trying to program a STM32F407VE MCU with PlatformIO using the stm32cube framework. I’ve got my environment successfully working and I can upload “led blink” code to my dev board using the settings below and it works great.

[env:genericSTM32F407VET6]
platform = ststm32
board = genericSTM32F407VET6
framework = stm32cube
upload_protocol = jlink

Now, I want to use an RTOS. STM provides a folder with a copy of FreeRTOS which supposedly works with my hardware and the stm32cube libraries. This folder includes examples using FreeRTOS on their dev boards but using IAR or some other IDE instead of PlatformIO.

The FreeRTOS folder provided has the normal FreeRTOS structure -> a Source folder with critical files and some sub-folders “CMSIS_RTOS”, “include”, and “portable”. The actual “FreeRTOS.h” file is under the “include” sub-folder. I currently have this entire FreeRTOS folder structure in the “lib” folder in platformIO but (expectedly) this is not working.

Of course I have “FreeRTOS.h” included at the top of my main.c file in “src” of my platformIO project, but on compilation, PlatformIO can’t find any FreeRTOS files.

How do I use FreeRTOS structure with PlatformIO? Can I restructure it somehow so it behaves as a normal library? Can I somehow make platformIO include all of my FreeRTOS sub-directories recursively?

Thanks for the help!

1 Like

I have gotten it to work, but had to step outside platformio to do it. So I won’t describe that here.

If you go with a mbed application, their version of RTOS is available by including “rtos.h” in the header, doing a “build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT” and “lib_ldf_mode = chain+” in your platform.ini file.

If you get some weird compile errors, try replacing “platform = ststm32@4.4.0” in your board def.

Sure it’s not a cube app, but cube apps are a kludge in this environment.

Thanks for the tip!

I was originally trying to get the mbed RTOS to work with this MCU before I tried the cube app!

The problem I ran into was quite possibly what you describe with compiler errors - the mbed RTOS didn’t seem to support this MCU. Upon further research, I found a post saying mbed was only good to version 2.0 on this MCU instead of the latest mbed-os / 5.0 version - thus the RTOS component would not build. Very frustrating!

By setting an ?older? version of ststm32 platform manually, are you forcing mbed to use the older version of it’s RTOS library? I’ll give your settings a shot regardless.

Thanks!

yes, it forces it to use an older version. I don’t know the actual number you will need to use to get back to 2.x, but I am sure the support here would give you that info.