diff options
Diffstat (limited to 'meta/classes/kernel-devicetree.bbclass')
-rw-r--r-- | meta/classes/kernel-devicetree.bbclass | 52 |
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 |
2 | PACKAGES_append = " kernel-devicetree" | 2 | PACKAGES_append = " \ |
3 | kernel-devicetree \ | ||
4 | ${@['kernel-image-zimage-bundle', ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \ | ||
5 | " | ||
3 | FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo" | 6 | FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo" |
7 | FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-*.dtb.bin" | ||
8 | |||
9 | # Generate kernel+devicetree bundle | ||
10 | KERNEL_DEVICETREE_BUNDLE ?= "0" | ||
4 | 11 | ||
5 | normalize_dtb () { | 12 | normalize_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 | ||
30 | do_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 | |||
23 | do_compile_append() { | 52 | do_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 | } |