PlatformIO Community

Framework optional dependency on library can't be resolved

framework-stm32cube has a config file for its library which can pull external dependency. Problem is, that the dependency is not resolved by PIO LDF so it fails to build.

In details

  • In framework-stm32cubef4 there is library STM32_USB_Host_Library.
  • This library depends on usbh_config.h which I can be provided in the include folder which works
  • I can enable OS support by USBH_USE_OS in this file and I must provide also #include <cmsis_os.h>.
  • I can provide RTOS support by PlatformIO-FreeRTOS as lib_deps
  • I can provide lib/cmsis_os with FreeRTOS<–>CMSIS_OS wrapper files

All lib_deps and local libraries are correctly scanned so they can use cmsis_os and freertos

|-- <LwOW> 3.0.2
|   |-- <cmsis_os>
|   |   |-- <PlatformIO-FreeRTOS> 2.1.3

But dependencies of libraries provided by the framework are not resolved.

|-- <STM32_USB_Host_Library-MSC>
|   |-- <STM32_USB_Host_Library-Core>

Should continue with

|   |   |-- <cmsis_os>
|   |   |   |-- <PlatformIO-FreeRTOS> 2.1.3

but it does not. So the STM32_USB_Host_Library compiles with an error fatal error: cmsis_os.h: No such file or directory

What is the correct way to solve this dependency?

  • framework-stm32cubef4 already has its own FreeRTOS and cmsis_os in Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/ but they are not available (visible) from PlatformIO.
  • I can add build_flags = -I lib/cmsis_os so the cmsis_os.h is satisfied but it immediately failed on FreeRTOS.h. This file is provided by lib_deps = PlatformIO-FreeRTOS which I don’t know how to correctly force to include. But in general, this is also a bad solution.
  • I can stop using the framework and all the lib_deps and copy everything locally but this is not preferred way.
  • The best option would be to persuade LDF to search framework dependencies also in regular libraries

Changing lib_ldf_mode brings no change?

Even deep+ did not search from framework dependencies in user libraries.

Can you upload the exact project that is failing?

Notice that the library dependency finder has some non working edge cases (Replace LDF deep with native GCC Preprocessor · Issue #3113 · platformio/platformio-core · GitHub, Library dependency not recognized in conditional include · Issue #4152 · platformio/platformio-core · GitHub), so maybe you’re running into that.