diff options
author | Ming Liu <ming.liu@toradex.com> | 2021-02-15 11:06:36 +0100 |
---|---|---|
committer | Ming Liu <ming.liu@toradex.com> | 2021-03-04 11:52:13 +0100 |
commit | 3f3703403ce8451c997faee1eb1f7665bff24437 (patch) | |
tree | a5b6e383ae53e80375c67e4e505831ef595f3e95 | |
parent | c8651feae915eeac23510565dde0f64557696de7 (diff) |
toradex-devicetree.bbclass: introduce bbclass file
The major reason for doing this is because we are currently deploying
all dtbo files to ${DEPLOY_DIR_IMAGE}/devicetree, but not machine
specific ones, and they will be unnecessarily bundled into fitimage
when kernel-fitimage.bbclass is being inherited.
To fix that, we introduce a extra task do_collect_overlays to collect
machine specific overlays to ${DT_FILES_PATH} before do_compile, where
dtb compilation is being compiled in. In this way, only machine
specific overlays would be compiled and deployed.
Now we can drop device-tree-overlay-filter recipe with this change.
Related-to: TOR-1700
Signed-off-by: Ming Liu <ming.liu@toradex.com>
-rw-r--r-- | classes/image_type_tezi.bbclass | 2 | ||||
-rw-r--r-- | classes/toradex-devicetree.bbclass | 88 | ||||
-rw-r--r-- | recipes-kernel/linux/device-tree-overlay-filter.bb | 63 | ||||
-rw-r--r-- | recipes-kernel/linux/device-tree-overlays-mainline_git.bb | 12 |
4 files changed, 90 insertions, 75 deletions
diff --git a/classes/image_type_tezi.bbclass b/classes/image_type_tezi.bbclass index fe52818..97328f1 100644 --- a/classes/image_type_tezi.bbclass +++ b/classes/image_type_tezi.bbclass @@ -5,7 +5,7 @@ # Since it also generates the image.json description file it is rather # interwind with the boot flow which is U-Boot target specific. -WKS_FILE_DEPENDS_append = " tezi-metadata device-tree-overlay-filter" +WKS_FILE_DEPENDS_append = " tezi-metadata virtual/dtb" DEPENDS += "${WKS_FILE_DEPENDS}" IMAGE_BOOT_FILES_append = " overlays.txt overlays/*;overlays/ " diff --git a/classes/toradex-devicetree.bbclass b/classes/toradex-devicetree.bbclass new file mode 100644 index 0000000..4deb850 --- /dev/null +++ b/classes/toradex-devicetree.bbclass @@ -0,0 +1,88 @@ +# Toradex devicetree.bbclass extension +# +# This bbclass extends OE's devicetree.bbclass by implementing devicetree +# overlays compilation for Toradex BSPs. +# +# A overlays.txt file is generated in ${DEPLOY_DIR_IMAGE}, with a uboot +# environment variable 'fdt_overlays' containing the devicetree overlays +# to be applied to the boot devicetree at runtime. +# +# The following options are supported: +# +# TEZI_EXTERNAL_KERNEL_DEVICETREE = "a-overlay.dtbo another_overlay.dtbo" +# +# The devicetree overlays to be deployed +# to ${DEPLOY_DIR_IMAGE}/overlays, if not +# set, all common and machine related +# overlays would be deployed. +# +# TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT = "a-overlay.dtbo" +# +# The devicetree overlays to be applied at +# runtime, will be written to: +# ${DEPLOY_DIR_IMAGE}/overlays.txt, if not +# set, no overlays would be applied. +# +# Copyright 2021 (C) Toradex AG + +TEZI_EXTERNAL_KERNEL_DEVICETREE ??= "" +TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT ??= "" + +SUMMARY = "Toradex BSP device tree overlays" + +SRC_URI = "git://git.toradex.com/device-tree-overlays.git;branch=${SRCBRANCH};protocol=https" + +PV = "${SRCBRANCH}+git${SRCPV}" + +inherit devicetree + +S = "${WORKDIR}/git/overlays" +DT_FILES_PATH = "${WORKDIR}/machine-overlays" + +# The machine specific recipes start with MACHINE_PREFIX}[_-] +MACHINE_PREFIX = "${MACHINE}" +MACHINE_PREFIX_colibri-imx7-emmc = "colibri-imx7" +MACHINE_PREFIX_apalis-imx8x-v11a = "apalis-imx8x" +MACHINE_PREFIX_colibri-imx8x-v10b = "colibri-imx8x" + +do_collect_overlays () { + if [ -z "${TEZI_EXTERNAL_KERNEL_DEVICETREE}" ] ; then + machine_dts=`cd ${S} && ls ${MACHINE_PREFIX}[_-]*.dts 2>/dev/null || true` + common_dts=`cd ${S} && ls *.dts 2>/dev/null | grep -v -e 'imx[6-8]' -e 'tk1' | xargs || true` + all_dts="$machine_dts $common_dts" + else + for dtbo in ${TEZI_EXTERNAL_KERNEL_DEVICETREE}; do + dtbo_ext=${dtbo##*.} + dts="`basename $dtbo .$dtbo_ext`.dts" + all_dts="$all_dts $dts" + done + fi + + for dts in $all_dts; do + cp ${S}/$dts ${DT_FILES_PATH} + done +} +do_collect_overlays[dirs] = "${DT_FILES_PATH}" +do_collect_overlays[cleandirs] = "${DT_FILES_PATH}" + +addtask collect_overlays after do_patch before do_configure + +do_deploy_append () { + install -d ${DEPLOYDIR}/overlays + if [ -d ${DEPLOYDIR}/devicetree ]; then + cp ${DEPLOYDIR}/devicetree/* ${DEPLOYDIR}/overlays + else + touch ${DEPLOYDIR}/overlays/none_deployed + fi + + # overlays that we want to be applied during boot time + overlays= + for dtbo in ${TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT}; do + if [ ! -e ${DEPLOYDIR}/overlays/$dtbo ]; then + bbfatal "$dtbo is not installed in your boot filesystem, please make sure it's in TEZI_EXTERNAL_KERNEL_DEVICETREE or being provided by virtual/dtb." + fi + overlays="$overlays $dtbo" + done + + echo "fdt_overlays=$(echo $overlays)" > ${DEPLOYDIR}/overlays.txt +} diff --git a/recipes-kernel/linux/device-tree-overlay-filter.bb b/recipes-kernel/linux/device-tree-overlay-filter.bb deleted file mode 100644 index b86f1cb..0000000 --- a/recipes-kernel/linux/device-tree-overlay-filter.bb +++ /dev/null @@ -1,63 +0,0 @@ -SUMMARY = "Filters device tree overlays based on machine into the deploy dir" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" - -# This recipe deploys from the available device tree overlays those which -# are applicable for the current machine. Additionally it creates the file -# overlays.txt containing a list of overlays which should be started by default. -# The files to deploy in the final image are: "overlays.txt overlays/*" - -do_deploy[depends] = "${@'virtual/dtb:do_deploy' if '${PREFERRED_PROVIDER_virtual/dtb}' else ''}" -PACKAGE_ARCH = "${MACHINE_ARCH}" - -inherit deploy nopackages - -do_configure[noexec] = "1" -do_compile[noexec] = "1" -do_install[noexec] = "1" - -# The machine specifc recipes start with MACHINE_PREFIX}[_-] -MACHINE_PREFIX = "${MACHINE}" -MACHINE_PREFIX_apalis-imx8x-v11a = "apalis-imx8x" -MACHINE_PREFIX_colibri-imx8x-v10b = "colibri-imx8x" -MACHINE_PREFIX_colibri-imx7-emmc = "colibri-imx7" - -TEZI_EXTERNAL_KERNEL_DEVICETREE ??= "" -TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT ??= "" - -do_deploy() { - deploy_dt_dir=${DEPLOY_DIR_IMAGE}/devicetree/ - dtbos= - if [ -z "${TEZI_EXTERNAL_KERNEL_DEVICETREE}" -a -d "$deploy_dt_dir" ] ; then - machine_dtbos=`cd $deploy_dt_dir && ls ${MACHINE_PREFIX}[_-]*.dtbo 2>/dev/null || true` - common_dtbos=`cd $deploy_dt_dir && ls *.dtbo 2>/dev/null | grep -v -e 'imx[6-8]' -e 'tk1' | xargs || true` - dtbos="$machine_dtbos $common_dtbos" - else - dtbos="${TEZI_EXTERNAL_KERNEL_DEVICETREE}" - fi - - mkdir -p ${DEPLOYDIR}/overlays/ - - # copy overlays to overlays/ or create an empty file for deployment - have_dtbos="n" - for dtbo in $dtbos; do - cp $deploy_dt_dir/$dtbo ${DEPLOYDIR}/overlays/ - have_dtbos="y" - done - if [ "$have_dtbos" = "n" ] ; then - touch ${DEPLOYDIR}/overlays/none_deployed - fi - - # overlays that we want to be applied during boot time - overlays= - for dtbo in ${TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT}; do - if [ ! -e ${DEPLOYDIR}/overlays/$dtbo ]; then - bbfatal "$dtbo is not installed in your boot filesystem, please make sure it's in TEZI_EXTERNAL_KERNEL_DEVICETREE or being provided by virtual/dtb. ${DEPLOYDIR}/overlays/" - fi - overlays="$overlays $dtbo" - done - - echo "fdt_overlays=$(echo $overlays)" > ${DEPLOYDIR}/overlays.txt -} - -addtask deploy after do_install before do_build diff --git a/recipes-kernel/linux/device-tree-overlays-mainline_git.bb b/recipes-kernel/linux/device-tree-overlays-mainline_git.bb index bf62db2..cc34553 100644 --- a/recipes-kernel/linux/device-tree-overlays-mainline_git.bb +++ b/recipes-kernel/linux/device-tree-overlays-mainline_git.bb @@ -1,17 +1,7 @@ -SUMMARY = "Toradex BSP device tree overlays" -DESCRIPTION = "Toradex BSP device tree overlays from within layer." - -SRC_URI = "git://git.toradex.com/device-tree-overlays.git;branch=${SRCBRANCH};protocol=https" +inherit toradex-devicetree SRCBRANCH = "toradex_5.4.y" - SRCREV = "b4bc095e8b8c2613c8c9a10c1895b544652f8cf4" SRCREV_use-head-next = "${AUTOREV}" -PV = "${SRCBRANCH}+git${SRCPV}" - -inherit devicetree - -S = "${WORKDIR}/git/overlays" - COMPATIBLE_MACHINE = ".*(mx[678]|tegra124).*" |