no dt overlay example in meta-skeleton
Hi,
In the the meta-skeleton repo there is an example that shows how to build a standalone kernel module but no example of how to include or build an accompanying device tree overlay. Is there an existing "standard" way to achieve this? I am aware it can be done via the a .append on the linux kernel.
Many Thanks
Quoted 6 lines · On Thu, 2021-05-06 at 02:27 -0700, [email protected] wrote:
Hi,
In the the meta-skeleton repo there is an example that shows how to build a standalone kernel module but no example of how to include or build an accompanying device tree overlay. Is there an existing "standard" way to achieve this? I am aware it can be done via the a .append on the linux kernel.
I'm not aware of one but it would be something that could be nice to add if you do work it out and were willing!
Cheers,
Richard
Quoted 11 lines · Richard Purdie
Quoted 6 lines · On Thu, 2021-05-06 at 02:27 -0700, [email protected] wrote:
Hi,
In the the meta-skeleton repo there is an example that shows how to build a standalone kernel module but no example of how to include or build an accompanying device tree overlay. Is there an existing "standard" way to achieve this? I am aware it can be done via the a .append on the linux kernel.
I'm not aware of one but it would be something that could be nice to add if you do work it out and were willing!
I agree on this.
Probably just need DEPENDS = "dtc-native" and do proper dtc calls in do_compile.
I would expect this to be allarch too.
The tricky thing is that in order for dtbo to be usable, the original dtb should keep the references of Device Tree nodes (which it does not by default, or at least didn't, don't know for the more recent kernels).
See what I had to do for a project a while ago:
https://github.com/QSchulz/linux-at91/commit/c1ddbd31090bc8d82d5df38af2a12e8c053bb01f
I think we have support for DTC_FLAGS in Yocto now:
https://docs.yoctoproject.org/ref-manual/variables.html#term-KERNEL_DTC_FLAGS
so that could be a way to pass this flag without requiring users to patch the sources of their Linux kernel.
Thinking about it, maybe that is something that could be added to KERNEL_DTC_FLAGS if some other variable in set in, e.g. a machine configuration file. Let's say KERNEL_DTBO_SUPPORT = "1" would add "-@" to KERNEL_DTC_FLAGS.
Anyway, that's outside of the scope of the patch you could to send.
Just pointers :)
Looking forward to your patch,
Cheers,
Quentin
RFC - this seems to work for me.
File : dtbo-standalone.bbclass
Quoted 51 lines
Quoted 49 lines
# Inherit this class in a recipe to build an out of kernel tree Device tree overlay (.dtbo) file
DEPENDS = "dtc-native"
inherit deploy
do_compile(){cd ${S}
pwd
for dtbo in ${DT_OVERLAYS}; do
dtc -@ -Hepapr -I dts -o $dtbo.dtbo $dtbo.dts
done
}
do_deploy(){install -d ${DEPLOYDIR}
for i in ${S}/*.dtbo ; do
cp $i ${DEPLOYDIR}
done
}
Quoted 9 lines
Quoted 7 lines
addtask deploy before
do_buildafterdo_installdo_deploy[dirs] += "${DEPLOYDIR}"
PACKAGE_ARCH= "${MACHINE_ARCH}"
File : dtbo-standalone-image.bbclass
Quoted 26 lines
# Inherit this class in your image recipe to include Device tree overlay (.dtbo) files built outside of the kernel tree, e.g. by a my-dtbo.bb recipe
DTBO_STANDLONE?= ""def
make_standalone_dtbo_files_list(d):
# GenerateIMAGE_BOOT_FILESentries for device tree files listed in #DTBO_STANDLONE.
dtbs =d.getVar('DTBO_STANDLONE')def transform(dtb):
base =os.path.basename(dtb)
ifdtb.endswith('dtbo'):# overlay dtb: # eg: overlays/hifiberry-amp.dtbo has: # DEPLOYDIR file: hifiberry-amp.dtbo # destination: overlays/hifiberry-amp.dtbo return '{};{}'.format(base, dtb) elif dtb.endswith('dtb'): # eg: whatever/bcm2708-rpi-b.dtb has: # DEPLOYDIR file: bcm2708-rpi-b.dtb # destination: bcm2708-rpi-b.dtb return base
Quoted 4 lines
return ' '.join([transform(dtb) for dtb in
dtbs.split(' ')if dtb])
IMAGE_BOOT_FILES+= "${@make_standalone_dtbo_files_list(d)}"
File : my-dtbo.bb
Quoted 7 lines
inherit dtbo-standalone
LICENSE = "CLOSED" # For brevity only
SRC_URI+= "file://my-dt.dts;subdir=${PN}-${PV}"DT_OVERLAYS= "my-dt"
And then in the image where you want to install the DT file
Quoted 5 lines
DTBO_STANDLONE+= "my-dt.dtbo"inherit dtbo-standalone-image