diff options
author | Otavio Salvador <otavio@ossystems.com.br> | 2017-09-12 17:36:06 -0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-09-13 22:07:42 +0100 |
commit | 53067c4a97561747ea760d3b72cb3abc2b7409db (patch) | |
tree | 08159fb0738ca817b0e8297268ef9ebbfcfdc4ca | |
parent | 03aa1ef733032e1acae4d291580968301679117f (diff) | |
download | poky-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>
-rw-r--r-- | meta/classes/kernel-devicetree.bbclass | 62 | ||||
-rw-r--r-- | meta/classes/kernel.bbclass | 3 | ||||
-rw-r--r-- | meta/recipes-kernel/linux/linux-dtb.inc | 66 | ||||
-rw-r--r-- | meta/recipes-kernel/linux/linux-yocto.inc | 1 |
4 files changed, 67 insertions, 65 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 | } | ||
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index 02a5e961cb..0ad522d167 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass | |||
@@ -662,3 +662,6 @@ do_deploy[prefuncs] += "package_get_auto_pr" | |||
662 | addtask deploy after do_populate_sysroot do_packagedata | 662 | addtask deploy after do_populate_sysroot do_packagedata |
663 | 663 | ||
664 | EXPORT_FUNCTIONS do_deploy | 664 | EXPORT_FUNCTIONS do_deploy |
665 | |||
666 | # Add using Device Tree support | ||
667 | inherit kernel-devicetree | ||
diff --git a/meta/recipes-kernel/linux/linux-dtb.inc b/meta/recipes-kernel/linux/linux-dtb.inc index ca92822d25..f1912775ca 100644 --- a/meta/recipes-kernel/linux/linux-dtb.inc +++ b/meta/recipes-kernel/linux/linux-dtb.inc | |||
@@ -1,65 +1,3 @@ | |||
1 | # Support for device tree generation | 1 | python() { |
2 | FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb /${KERNEL_IMAGEDEST}/*.dtbo" | 2 | bb.warn("You are using the linux-dtb.inc which is deprecated. You can safely remove it as the Device Tree support is automatically enabled when KERNEL_DEVICETREE is set.") |
3 | |||
4 | python __anonymous () { | ||
5 | d.appendVar("PACKAGES", " kernel-devicetree") | ||
6 | } | ||
7 | |||
8 | normalize_dtb () { | ||
9 | DTB="$1" | ||
10 | if echo ${DTB} | grep -q '/dts/'; then | ||
11 | bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used." | ||
12 | DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'` | ||
13 | fi | ||
14 | echo "${DTB}" | ||
15 | } | ||
16 | |||
17 | get_real_dtb_path_in_kernel () { | ||
18 | DTB="$1" | ||
19 | DTB_PATH="${B}/arch/${ARCH}/boot/dts/${DTB}" | ||
20 | if [ ! -e "${DTB_PATH}" ]; then | ||
21 | DTB_PATH="${B}/arch/${ARCH}/boot/${DTB}" | ||
22 | fi | ||
23 | echo "${DTB_PATH}" | ||
24 | } | ||
25 | |||
26 | do_compile_append() { | ||
27 | for DTB in ${KERNEL_DEVICETREE}; do | ||
28 | DTB=`normalize_dtb "${DTB}"` | ||
29 | oe_runmake ${DTB} | ||
30 | done | ||
31 | } | ||
32 | |||
33 | do_install_append() { | ||
34 | for DTB in ${KERNEL_DEVICETREE}; do | ||
35 | DTB=`normalize_dtb "${DTB}"` | ||
36 | DTB_EXT=${DTB##*.} | ||
37 | DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"` | ||
38 | DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` | ||
39 | install -m 0644 ${DTB_PATH} ${D}/${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} | ||
40 | for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do | ||
41 | symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME} | ||
42 | DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` | ||
43 | ln -sf ${DTB_BASE_NAME}.${DTB_EXT} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} | ||
44 | done | ||
45 | done | ||
46 | } | ||
47 | |||
48 | do_deploy_append() { | ||
49 | for DTB in ${KERNEL_DEVICETREE}; do | ||
50 | DTB=`normalize_dtb "${DTB}"` | ||
51 | DTB_EXT=${DTB##*.} | ||
52 | DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` | ||
53 | for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do | ||
54 | base_name=${type}"-"${KERNEL_IMAGE_BASE_NAME} | ||
55 | symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME} | ||
56 | DTB_NAME=`echo ${base_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` | ||
57 | DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` | ||
58 | DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"` | ||
59 | install -d ${DEPLOYDIR} | ||
60 | install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} | ||
61 | ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.${DTB_EXT} | ||
62 | ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_BASE_NAME}.${DTB_EXT} | ||
63 | done | ||
64 | done | ||
65 | } | 3 | } |
diff --git a/meta/recipes-kernel/linux/linux-yocto.inc b/meta/recipes-kernel/linux/linux-yocto.inc index 1b8ffd0c17..9c1f61be75 100644 --- a/meta/recipes-kernel/linux/linux-yocto.inc +++ b/meta/recipes-kernel/linux/linux-yocto.inc | |||
@@ -54,7 +54,6 @@ LINUX_VERSION_EXTENSION ??= "-yocto-${LINUX_KERNEL_TYPE}" | |||
54 | # Pick up shared functions | 54 | # Pick up shared functions |
55 | inherit kernel | 55 | inherit kernel |
56 | inherit kernel-yocto | 56 | inherit kernel-yocto |
57 | require linux-dtb.inc | ||
58 | 57 | ||
59 | B = "${WORKDIR}/linux-${PACKAGE_ARCH}-${LINUX_KERNEL_TYPE}-build" | 58 | B = "${WORKDIR}/linux-${PACKAGE_ARCH}-${LINUX_KERNEL_TYPE}-build" |
60 | 59 | ||