summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel-devicetree.bbclass
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2017-09-12 17:36:06 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-13 22:07:42 +0100
commit53067c4a97561747ea760d3b72cb3abc2b7409db (patch)
tree08159fb0738ca817b0e8297268ef9ebbfcfdc4ca /meta/classes/kernel-devicetree.bbclass
parent03aa1ef733032e1acae4d291580968301679117f (diff)
downloadpoky-53067c4a97561747ea760d3b72cb3abc2b7409db.tar.gz
kernel: Move Device Tree support to kernel.bbclass
The Device Tree is commonly used but it is still kept as a .inc file instead of a proper class. Instead now we move the Device Tree code to a kernel-devicetree class and automatically enable it when the KERNEL_DEVICETREE variable is set. To avoid breakage in existing layers, we kept a linux-dtb.inc file which raises a warning telling the user about the change so in next release this can be removed. (From OE-Core rev: 03a00be7f2062aefef0e51ef20a4c9737f6685e7) Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel-devicetree.bbclass')
-rw-r--r--meta/classes/kernel-devicetree.bbclass62
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
2PACKAGES_append = " kernel-devicetree"
3FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo"
4
5normalize_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
14get_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
23do_compile_append() {
24 for DTB in ${KERNEL_DEVICETREE}; do
25 DTB=`normalize_dtb "${DTB}"`
26 oe_runmake ${DTB}
27 done
28}
29
30do_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
45do_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}