diff options
Diffstat (limited to 'meta/classes/kernel-devicetree.bbclass')
-rw-r--r-- | meta/classes/kernel-devicetree.bbclass | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/meta/classes/kernel-devicetree.bbclass b/meta/classes/kernel-devicetree.bbclass new file mode 100644 index 0000000000..72814ca224 --- /dev/null +++ b/meta/classes/kernel-devicetree.bbclass | |||
@@ -0,0 +1,62 @@ | |||
1 | # Support for device tree generation | ||
2 | PACKAGES_append = " kernel-devicetree" | ||
3 | FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo" | ||
4 | |||
5 | normalize_dtb () { | ||
6 | DTB="$1" | ||
7 | if echo ${DTB} | grep -q '/dts/'; then | ||
8 | bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used." | ||
9 | DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'` | ||
10 | fi | ||
11 | echo "${DTB}" | ||
12 | } | ||
13 | |||
14 | get_real_dtb_path_in_kernel () { | ||
15 | DTB="$1" | ||
16 | DTB_PATH="${B}/arch/${ARCH}/boot/dts/${DTB}" | ||
17 | if [ ! -e "${DTB_PATH}" ]; then | ||
18 | DTB_PATH="${B}/arch/${ARCH}/boot/${DTB}" | ||
19 | fi | ||
20 | echo "${DTB_PATH}" | ||
21 | } | ||
22 | |||
23 | do_compile_append() { | ||
24 | for DTB in ${KERNEL_DEVICETREE}; do | ||
25 | DTB=`normalize_dtb "${DTB}"` | ||
26 | oe_runmake ${DTB} | ||
27 | done | ||
28 | } | ||
29 | |||
30 | do_install_append() { | ||
31 | for DTB in ${KERNEL_DEVICETREE}; do | ||
32 | DTB=`normalize_dtb "${DTB}"` | ||
33 | DTB_EXT=${DTB##*.} | ||
34 | DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"` | ||
35 | DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` | ||
36 | install -m 0644 ${DTB_PATH} ${D}/${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} | ||
37 | for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do | ||
38 | symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME} | ||
39 | 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} | ||
41 | done | ||
42 | done | ||
43 | } | ||
44 | |||
45 | do_deploy_append() { | ||
46 | for DTB in ${KERNEL_DEVICETREE}; do | ||
47 | DTB=`normalize_dtb "${DTB}"` | ||
48 | DTB_EXT=${DTB##*.} | ||
49 | DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` | ||
50 | for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do | ||
51 | base_name=${type}"-"${KERNEL_IMAGE_BASE_NAME} | ||
52 | symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME} | ||
53 | DTB_NAME=`echo ${base_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` | ||
54 | DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` | ||
55 | DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"` | ||
56 | install -d ${DEPLOYDIR} | ||
57 | install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} | ||
58 | 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} | ||
60 | done | ||
61 | done | ||
62 | } | ||