Kernel 4.4.6+ on RaspberryPi support .dtbo files for overlays, instead of .dtb.
Add support for both extensions for overlays (".dtb" and ".dtbo")

CAUTION: in IMAGE_CMD_rpi-sdimg, 'TMPDIR' is not set, causing 
'STAGING_KERNEL_BUILDDIR' to not be expanded, causing get_dts() to not being 
able to get the kernel version!
To avoid this problem, the kernel version is added in a new variable outside 
the scope of IMAGE_CMD_rpi-sdimg, and its value passed to get_dts() and 
split_overlays()!

Signed-off-by: Herve Jourdain <herve.jourd...@neuf.fr>
---
 classes/sdcard_image-rpi.bbclass | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/classes/sdcard_image-rpi.bbclass b/classes/sdcard_image-rpi.bbclass
index 57cefea..a04204a 100644
--- a/classes/sdcard_image-rpi.bbclass
+++ b/classes/sdcard_image-rpi.bbclass
@@ -75,6 +75,8 @@ IMAGEDATESTAMP = "${@time.strftime('%Y.%m.%d',time.gmtime())}"
 IMAGE_CMD_rpi-sdimg[vardepsexclude] += "IMAGEDATESTAMP"
 IMAGE_CMD_rpi-sdimg[vardepsexclude] += "DATETIME"
 
+RPI_KERNEL_VERSION := 
"${@get_kernelversion_file('${STAGING_KERNEL_BUILDDIR}')}"
+
 IMAGE_CMD_rpi-sdimg () {
 
        # Align partitions
@@ -85,7 +87,7 @@ IMAGE_CMD_rpi-sdimg () {
        echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB 
and RootFS $ROOTFS_SIZE KiB"
 
        # Check if we are building with device tree support
-       DTS="${@get_dts(d, None)}"
+       DTS="${@get_dts(d, '${RPI_KERNEL_VERSION}')}"
 
        # Initialize sdcard image file
        dd if=/dev/zero of=${SDIMG} bs=1024 count=0 seek=${SDIMG_SIZE}
@@ -105,9 +107,9 @@ IMAGE_CMD_rpi-sdimg () {
        mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img 
$BOOT_BLOCKS
        mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/* 
::/
        if test -n "${DTS}"; then
-               # Device Tree Overlays are assumed to be suffixed by 
'-overlay.dtb' string and will be put in a dedicated folder
-               DT_OVERLAYS="${@split_overlays(d, 0)}"
-               DT_ROOT="${@split_overlays(d, 1)}"
+               # Device Tree Overlays are assumed to be suffixed by 
'-overlay.dtb' (4.1.x) or by '.dtbo' (4.4.9+) string and will be put in a 
dedicated folder
+               DT_OVERLAYS="${@split_overlays(d, '${RPI_KERNEL_VERSION}', 0)}"
+               DT_ROOT="${@split_overlays(d, '${RPI_KERNEL_VERSION}', 1)}"
 
                # Copy board device trees to root folder
                for DTB in ${DT_ROOT}; do
@@ -119,9 +121,10 @@ IMAGE_CMD_rpi-sdimg () {
                # Copy device tree overlays to dedicated folder
                mmd -i ${WORKDIR}/boot.img overlays
                for DTB in ${DT_OVERLAYS}; do
-                       DTB_BASE_NAME=`basename ${DTB} .dtb`
+                               DTB_EXT=${DTB##*.}
+                               DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
 
-                       mcopy -i ${WORKDIR}/boot.img -s 
${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.dtb 
::overlays/${DTB_BASE_NAME}.dtb
+                       mcopy -i ${WORKDIR}/boot.img -s 
${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTB_BASE_NAME}.${DTB_EXT} 
::overlays/${DTB_BASE_NAME}.${DTB_EXT}
                done
        fi
        case "${KERNEL_IMAGETYPE}" in
-- 
2.7.4

-- 
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to