blob: 2f378a1db0fc732ef83da13190b96870be10a581 [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}"`
Patrick Williamsc0f7c042017-02-23 20:41:17 -060036 DTB_EXT=${DTB##*.}
37 DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
He Zhefe76b1e2016-05-25 04:47:16 -040038 for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do
39 symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
40 DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
41 DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"`
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042 install -m 0644 ${DTB_PATH} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT}
He Zhefe76b1e2016-05-25 04:47:16 -040043 done
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045}
46
47do_deploy_append() {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050048 for DTB in ${KERNEL_DEVICETREE}; do
49 DTB=`normalize_dtb "${DTB}"`
Patrick Williamsc0f7c042017-02-23 20:41:17 -060050 DTB_EXT=${DTB##*.}
51 DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
He Zhefe76b1e2016-05-25 04:47:16 -040052 for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do
53 base_name=${type}"-"${KERNEL_IMAGE_BASE_NAME}
54 symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
55 DTB_NAME=`echo ${base_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
56 DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
57 DTB_PATH=`get_real_dtb_path_in_kernel "${DTB}"`
58 install -d ${DEPLOYDIR}
Patrick Williamsc0f7c042017-02-23 20:41:17 -060059 install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT}
60 ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.${DTB_EXT}
He Zhefe76b1e2016-05-25 04:47:16 -040061 done
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050062 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063}
64
65pkg_postinst_kernel-devicetree () {
66 cd /${KERNEL_IMAGEDEST}
He Zhefe76b1e2016-05-25 04:47:16 -040067 for DTB in ${KERNEL_DEVICETREE}; do
68 for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do
69 symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
Patrick Williamsc0f7c042017-02-23 20:41:17 -060070 DTB_EXT=${DTB##*.}
Brad Bishop37a0e4d2017-12-04 01:01:44 -050071 DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
He Zhefe76b1e2016-05-25 04:47:16 -040072 DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
Patrick Williamsc0f7c042017-02-23 20:41:17 -060073 update-alternatives --install /${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.${DTB_EXT} ${DTB_BASE_NAME}.${DTB_EXT} /boot/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} ${KERNEL_PRIORITY} || true
He Zhefe76b1e2016-05-25 04:47:16 -040074 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075 done
76}
77
78pkg_postrm_kernel-devicetree () {
79 cd /${KERNEL_IMAGEDEST}
He Zhefe76b1e2016-05-25 04:47:16 -040080 for DTB in ${KERNEL_DEVICETREE}; do
81 for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do
82 symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME}
Patrick Williamsc0f7c042017-02-23 20:41:17 -060083 DTB_EXT=${DTB##*.}
Brad Bishop37a0e4d2017-12-04 01:01:44 -050084 DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"`
He Zhefe76b1e2016-05-25 04:47:16 -040085 DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"`
Patrick Williamsc0f7c042017-02-23 20:41:17 -060086 update-alternatives --remove ${DTB_BASE_NAME}.${DTB_EXT} /boot/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} ${KERNEL_PRIORITY} || true
He Zhefe76b1e2016-05-25 04:47:16 -040087 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 done
89}