I built a yocto distro (rocko) for my BBB using kernel linux-ti-staging-4.14 with a custom device tree. Since I need to port an old project from Debian to Yocto, I also needed to enable the UIO features in the kernel, which works fine too.
Now I need to also create an additonal device-tree-overlay for the UIO PRUSS. I use a dts file from here and extended the kernel recipe via bbappend:
inherit kernel-devicetree
FILESEXTRAPATHS_prepend := "${THISDIR}/files/dts:${THISDIR}/files/beaglebone:"
# Make custom kernel with PRU enabled
SRC_URI += "
file://bbb-pru-minimal.dts;subdir=git/arch/${ARCH}/boot/dts
file://AM335X-PRU-UIO-00A0-overlay.dts;subdir=git/arch/${ARCH}/boot/dts/overlays
file://0001-add-UIO-dtbo.patch
file://defconfig
"
KERNEL_DEVICETREE = "
AM335X-PRU-UIO-00A0.dtbo
bbb-pru-minimal.dtb
"
The above listed patch file contains:
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 7949c213a434..fe2513074893 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -610,6 +610,7 @@ dtb-$(CONFIG_SOC_TI81XX) +=
dm8168-evm.dtb
dra62x-j5eco-evm.dtb
dtb-$(CONFIG_SOC_AM33XX) +=
+ AM335X-PRU-UIO-00A0.dtbo
am335x-baltos-ir2110.dtb
am335x-baltos-ir3220.dtb
am335x-baltos-ir5221.dtb
However, the kernel build fails as it seems there is no rule for .dtbo targets:
| CC scripts/mod/empty.o
| CC scripts/mod/devicetable-offsets.s
| MKELF scripts/mod/elfconfig.h
| HOSTCC scripts/mod/modpost.o
| HOSTCC scripts/mod/sumversion.o
| CHK scripts/mod/devicetable-offsets.h
| HOSTCC scripts/mod/file2alias.o
| HOSTLD scripts/mod/modpost
| NOTE: make -j 24 HOSTCC=gcc -isystem[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/include -O2 -pipe -L[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -L[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-rpath-link,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -Wl,-rpath-link,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-rpath,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/usr/lib -Wl,-rpath,[TOPDIR]/build/tmp/work/beaglebone-poky-linux-gnueabi/linux-ti-staging/4.14.79+gitAUTOINC+3438de3474-c/recipe-sysroot-native/lib -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=[TOPDIR]/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 HOSTCPP=gcc -E AM335X-PRU-UIO-00A0.dtbo
| CHK scripts/mod/devicetable-offsets.h
| make[3]: *** No rule to make target 'arch/arm/boot/dts/AM335X-PRU-UIO-00A0.dtbo'. Stop.
| arch/arm/Makefile:345: recipe for target 'AM335X-PRU-UIO-00A0.dtbo' failed
| make[2]: *** [AM335X-PRU-UIO-00A0.dtbo] Error 2
| Makefile:146: recipe for target 'sub-make' failed
| make[1]: *** [sub-make] Error 2
| Makefile:24: recipe for target '__sub-make' failed
| make: *** [__sub-make] Error 2
| ERROR: oe_runmake failed
Please note, I replaced the absolute paths in the error message with [TOPDIR] due to privacy reasons.
Since I am fairly new to overlay creation I don’t really know what I am missing or how to fix it. Any hints?
Thank you in advance!
Update: Added patch file to description above.
2
Answers
Thanks to the hints from @BelHadjSalem I was able to manage the dtbo build. The class file devicetree.bbclass was introduced in Yocto with release "thud", therefore I updated my whole workspace to the latest Yocto release (dunfell). Afterwards I created a new recipe just to build my dtbo overlay:
The recipe is pretty simple and works in my project as required.
However, one important note: Inheriting the devicetree.bbclass in any kernel recipe or kernel bbappend file, will NOT work! Not sure what exactly happens, but the inheritance of devicetree.bbclass will invalidate the kernel recipe configuration and fail with
ERROR: Nothing PROVIDES 'virtual/kernel'
Here is what I found after analyzing Toradex’s git projects that can inspire you for a solution:
They have a custom class that handles their device tree files and device tree overlays, here.
The class inherits
devicetree
that is an official poky class here.The
devicetree
class tests if a device tree is an overlay or normal and then it compiles all of them.So, you can basically use
devicetree
class in a custom recipe to compile device tree overlays and deploy them manually into your rootfs.Toradex also has a simple recipe like that here. They have a git project that holds all of their device tree overlays.
That being said, I think Toradex doesn’t use the custom recipe, rather they use the custom
toradex-devicetree
class which inherits fromdevicetree
, compiles all device tree overlays from their device tree overlays git project and then deploy them all into the rootfs.In that custom class, they append to do_deploy of
devicetree
class to install the.dtbo
files and add them tooverlays.txt
file under the boot partition.So finally, you can create a
bbappend
file for you kernel recipe if you don’t have one, and try to follow these steps:devicetree
SRC_URI
via local files or URLDT_FILES_PATH
of thedevicetree
classdo_deploy
to add them to rootfs.Now, here is my advice to achieve this step by step:
devicetree
class with dts overlay example file