Skip to contentSkip to conversation

How to use devicetree.bbclass?

DISCUSSION [email protected] 1 participant 2 messages Jun 8, 2022 2 messages not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

We're using honister. We have a recipe that generates a device tree using devicetree.bbclass. It doesn't do anything special:

SRC_URI = file://system-top.dts
DT_INCLUDE:append = " ${THISDIR}/files"
COMPATIBLE_MACHINE:zynq = "zynq"
inherit devicetree

It's unclear to me how this is actually supposed to work, however. There are no examples of using the class in poky or meta-openembedded that I can find.

What I'm leaning towards now is creating a bbappend for the kernel recipe that just installs the generated device tree into arch/arm/boot/dts. But if anyone has a better way I'd be glad to hear it.

Thanks,
Chris

#3 lore raw
In reply to a message not in the archive

We're using honister. We have a recipe that generates a device tree using devicetree.bbclass. It doesn't do anything special:

SRC_URI = file://system-top.dts
DT_INCLUDE:append = " ${THISDIR}/files"
COMPATIBLE_MACHINE:zynq = "zynq"
inherit devicetree

It's unclear to me how this is actually supposed to work, however. There are no examples of using the class in poky or meta-openembedded that I can find.

What I'm leaning towards now is creating a bbappend for the kernel recipe that just installs the generated device tree into arch/arm/boot/dts. But if anyone has a better way I'd be glad to hear it.

I've done a little more experimenting and I think I understand now. Please someone correct me if I'm wrong.

If you want an in-tree (kernel source tree, that is) device tree, you set KERNEL_DEVICETREE. AFAICT the device tree doesn't actually get baked into the kernel. Rather, it is exported alongside the kernel to be picked up by a fitImage, for example.

If you want an out-of-tree device tree, you can write a recipe that inherits devicetree.bbclass (if you want to use the device tree compiler), or I suppose you could write a recipe that just deploys a pre-built .dtb in a similar way to how devicetree.bbclass does. Either way, you *don't* set KERNEL_DEVICETREE. Then the fitimage process will pick up the .dtb.

In my case, I'm creating a fitimage without an initramfs. It's just the kernel and dtb. This is done by adding this to my MACHINE conf:

KERNEL_CLASSES += "kernel-fitimage"
KERNEL_IMAGETYPES += "fitImage"

You also need to tell the kernel-fitimage.bbclass where to get the dtb from, which is done somewhat indirectly by setting a preferred provider:

PREFERRED_PROVIDER_virtual/dtb = "my-device-tree"

Thanks,
Chris