PlatformIO + STM32 + FreeRTOS

Hello!
I just found that I can program STM32 using VSCode + PlatformIO. Before I used the STM32Cube IDE and FreeRTOS. So I have installed latest versions of the VSCode + PlatformIO + STSTM32. And I have cloned the GIt project: https://github.com/maxgerhardt/pio-stm32h7-stm32cube-freertos/tree/main
But when I try to build this project I am gettings errors:

Building in release mode
Linking .pio\build\nucleo_h723zg\firmware.elf
.pio/build/nucleo_h723zg/libFrameworkCMSISDevice.a(system_stm32h7xx.o): In function SystemInit': system_stm32h7xx.c:(.text.SystemInit+0x0): multiple definition of SystemInit’
.pio/build/nucleo_h723zg/src/system_stm32h7xx.o:system_stm32h7xx.c:(.text.SystemInit+0x0): first defined here
.pio/build/nucleo_h723zg/libFrameworkCMSISDevice.a(system_stm32h7xx.o): In function SystemCoreClockUpdate': system_stm32h7xx.c:(.text.SystemCoreClockUpdate+0x0): multiple definition of SystemCoreClockUpdate’
.pio/build/nucleo_h723zg/src/system_stm32h7xx.o:system_stm32h7xx.c:(.text.SystemCoreClockUpdate+0x0): first defined here
.pio/build/nucleo_h723zg/libFrameworkCMSISDevice.a(system_stm32h7xx.o):(.rodata.D1CorePrescTable+0x0): multiple definition of D1CorePrescTable' .pio/build/nucleo_h723zg/src/system_stm32h7xx.o:(.rodata.D1CorePrescTable+0x0): first defined here .pio/build/nucleo_h723zg/libFrameworkCMSISDevice.a(system_stm32h7xx.o):(.data.SystemD2Clock+0x0): multiple definition of SystemD2Clock’
.pio/build/nucleo_h723zg/src/system_stm32h7xx.o:(.data.SystemD2Clock+0x0): first defined here
.pio/build/nucleo_h723zg/libFrameworkCMSISDevice.a(system_stm32h7xx.o):(.data.SystemCoreClock+0x0): multiple definition of `SystemCoreClock’
.pio/build/nucleo_h723zg/src/system_stm32h7xx.o:(.data.SystemCoreClock+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\nucleo_h723zg\firmware.elf] Error 1

In the initial project the SystemInit function appears only in the one file pio-stm32h7-stm32cube-freertos\src\system_stm32h7xx.c . So I do not understand where are from other version of this function appears and how to avoid this. Could you please help me?

This project is 4 years old and didn’t pin the used platform = ststm32@x.y.z version. if you were to use the older ststm32 version from 4 years ago (https://github.com/platformio/platform-ststm32/tags), should be

platform = ststm32@14.2.0

it should compile again.

But it should also be easily made to function against the latest version, all that’s missing is the

board_build.stm32cube.custom_system_setup = yes

https://docs.platformio.org/en/latest/frameworks/stm32cube.html#custom-system-setup-implementation

since that is telling the build system to not compile in the internal system_stm32h7xx.c. Otherwise, it will be duplicated and you get those linking errors as shown.

Thank you - this really allowed me to compile this project !

My apologies, that actually causes the build process to actually not compile the startup.S file as well. Without that, the chip won’t startup at all properly.

The right fix to get correct compilation under the latest version is to instead set

board_build.stm32cube.system_file = src/system_stm32h7xx.c

and update that system_stm32h7xx.c file to the one in e.g. cmsis-device-h7/Source/Templates/system_stm32h7xx_singlecore.c at 45b818cab6ee2806e3a27c80e330957223424392 · STMicroelectronics/cmsis-device-h7 · GitHub.

I’ve updated the project to reflect that.

Thank you very much, @ [maxgerhardt]! (https://community.platformio.org/u/maxgerhardt)
With your modifications a project from GitHub can be build. And as I added a blinking onboard LED it is really blinking - FreeRTOS is working.
Have a good day!