Building PlatformIO projects with mainline Zephyr source trees

My intent is to use PlatformIO with the mainline Zephyr source trees. I am developing some system-level components for Zephyr, so this is an important feature. (I could not determine which was the best area of the forum for this topic)

I began to follow the advice from this first topic:

I implemented the updates to the platformio.ini project file, as described in the above link. It seems like all frameworks are detected during the build, but I get errors related to search paths.

    warning: Ignoring missing SConscript '/[user-path]/.platformio/packages/framework-zephyr/scripts/platformio/platformio-build.py'
File "/[user-path]/.platformio/platforms/ststm32/builder/frameworks/zephyr.py", line 28, in <module>
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/nucleo_l010rb/src/main.o
src/main.c:1:10: fatal error: zephyr.h: No such file or directory

I’m using the VSCode IDE. It seems like there’s a header search path issue, although I’m not sure it’s with the IDE or the configuration. Looking for a solution. Thanks.

Seems like you haven’t copied PlatformIO’s custom build scripts in there? Those need to be acquired from the current version.

If you don’t have these files on your computer from a previous package of Zephyr’s, download 59aad95-framework-zephyr-2.20400.201110.tar.gz from Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog.

OK, the reason why it was missing the script dir is because I moved it instead of copying it from platformio to mainline zephyr (this was a mistake).

But the underlying problem here is that PlatformIO is still trying to build from the internal packages rather than the external packages. I need to build from the external packages that were re-specified in my platformio.ini file.

Since you’re specifying these 20 folders as them as platform_packages, they also need to be valid PlatformIO packages with a package.json inside them, describing the package and their version. I’m assuming since you’re linking to a cloned Zephyr repo that this file does not exist in any of the folders. Again you should use the previous PlatformIO package’s package.json as template for modification, e.g. for framework-zephyr

{
  "name": "framework-zephyr",
  "version": "2.20500.231210",
  "description": "Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures",
  "keywords": [
    "framework",
    "rtos",
    "hal"
  ],
  "homepage": "https://www.zephyrproject.org",
  "license": "Apache-2.0",
  "repository": {
    "type": "git",
    "url": "https://github.com/zephyrproject-rtos/zephyr"
  }
}

(changed the version to reflect Zephyr 2.5.0 and the current datecode).

All other framework-zephyr-* packages can be seen at the bintray as linked above.

I’m also not sure if the platformio/ prefix is needed for any of the pacakges – you can play with that.

You should see that it picks up your custom pacakge version when the build output where all used packages are listed reflects your changed versions.

Hm actually, maybe I should asking more goal-oriented questions. You’ve selected a Nucleo L010RB as your board. PlatformIO does not know this board so I’m assuming you’ve created the board’s JSON file yourself. However, neither is it listed in Zephyr’s latest documentation on supoprted boards.

grafik

In Zephyr’s codebase, I also don’t see L010 series boards being supported. zephyr/soc/arm/st_stm32/stm32l0 at main · zephyrproject-rtos/zephyr · GitHub

Have you written your port / extension for Zephyr already to explicitly support your board? I.e., you’ve tested this with your current Zephyr version standalone?

I had already copied the package.json files from the platformio distribution into the mainline distribution. Perhaps there is one missing; I will check again.

I added the nucleo-l010rb board and SoC into Zephyr myself. I have a project on Nucleo-l010rb that compiles and runs through normal Zephyr tools. The major reason I want to use the mainline zephyr source trees is because I am contributing board, SoCs, and other modules to the Zephyr project.

I want to have an IDE with Zephyr, so I am trying PlatformIO. The Zephyr-Eclipse plugin is OK but not great. I think PlatformIO on VSCode could be nicer.

Okay then I need you to specify how you saw that that is the case. What is the current output for the “Build” task?

in one of the recent release (not sure which one) of platformIO a new _pio folder is created inside framework-zephyr which maintains similar folder hierarchy what zephyr maintains for modules
image

i updated platfomIO and saw some anomaly in build behavior. So i deleted all the zephyr package uninstalled the ststm32 platform and reinstalled it which helped me removed the anomaly.

before:

after:

the Anomaly was core_cm4.h was not getting traced
" fatal error: core_cm4.h: No such file or directory"