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}"` |
| 36 | DTB_BASE_NAME=`basename ${DTB} .dtb` |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 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 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 43 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | do_deploy_append() { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 47 | for DTB in ${KERNEL_DEVICETREE}; do |
| 48 | DTB=`normalize_dtb "${DTB}"` |
| 49 | DTB_BASE_NAME=`basename ${DTB} .dtb` |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 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 |
| 58 | ln -sf ${DTB_NAME}.dtb ${DEPLOYDIR}/${DTB_SYMLINK_NAME}.dtb |
| 59 | done |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 60 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | pkg_postinst_kernel-devicetree () { |
| 64 | cd /${KERNEL_IMAGEDEST} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 65 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | done |
| 73 | } |
| 74 | |
| 75 | pkg_postrm_kernel-devicetree () { |
| 76 | cd /${KERNEL_IMAGEDEST} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 77 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | done |
| 85 | } |