Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # Support for device tree generation |
| 2 | FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/devicetree*" |
| 3 | |
| 4 | python __anonymous () { |
| 5 | d.appendVar("PACKAGES", " kernel-devicetree") |
| 6 | } |
| 7 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 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'` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | fi |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 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 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | do_install_append() { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 34 | for DTB in ${KERNEL_DEVICETREE}; do |
| 35 | DTB=`normalize_dtb "${DTB}"` |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 36 | DTB_EXT=${DTB##*.} |
| 37 | DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 38 | 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 42 | install -m 0644 ${DTB_PATH} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 43 | done |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 44 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | do_deploy_append() { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 48 | for DTB in ${KERNEL_DEVICETREE}; do |
| 49 | DTB=`normalize_dtb "${DTB}"` |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 50 | DTB_EXT=${DTB##*.} |
| 51 | DTB_BASE_NAME=`basename ${DTB} ."${DTB_EXT}"` |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 52 | 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 59 | install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.${DTB_EXT} |
| 60 | ln -sf ${DTB_NAME}.${DTB_EXT} ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.${DTB_EXT} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 61 | done |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 62 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | pkg_postinst_kernel-devicetree () { |
| 66 | cd /${KERNEL_IMAGEDEST} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 67 | for DTB in ${KERNEL_DEVICETREE}; do |
| 68 | for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do |
| 69 | symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 70 | DTB_EXT=${DTB##*.} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 71 | DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print $1}'` |
| 72 | DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 73 | 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 Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 74 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | done |
| 76 | } |
| 77 | |
| 78 | pkg_postrm_kernel-devicetree () { |
| 79 | cd /${KERNEL_IMAGEDEST} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 80 | for DTB in ${KERNEL_DEVICETREE}; do |
| 81 | for type in ${KERNEL_IMAGETYPE_FOR_MAKE}; do |
| 82 | symlink_name=${type}"-"${KERNEL_IMAGE_SYMLINK_NAME} |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 83 | DTB_EXT=${DTB##*.} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 84 | DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print $1}'` |
| 85 | DTB_SYMLINK_NAME=`echo ${symlink_name} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 86 | update-alternatives --remove ${DTB_BASE_NAME}.${DTB_EXT} /boot/devicetree-${DTB_SYMLINK_NAME}.${DTB_EXT} ${KERNEL_PRIORITY} || true |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 87 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | done |
| 89 | } |