PlatformIO FreeRTOS

Hi

I’m using a Nucleo-H723ZG board and I would like to know how to include FreeRTOS into a PlatformIO project.

thanks

That highly depends on the framework you’re working with.

We are using stm32cube.

We’re trying to use STM32 Cube MX to generate a HAL project without including ST’s version of FREERTOS, then use the PlatformIO framework-stm32cubeh7 package to provide FreeRTOS.

In:
~/.platformio/packages/framework-stm32cubeh7/Middlewares/Third_Party/FreeRTOS/Source

FreeRTOS seems to be bundled with the ststm32 platform.

thanks

Indeed but PlatformIO does not yet provide a way to easily use this source. But one can create a project using those files (while removing the files that don’t match).

That process for adding FreeRTOS is always the same though: Add FreeRTOS base source files, add port-specific (here: ARM_CM7) files, select heap implementation, add configuration. See e.g. gd32-pio-projects/gd32-spl-freertos at main · CommunityGD32Cores/gd32-pio-projects · GitHub.

Let me spin up a sample project.

Hi

PlatformIO seems to be very keen in using its own STM32 drivers:

.pio/build/env_nucleo_h723zg/FrameworkHALDriver/Src/stm32h7xx_hal_spi_ex.o
.pio/build/env_nucleo_h723zg/FrameworkHALDriver/Src/stm32h7xx_hal_dma_ex.o
.pio/build/env_nucleo_h723zg/FrameworkHALDriver/Src/stm32h7xx_hal_wwdg.o
.pio/build/env_nucleo_h723zg/FrameworkHALDriver/Src/stm32h7xx_hal_rtc_ex.o

Is there anyway of not doing this? So that we can import everything we need from STM32CubeIDE?

thanks

This is the entire point of PlatformIO. When using framework = stm32cube in the platformio.ini, PlatformIO supplies the framework files, like the STM32HAL and CMSIS headers, so that they don’t have to be in the project. Check out reference projects like this.

Otherwise you’d just be doing a baremetal project with all files supplied from the autogenerated project and no framework-specific help from PlatformIO. Of course baremetal projects are also possible with PlatformIO, see e.g. here – just remove the framework = stm32cube and you will loose all automatic settings from the STM32Cube builder scripts and PIO will will only compile the sources in src/ and referenced libraries in lib/.

I’ve auto-generated a STM32Cube project with FreeRTOS and converted it to PlatformIO (aka, I have done the astonishing work of copying files from 3 folders of the auto-generated project into the PlatformIO project and gave it a platformio.ini): GitHub - maxgerhardt/pio-stm32h7-stm32cube-freertos

A baremetal variant that sources all files from the genenerated STM32Cube project can be found in the baremetal branch: GitHub - maxgerhardt/pio-stm32h7-stm32cube-freertos at baremetal

1 Like

When I remove the framework option I get an error:

Compiling .pio/build/env_nucleo_h723zg/src/Core/Startup/startup_stm32h723zgtx.o
arm-none-eabi-as: unrecognised option ‘-x’
Compiling .pio/build/env_nucleo_h723zg/src/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.o
*** [.pio/build/env_nucleo_h723zg/src/Core/Startup/startup_stm32h723zgtx.o] Error 1

I cannot find in PlatformIO.ini the -x option…

However when I build in verbose mode the -x appears:

Building in release mode
arm-none-eabi-as -x assembler-with-cpp -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m7 -o .pio/build/env_nucleo_h723zg/src/Core/Startup/startup_stm32h723zgtx.o src/Core/Startup/startup_stm32h723zgtx.s
arm-none-eabi-as: unrecognised option ‘-x’
arm-none-eabi-gcc -o .pio/build/env_nucleo_h723zg/src/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.o -c -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -DF_CPU=550000000L -DPLATFORMIO=50200 -DSTM32H7xx -DSTM32H723xx -DEVAL -DSTM32H723xx -I/home/wsone/.platformio/platforms/ststm32/builder/include -Isrc -Isrc/Core/Inc -Isrc/Drivers/CMSIS/Include -Isrc/Drivers/CMSIS/Device/ST/STM32H7xx/Include -Isrc/Drivers/STM32H7xx_HAL_Driver/Inc -Isrc/Middlewares/Third_Party/FreeRTOS/Source/include -Isrc/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -Isrc/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 src/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c
*** [.pio/build/env_nucleo_h723zg/src/Core/Startup/startup_stm32h723zgtx.o] Error 1

Strangely here:
https://manpages.debian.org/unstable/binutils-arm-none-eabi/arm-none-eabi-as.1.en.html
the -x option is supported but is ignored:
-x Ignored.

I have this version of the assembler:
wsone@wsone-VirtualBox:~/.platformio/packages/toolchain-gccarmnoneeabi/bin$ ./arm-none-eabi-as --version
GNU assembler (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 2.29.51.20171128

Startup files need to have a .S extension to be recognized as “Assembly with C++”. The -x option is inteded for gcc as -x assembler-with-cpp. I fixed that in pio-stm32h7-stm32cube-freertos/src/Startup/startup_stm32h723zgtx.S at baremetal · maxgerhardt/pio-stm32h7-stm32cube-freertos · GitHub now, you’ll need to delete the folder & download it again.

Another bug bites the dust… :slight_smile:

But still…
I would like to use the .ld file provided by STM32CubeIDE.
Any magical option to do do that? :slight_smile:

thanks

The project already does that

by using the documented option to change the linkerscript. The file must be locally in the project folder then.

1 Like