I created project in STM32CubeMX, next config:
Next I execute cmd: pio project init --board genericSTM32F103RC
And change platformio.ini, result:
platform = ststm32
board = genericSTM32F103RC
framework = stm32cube
lib_ldf_mode = chain+
This is SUCCESS compile.
But. I think this is bad variant.
I don’t like
If delete this line (-IMiddlewares/Third_Party/FatFs/src/drivers), then FAILED compile:
Inc/fatfs.h:28:10: fatal error: sd_diskio.h: No such file or directory
This is because the platformio does not see the file in the Middlewares/Third_Party/FatFs/src/drivers
How do I make the platformio look for files in all library directories?
At the same time, I do not want to explicitly indicate src/drivers
This is a common problem. You can find similar questions at the request of Google: “platformio include not found subdirectory”
There is no recursive solution.
Solution option 1: what is in the first message. (
build_flags = -IMiddlewares/Third_Party/FatFs/src/drivers)
Solution option 2: create library.json in …/FatFs
This is correct – STM32CubeMX generates projects with a different foler structure than PlatformIO expects ot. They’re two different systems, after all. PlatformIO expects the standardized PlatformIO folder structure or the appropriate build flags / library directives for the folder structures.
Also have a look at the example projects for STM32Cube in platform-ststm32/examples at develop · platformio/platform-ststm32 · GitHub.
I can e.g. see you’re putting the whole
Drivers/ folder with the STM32HAL and CMSIS in the PlatformIO project, but these aren’t supposed to be there, since they will be sourced from PlatformIO packages (aka loaded in
C:\Users\<user>\.platformio\packages\framework-stm32cubef1 in this case). The
Drivers/ folder in the project folder will be ignored by PIO during build, since it only builds source files in
src/ an the libraries (in
lib/ or in the manually declared path), with not-built but included header files sourced from
There are also automated conversion programs as GitHub - ussserrr/stm32pio: Automate managing of STM32CubeMX + PlatformIO projects, as discussed in PlatformIO for stm32 and CubeMX include error - #9 by ussserrr. The topic also contains the same information about the manual way of solving it with