Is STM32H747I-DISCO BSP compatible with stm32cube framework?

I am trying to port this example to PlatformIO.
The example is working in Visual Studio 2022.

Question

Output of platformio lib search "header:stm32h747i_discovery.h"

WARNING: This command is deprecated and will be removed in the next releases. 
Please use `pio pkg search` instead.

Found 1 libraries:

BSP_DISCO_H747I
===============
#ID: 9803
BSP files for STM32H747I-Discovery Copy from ST Cube delivery

Compatible frameworks: Mbed
Compatible platforms: Freescale Kinetis, NXP LPC, Silicon Labs EFM32, ST STM32, Teensy, Nordic nRF52, Maxim 32, WIZNet W7500, RISC-V GAP, NXP i.MX RT
Authors: ST

Does this mean BSP is not supported if framework = stm32cube?

Setup and Motivation

My setup:

Ubuntu 20.04
VS Code 1.67.2
PIO Core 6.0.2
Board STM32H747XI-DISCO

my platformio.ini:

[env:disco_h747xi]
platform = ststm32
board = disco_h747xi
framework = stm32cube
build_flags = -DCORE_CM7

When I try to build I get:

Processing disco_h747xi (platform: ststm32; board: disco_h747xi; framework: stm32cube)
-----------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/disco_h747xi.html
PLATFORM: ST STM32 (15.4.0) > STM32H747I-DISCO
HARDWARE: STM32H747XIH6 400MHz, 512KB RAM, 2MB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES: 
 - framework-stm32cubeh7 @ 1.9.0 
 - tool-ldscripts-ststm32 @ 0.2.0 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 55 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/disco_h747xi/src/main.o
Compiling .pio/build/disco_h747xi/src/stm32h7xx_hal_msp.o
Compiling .pio/build/disco_h747xi/src/stm32h7xx_it.o
In file included from src/main.c:21:0:
include/main.h:25:10: fatal error: stm32h747i_discovery.h: No such file or directory

******************************************************************************
* Looking for stm32h747i_discovery.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:stm32h747i_discovery.h"
* Web  > https://registry.platformio.org/search?q=header:stm32h747i_discovery.h
*
******************************************************************************

 #include "stm32h747i_discovery.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from src/stm32h7xx_hal_msp.c:20:0:
include/main.h:25:10: fatal error: stm32h747i_discovery.h: No such file or directory

******************************************************************************
* Looking for stm32h747i_discovery.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:stm32h747i_discovery.h"
* Web  > https://registry.platformio.org/search?q=header:stm32h747i_discovery.h
*
******************************************************************************

 #include "stm32h747i_discovery.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
In file included from src/stm32h7xx_it.c:20:0:
include/main.h:25:10: fatal error: stm32h747i_discovery.h: No such file or directory

******************************************************************************
* Looking for stm32h747i_discovery.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:stm32h747i_discovery.h"
* Web  > https://registry.platformio.org/search?q=header:stm32h747i_discovery.h
*
******************************************************************************

 #include "stm32h747i_discovery.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/disco_h747xi/src/stm32h7xx_it.o] Error 1
*** [.pio/build/disco_h747xi/src/main.o] Error 1
*** [.pio/build/disco_h747xi/src/stm32h7xx_hal_msp.o] Error 1
=================================================== [FAILED] Took 1.59 seconds ===================================================
The terminal process "platformio 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Even if I added to c_cpp_properties.json:

 "/home/abet/.platformio/packages/framework-stm32cubeh7/Drivers/BSP/STM32H747I-DISCO",

Going through the library manager is the wrong way. The documentation holds the answer.

https://docs.platformio.org/en/latest/frameworks/stm32cube.html#custom-build-variant

As you can see in C:\Users\<user>\.platformio\packages\framework-stm32cubeh7\Drivers\BSP\STM32H747I-DISCO, the header you are looking for is right there in the Drivers\BSP folder of the firmware. As linked above, PlatformIO can build include that BSP library in the build if you tell it to, that is, you have to set

However, you will see that when you add the STM32H747I-DISCO as the stm32cube variant by adding

board_build.stm32cube.variant = STM32H747I-DISCO

to the platformio.ini.

What you will then run into is however that this BSP comonent will want a configuration header file, stm32h747i_discovery_conf.h, that you have to provide in your project as the user. So, just copy STM32CubeH7/Projects/STM32H747I-DISCO/Examples/ADC/ADC_DualModeInterleaved/Common/Inc/stm32h747i_discovery_conf.h at master · STMicroelectronics/STM32CubeH7 · GitHub from your target project as stm32h747i_discovery_conf.h into the include/ folder of the project and make this header globally visible by adding the include/ folder to the include search path of GCC by using the -I flag. All in all, you have

[env:disco_h747xi]
platform = ststm32
board = disco_h747xi
framework = stm32cube
build_flags = -DCORE_CM7 -Iinclude
board_build.stm32cube.variant = STM32H747I-DISCO

then. You will then notice an error with

In file included from C:\Users\Max\.platformio\packages\framework-stm32cubeh7\Drivers\BSP\STM32H747I-DISCO\stm32h747i_discovery_ts.h:35:0,
c:\users\max\.platformio\packages\framework-stm32cubeh7\drivers\bsp\components\ft6x06\ft6x06.h:32:10: fatal error: ft6x06_conf.h: No such file or directory

which comes from PlatformIO compiling all source files within that BSP folders instead of the reference project only compiling Drivers/BSP/STM32H747I_DISCO/stm32h747i_discovery.c but not anything else. Sadly I just didn’t quickly find out how to apply a global source filter, build_src_filter is just for the project’s src/ folder.

So, two ways:

  • copy all needed config header files that show from their components directory into the include/ folder of the project, or
  • just additionally copy stm32h747i_discovery.c into src/ and stm32h747i_discovery_errno.h and stm32h747i_discovery.h into include and remove board_build.stm32cube.variant.

Latter is easy and works fine.

I’ve actually filed a request from improving this in Allow global source filter · Issue #4303 · platformio/platformio-core · GitHub.

1 Like

@maxgerhardt thanks a lot, that was very informative!
After downloading the stm32CubeProgrammer I was able to debug the example :slight_smile:

So, to wrap up:
my platformio.ini

[env:disco_h747xi]
platform = ststm32
board = disco_h747xi
framework = stm32cube
build_flags = -DCORE_CM7 -Iinclude

I also had to manually had a fiew files:

  • stm32h747i_discovery.h stm32h747i_discovery.c and stm32h747i_discovery_errno.h(BSP)
  • stm32h4741_discovery_conf.h (project configuration file)
  • all other project specific files.

image
(project name is wrong)