blob: 651a19e4ae9df0635d6b7bf0626d5ce6d69045e9 [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`
37 DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
38 DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"`
39 install -m 0644 ${DTB_PATH} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.dtb
40 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041}
42
43do_deploy_append() {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044 for DTB in ${KERNEL_DEVICETREE}; do
45 DTB=`normalize_dtb "${DTB}"`
46 DTB_BASE_NAME=`basename ${DTB} .dtb`
47 DTB_NAME=`echo ${KERNEL_IMAGE_BASE_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
48 DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
49 DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"`
50 install -d ${DEPLOYDIR}
51 install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.dtb
52 ln -sf ${DTB_NAME}.dtb ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.dtb
53 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054}
55
56pkg_postinst_kernel-devicetree () {
57 cd /${KERNEL_IMAGEDEST}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050058 for DTB in ${KERNEL_DEVICETREE}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 do
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050060 DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print $1}'`
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050062 update-alternatives --install /${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.dtb ${DTB_BASE_NAME}.dtb /boot/devicetree-${DTB_SYMLINK_NAME}.dtb ${KERNEL_PRIORITY} || true
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 done
64}
65
66pkg_postrm_kernel-devicetree () {
67 cd /${KERNEL_IMAGEDEST}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050068 for DTB in ${KERNEL_DEVICETREE}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069 do
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050070 DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print $1}'`
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050072 update-alternatives --remove ${DTB_BASE_NAME}.dtb /boot/devicetree-${DTB_SYMLINK_NAME}.dtb ${KERNEL_PRIORITY} || true
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 done
74}