I've got an answer for most of the question, although not as complete as I would like:
To build a .dts with .dtsi includes:
In you own layer, create a folder meta-mylayer/recipes-kernel/linux/files
In files copy the mycustom.dts and all the myinclude.dtsi.
Create the recipe meta-mylayer/recipes-kernel/linux/linux-yocto_%.bbappend
that will append to any linux-yocto kernel that you use with the following:
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:append = " \
file://mycustom.dts \
file://myinclude.dtsi \
"
do_configure:append(){
cp ${WORKDIR}/*.dt* ${S}/arch/arm/boot/dts
echo 'dtb-$(CONFIG_SOC_AM33XX) += mycustom.dtb' >> ${S}/arch/arm/boot/dts/Makefile
}
The recipe will patch the Makefile to include your mycustom.dtb. This is not as neat as creating a patch for it and it will append it twice if you run configure twice, but I don't think it will do any harm and it is clear what it is trying to do.
Now add your mycustom.dtb to the KERNEL_DEVICETREE variable in the conf/local.conf
file:
KERNEL_DEVICETREE:append = " mycustom.dtb"
I tried adding this to the bbappend or the image recipes but it did not work. Probably because the kernel does not check those recipes.
When you compile the image, it will now add mycustom.dtb
to the /boot
folder. If you want to check if you are in the right track, clean and configure the kernel with:
bitbake -c cleanall virtual/kernel
bitbake -c configure virtual/kernel
You should find the file tmp/work-shared/beaglebone-yocto/kernel-source/arch/arm/boot/dts/Makefile
has dtb-$(CONFIG_SOC_AM33XX) += mycustom.dtb
in the last line and the folder tmp/work-shared/beaglebone-yocto/kernel-source/arch/arm/boot/dts/
has mycustom.dts
and myincludes.dtsi
. When you compile the kernel
bitbake virtual/kernel
mycustom.dtb
exists in tmp/work/beaglebone_yocto-poky-linux-gnueabi/linux-yocto/5.15.54+gitAUTOINC+e4b95ec172_9aabbaa89f-r0/linux-beaglebone_yocto-standard-build/arch/arm/boot/dts/
your kernel version may be different.
When you boot your image, it should now show mycustom.dtb
in the /boot folder. To tell u-boot to use mycustom.dtb
, I wanted to change the file /boot/extlinux/extlinux.conf
. To do this, you can create a custom extlinux.conf
file with:
default Yocto
label Yocto
kernel /zImage
fdtdir /
DEVICETREE /mycustom.dtb
append root=/dev/mmcblk0p2 rootwait console=ttyS0,115200
and copy it to poky/meta-yocto-bsp/wic/myextlinux.conf
. Finally modify the file poky/meta-yocto-bsp/wic/beaglebone-yocto.wks
and in the bootloader last line, add --configfile myextlinux.conf
so it reads:
bootloader --append="console=ttyS0,115200" --configfile myextlinux.conf
Bitbake your image and it will now use you mycustom.dtb
by default.
I tried creating my own wks file so I could keep it in my layer, but I got an error that it couldn't find my kernel.
I also tried creating my own machine, but I got other errors.
I wish I didn't have to use /dev/mmcblk0p2
, but I don't know if I can or how to use PARTUUID. Using /dev/mmcblk0p2 may give issues if the image is flashed to EMMC.
That's the best answer I've got, at least for the moment.
mycustom.dtsi
intomycustom.dtb
... which builds correctly" -- That doesn't make sense or seem plausible. A .dtsi is merely an include file. The .dtb file is compiled from a .dts file. – Ale