summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel-devicetree.bbclass
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2017-09-21 10:58:33 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-25 14:14:17 +0100
commit64c4d72b3a64c938c36b373b2049b5d9f01e6749 (patch)
tree526efbd16f6de570adbb453cf8a8f2ba8fe3ef55 /meta/classes/kernel-devicetree.bbclass
parentd33fe7410dc2d3f9179c9cbc3f6874fa7dd7365e (diff)
downloadpoky-64c4d72b3a64c938c36b373b2049b5d9f01e6749.tar.gz
kernel-devicetree.bbclass: Add support to generate append to kernel
The are use cases where the Device Tree appended to the kernel is convinient, so we generate the bundle concatenating the kernel (and potentionally the initramfs) and the Device Tree binaries. To enable it, set KERNEL_DEVICETREE_BUNDLE variable to '1' (From OE-Core rev: f044567326988e84e5d72040e9387c3240836ddb) Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel-devicetree.bbclass')
-rw-r--r--meta/classes/kernel-devicetree.bbclass52
1 files changed, 51 insertions, 1 deletions
diff --git a/meta/classes/kernel-devicetree.bbclass b/meta/classes/kernel-devicetree.bbclass
index 72814ca224..6e08be4b70 100644
--- a/meta/classes/kernel-devicetree.bbclass
+++ b/meta/classes/kernel-devicetree.bbclass
@@ -1,6 +1,13 @@
1# Support for device tree generation 1# Support for device tree generation
2PACKAGES_append = " kernel-devicetree" 2PACKAGES_append = " \
3 kernel-devicetree \
4 ${@['kernel-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
5"
3FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo" 6FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
7FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin"
8
9# Generate kernel+devicetree bundle
10KERNEL_DEVICETREE_BUNDLE ?= "0"
4 11
5normalize_dtb () { 12normalize_dtb () {
6 DTB="$1" 13 DTB="$1"
@@ -20,6 +27,28 @@ get_real_dtb_path_in_kernel () {
20 echo "${DTB_PATH}" 27 echo "${DTB_PATH}"
21} 28}
22 29
30do_configure_append() {
31 if [ "${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
32 if echo ${KERNEL_IMAGETYPE_FOR_MAKE} | grep -q 'zImage'; then
33 case "${ARCH}" in
34 "arm")
35 config="${B}/.config"
36 if ! grep -q 'CONFIG_ARM_APPENDED_DTB=y' $config; then
37 bbwarn 'CONFIG_ARM_APPENDED_DTB is NOT enabled in the kernel. Enabling it to allow the kernel to boot with the Device Tree appended!'
38 sed -i "/CONFIG_ARM_APPENDED_DTB[ =]/d" $config
39 echo "CONFIG_ARM_APPENDED_DTB=y" >> $config
40 echo "# CONFIG_ARM_ATAG_DTB_COMPAT is not set" >> $config
41 fi
42 ;;
43 *)
44 bberror "KERNEL_DEVICETREE_BUNDLE is not supported for ${ARCH}. Currently it is only supported for 'ARM'."
45 esac
46 else
47 bberror 'The KERNEL_DEVICETREE_BUNDLE requires the KERNEL_IMAGETYPE to contain zImage.'
48 fi
49 fi
50}
51
23do_compile_append() { 52do_compile_append() {
24 for DTB in ${KERNEL_DEVICETREE}; do 53 for DTB in ${KERNEL_DEVICETREE}; do
25 DTB=`normalize_dtb "${DTB}"` 54 DTB=`normalize_dtb "${DTB}"`
@@ -38,6 +67,12 @@ do_install_append() {
38 symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME} 67 symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
39 DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` 68 DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
40 ln -sf ${DTB_BASE_NAME}.${DTB_EXT} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} 69 ln -sf ${DTB_BASE_NAME}.${DTB_EXT} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT}
70
71 if [ "$type" = "zImage" ] && [ "${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
72 cat ${D}/${KERNEL_IMAGEDEST}/$type \
73 ${D}/${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} \
74 > ${D}/${KERNEL_IMAGEDEST}/$type-${DTB_BASE_NAME}.${DTB_EXT}.bin
75 fi
41 done 76 done
42 done 77 done
43} 78}
@@ -57,6 +92,21 @@ do_deploy_append() {
57 install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} 92 install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}
58 ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.${DTB_EXT} 93 ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.${DTB_EXT}
59 ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_BASE_NAME}.${DTB_EXT} 94 ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_BASE_NAME}.${DTB_EXT}
95
96 if [ "$type" = "zImage" ] && [ "${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
97 cat ${DEPLOYDIR}/$type \
98 ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} \
99 > ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}.bin
100 ln -sf ${DTB_NAME}.${DTB_EXT}.bin ${DEPLOYDIR}/$type-${DTB_BASE_NAME}.${DTB_EXT}.bin
101
102 if [ -e "${KERNEL_OUTPUT_DIR}/${type}.initramfs" ]; then
103 cat ${KERNEL_OUTPUT_DIR}/${type}.initramfs \
104 ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} \
105 > ${DEPLOYDIR}/${type}-${INITRAMFS_BASE_NAME}-${DTB_BASE_NAME}.${DTB_EXT}.bin
106 ln -sf ${type}-${INITRAMFS_BASE_NAME}-${DTB_BASE_NAME}.${DTB_EXT}.bin \
107 ${DEPLOYDIR}/${type}-initramfs-${DTB_BASE_NAME}.${DTB_EXT}-${MACHINE}.bin
108 fi
109 fi
60 done 110 done
61 done 111 done
62} 112}