The are use cases where the Device Tree appended to the kernel is
convinient, so we now allow the generation of this type of bundle.

To enable it, set KERNEL_DEVICETREE_BUNDLE variable to '1'

Signed-off-by: Otavio Salvador <[email protected]>
---

Changes in v4:
- new patch

Changes in v3: None
Changes in v2: None

 meta/classes/kernel-devicetree.bbclass | 40 +++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/meta/classes/kernel-devicetree.bbclass 
b/meta/classes/kernel-devicetree.bbclass
index 04e2f2695e..87243dde5d 100644
--- a/meta/classes/kernel-devicetree.bbclass
+++ b/meta/classes/kernel-devicetree.bbclass
@@ -1,6 +1,13 @@
 # Support for device tree generation
-PACKAGES_append = " kernel-devicetree"
+PACKAGES_append = " \
+    kernel-devicetree \
+    ${@['kernel-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') 
!= '1']} \
+"
 FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb 
/${KERNEL_IMAGEDEST}/*.dtbo"
+FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bundle"
+
+# Generate kernel+devicetree bundle
+KERNEL_DEVICETREE_BUNDLE ?= "0"
 
 normalize_dtb () {
        DTB="$1"
@@ -20,6 +27,24 @@ get_real_dtb_path_in_kernel () {
        echo "${DTB_PATH}"
 }
 
+
+do_configure_devicetree() {
+       if [ "${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
+               if echo ${KERNEL_IMAGETYPE_FOR_MAKE} | grep -q 'zImage'; then
+                       config="${B}/.config"
+                       if ! grep -q 'CONFIG_ARM_APPENDED_DTB=y' $config; then
+                               bbwarn 'CONFIG_ARM_APPENDED_DTB is NOT enabled 
in the kernel. Enabling it to allow the kernel to boot with the Device Tree 
appended!'
+                               sed -i "/CONFIG_ARM_APPENDED_DTB[ =]/d" $config
+                               echo "CONFIG_ARM_APPENDED_DTB=y" >> $config
+                               echo "# CONFIG_ARM_ATAG_DTB_COMPAT is not set" 
>> $config
+                       fi
+               else
+                       bberror 'The KERNEL_DEVICETREE_BUNDLE requires the 
KERNEL_IMAGETYPE to contain zImage.'
+               fi
+       fi
+}
+addtask configure_devicetree after do_configure before do_compile
+
 do_compile_devicetree() {
     DTBS=""
        for dtb in ${KERNEL_DEVICETREE}; do
@@ -43,6 +68,12 @@ fakeroot do_install_devicetree() {
                        symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
                        DTB_SYMLINK_NAME=`echo ${symlink_name} | sed 
"s/${MACHINE}/${DTB_BASE_NAME}/g"`
                        ln -sf ${DTB_BASE_NAME}.${DTB_EXT} 
${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT}
+
+                       if [ "$type" = "zImage" ] && [ 
"${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
+                               cat ${D}/${KERNEL_IMAGEDEST}/$type \
+                                       
${D}/${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} \
+                                       > 
${D}/${KERNEL_IMAGEDEST}/$type-${DTB_BASE_NAME}.${DTB_EXT}.bundle
+                       fi
                done
        done
 }
@@ -63,6 +94,13 @@ do_deploy_append() {
                        install -m 0644 ${DTB_PATH} 
${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}
                        ln -sf ${DTB_NAME}.${DTB_EXT} 
${DEPLOYDIR}/${DTB_SYMLINK_NAME}.${DTB_EXT}
                        ln -sf ${DTB_NAME}.${DTB_EXT} 
${DEPLOYDIR}/${DTB_BASE_NAME}.${DTB_EXT}
+
+                       if [ "$type" = "zImage" ] && [ 
"${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
+                               cat ${DEPLOYDIR}/$type \
+                                       ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} \
+                                       > 
${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}.bundle
+                               ln -sf ${DTB_NAME}.${DTB_EXT}.bundle 
${DEPLOYDIR}/$type-${DTB_BASE_NAME}.${DTB_EXT}.bundle
+                       fi
                done
        done
 }
-- 
2.14.1

-- 
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to