PlatformIO Community

Problem including the BSP APIs for stm32f4 discovery

Problem including the stm32 bsp source files after updating the stmcube firmware.image .
Tried including it manually using th build flags. image
i can go to the function definition using f12 though, but fails during compilation.
Copying the source file in the project directory works too. Any correct solution i’m missing here ?

Have you set board_build.stm32cube.variant = STM32F4-Discovery in the platformio.ini? See official example that uses BSP functions and STM32Cube.

What’s the full code and platformio.ini?

1 Like

The .ini file does have the board variant. wouldn’t that become redundant ?
Also, i’m simply using the BSP functions after including.

#include “stm32f4_discovery.h”.

Ctrl + click takes me to the function definition in the c file too. everything works on manually including the .c file
worked perfectly fine before the framework update.

Just adding -I include flag will make GCC recognize the header in the include path, but not actually build anything. Thus the undefined reference errors that you have.

You mean it does not, I don’t see board_build.stm32cube.variant = STM32F4-Discovery there.

In version 10 of ST-STM32 platform, STM32Cube support was majorly redone.

How do i include the source files manually then ? without actually copying the c file in my project directory. Can’t edit the .json file manually.
Doesn’t this recognize the board for me ?

board = disco_f407vg

works for other projects with only the HAL layer.
Thanks for the response

By setting that option stated above, the python builder script will include the BSP libraries for you then. As said, this was changed since version 10.

As you can see, Drivers/BSP/xyz is only included when the stm32cube.variant attribute it set, which it is not in the disco_f407vg.json file, thus you can set it as shown above in the platformio.ini. I’ve proposed to also automatically change this in

Otherwise of course, code is only built if it’s in the src/ folder, in one of the lib/ subfolders, declared via lib_deps or in the framework files which the builder script chooses.

Yes it recognizes the board but without the attribute above, no BSP libraries are built, due to the builder script and the current state of the board’s JSON file.

Yup, that works. although, the compilation now breaks due to the pdm2pcm_glo.h.
Fixed that by adding the directory with the built flags. Copying the file seems a little too straightforward at this point though.
Thanks for the almost instant replies and the explanations.

Oh okay that is a problem because the file is truly not there


I will open an issue for that, since that should be there.

You could only save it by including it from the previous framework-stm32cube.

Please note that

is technically wrong. framework-stm32cubef4 is the new package that the STM32 platform since version 10 uses. You still have the framework-stm32cube package from the last versions and include files from there in a project that uses the newer platform versions – that’s dangerous. No build_flags should be needed for the BSP anymore though if you have the variant option enabled now.

As a nicer workaroudn you can put the originally missing file in the include/ folder of the project and add -I include to the build flags and remove the reference to the framework-stm32cube folder.

Edit: Aha that is actually wanted in the new STM32Cube versions:

So you would have to add those files yourself if you agree to the license.

Also note that per docs and releases you can choose to use an older platform version for a project, as in platform = ststm32@9.0.0 in the platformio.ini. Then it should work without any major modifications.

works perfectly again with

platform = ststm32@9.0.0

added to the .ini file. thanks !
For the newer projects i create, i still get my .json file listing all dependencies from framework-stm32cube and not stm32cubef4, which is present in the packages directory. wonder why that is if the stm32cubef4 was separately added with the update. on changing to stm32cubef4 in the .ini file i get,

Error: This board doesn’t support stm32cubef4 framework!

Nono, framework = stm32cube is correct to select the framework, it’s just that the internal PlatformIO package management has split up the STM32Cube packages into framework-stm32cubef4, framework-stm32cubef3 etc. The old ST-STM32 version had just one framework-stm32cube folder which contained everything.

So if one would just use the newest platform version from a clean installation, framework-stm32cube will not exist when using STM32Cube. Thus it’s needed to copy the missing header file, e.g.

1 Like

Got it !. Thanks a lot.