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` |
| 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | do_deploy_append() { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 44 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | pkg_postinst_kernel-devicetree () { |
| 57 | cd /${KERNEL_IMAGEDEST} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 58 | for DTB in ${KERNEL_DEVICETREE} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | do |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 60 | DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print $1}'` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 62 | update-alternatives --install /${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.dtb ${DTB_BASE_NAME}.dtb /boot/devicetree-${DTB_SYMLINK_NAME}.dtb ${KERNEL_PRIORITY} || true |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | done |
| 64 | } |
| 65 | |
| 66 | pkg_postrm_kernel-devicetree () { |
| 67 | cd /${KERNEL_IMAGEDEST} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 68 | for DTB in ${KERNEL_DEVICETREE} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | do |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 70 | DTB_BASE_NAME=`basename ${DTB} | awk -F "." '{print $1}'` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 71 | DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 72 | update-alternatives --remove ${DTB_BASE_NAME}.dtb /boot/devicetree-${DTB_SYMLINK_NAME}.dtb ${KERNEL_PRIORITY} || true |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | done |
| 74 | } |