0

I'm working with Yocto Kirkstone. My goal is to add a dts file to the raspberry pi linux kernel. I followed this answer and ended up with a new meta-layer and this directory tree:

meta-main-layer
meta-raspberrypi
meta-mydts/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-kernel
    └── linux
        ├── linux-raspberrypi
        │   └── raspberrypi4-64
        │       └── my.dts
        └── linux-raspberrypi_5.15.bbappend

and the linux-raspberrypi_5.15.bbappend:

SRC_URI += "file://mydts.dts;subdir=git/arch/arm/boot/dts/overlays"

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

PACKAGE_ARCH = "${MACHINE_ARCH}"
KERNEL_DEVICETREE += "mydst.dtb"

meta-main-layer is the layer with image definition, it does include the meta-mydts with

IMAGE_INSTALL:append += " mydts"

but for some reason yocto complains saying that there's no target mydts as below:

ERROR: Nothing RPROVIDES 'mydts' (but meta-main-layer/recipes-core/images/image-64.bb RDEPENDS on or otherwise requires it)
NOTE: Runtime target 'mydts' is unbuildable, removing...
Missing or unbuildable dependency chain was: ['mydts']

How can a meta-layer with linux kernel patches be turned into something that is buildable? What am I missing?

Antoni
  • 176
  • 10

2 Answers2

1

You should read Yocto documentation RPROVIDE.

Basically you want Bitbake to recognize your meta-layer. IMAGE_INSTALL:append is needed when you want to deploy a package in your final target. For example you have SRC_URI += "helloword.c" in my_helloword.bb then IMAGE_INSTALL:append = my_helloworld will add your binary helloword.o in final target.

Now you can understand trying to IMAGE_INSTALL:append a whole meta-layer is nonsense.

The proper way to make your meta-layer "discoverable" by bitbake is to go in your build directory, add in your conf/bblayers.conf file the path of your meta-layer in the variable BBLAYERS.

Also note that there is a syntax error in KERNEL_DEVICETREE += "mydst.dtb" It should be KERNEL_DEVICETREE += "mydts.dtb"

void_brain
  • 642
  • 2
  • 13
  • Does it mean that adding the path to the *meta-mydts* to *conf/bblayers.conf* is enough for raspberry pi kernel to notice the *meta-mydts/recipes-kernel/linux/linux-raspberrypi_5.15.bbappend* file and apply it? Thanks for pointing out the error! – Antoni Mar 10 '23 at 11:04
  • yes it is enough – void_brain Mar 10 '23 at 13:25
  • Do you know why could it be, that with my custom `mydts.dtbo` built added to the image, no other `*.dtbo` files are built? And I need these other `*.dtbo`'s as they are essential to the system. – Antoni Mar 14 '23 at 09:55
  • Okay, I tried many configurations and ended up adding `KERNEL_DEVICETREE:append = " mydts.dtbo" to `layer.conf` only. `+=` operator overwrites the original contents of the `KERNEL_DEVICETREE` variable as it uses weak value operator internally. That ment deleting all other `dtbo` files from the variable, breaking the image completely. – Antoni Mar 14 '23 at 13:15
1

I've figured out the problem and decided to post the steps here. This is based on @void_brain answer and @bvarner post. Below instructions are up to date with Yocto Kirkstone 4.01.

The *.dts file name has to include -overlay.dts suffix, every raspberry pi dt-overlay file has to follow that convention (step 2). Keep in mind, that the Device Tree Blob or *.dtbo file can not include this suffix anymore (step 3).

To add a custom *-overlay.dts file, follow below steps:

  1. First, get into the environment of the yocto project with source poky/oe-init-build-env to get access to the bitbake command. Later create a new layer for the *overlay-dts file:

    $ bitbake-layers create-layer meta-mydts
    
  2. Import the *-overlay.dts file to the freshly created meta-layer with recipetool command. It will create recipes-kernel/linux directories with a linux-raspberrypi_%.bbappend file. If your *-overlay.dts file is made for a specific machine, for example raspberrypi4-64, include it's name with the -wm parameter.

    recipetool appendsrcfile -wm raspberrypi4-64 . virtual/kernel path/to/mydts-overlay.dts 'arch/${ARCH}/boot/dts/overlays/mydts-overlay.dts'
    
  3. Add KERNEL_DEVICETREE:append = " overlays/mydts.dtbo" without the -overlay suffix to *.conf file, that can be meta-mydts/conf/layer.conf. This will tell Yocto to build your *-overlay.dts file into a *.dtbo and include it in the image.

  4. Include the path to meta-mydts layer in build/conf/bblayers.conf, to make the layer discoverable for Yocto.

That's about it. For automatic activation of the overlay look into the @bvarner post post.

Edit:

The overlay activation mechanism that worked the best for me is with the use of RPI_EXTRA_CONFIG variable. This variable should be put in the build/conf/local.conf, as below:

RPI_EXTRA_CONFIG:append = "\ndtoverlay=mydts\n"

The other location is layer.conf of the layer of your project that has a recipe for the image.

Antoni
  • 176
  • 10