blob: 74f5ef8ca88cd14ffbd262ceb0dafd136f62336e [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Support for device tree generation
2FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/devicetree*"
3
4python __anonymous () {
5 d.appendVar("PACKAGES", " kernel-devicetree")
6}
7
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05008normalize_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'`
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050014 echo "${DTB}"
15}
16
17get_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
26do_compile_append() {
27 for DTB in ${KERNEL_DEVICETREE}; do
28 DTB=`normalize_dtb "${DTB}"`
29 oe_runmake ${DTB}
30 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031}
32
33do_install_append() {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050034 for DTB in ${KERNEL_DEVICETREE}; do
35 DTB=`normalize_dtb "${DTB}"`
36 DTB_BASE_NAME=`basename ${DTB} .dtb`
He Zhefe76b1e2016-05-25 04:47:16 -040037 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 DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"`
41 install -m 0644 ${DTB_PATH} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.dtb
42 done
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050043 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044}
45
46do_deploy_append() {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050047 for DTB in ${KERNEL_DEVICETREE}; do
48 DTB=`normalize_dtb "${DTB}"`
49 DTB_BASE_NAME=`basename ${DTB} .dtb`
He Zhefe76b1e2016-05-25 04:47:16 -040050 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
58 ln -sf ${DTB_NAME}.dtb ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.dtb
59 done
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050060 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061}
62
63pkg_postinst_kernel-devicetree () {
64 cd /${KERNEL_IMAGEDEST}
He Zhefe76b1e2016-05-25 04:47:16 -040065 for DTB in ${KERNEL_DEVICETREE}; do
66 for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do
67 symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
68 DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print $1}'`
69 DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
70 update-alternatives --install /${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.dtb ${DTB_BASE_NAME}.dtb /boot/devicetree-${DTB_SYMLINK_NAME}.dtb ${KERNEL_PRIORITY} || true
71 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072 done
73}
74
75pkg_postrm_kernel-devicetree () {
76 cd /${KERNEL_IMAGEDEST}
He Zhefe76b1e2016-05-25 04:47:16 -040077 for DTB in ${KERNEL_DEVICETREE}; do
78 for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do
79 symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
80 DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print $1}'`
81 DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
82 update-alternatives --remove ${DTB_BASE_NAME}.dtb /boot/devicetree-${DTB_SYMLINK_NAME}.dtb ${KERNEL_PRIORITY} || true
83 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 done
85}