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 | |
| 8 | do_compile_append() { |
| 9 | if test -n "${KERNEL_DEVICETREE}"; then |
| 10 | for DTB in ${KERNEL_DEVICETREE}; do |
| 11 | if echo ${DTB} | grep -q '/dts/'; then |
| 12 | bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used." |
| 13 | DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'` |
| 14 | fi |
| 15 | oe_runmake ${DTB} |
| 16 | done |
| 17 | fi |
| 18 | } |
| 19 | |
| 20 | do_install_append() { |
| 21 | if test -n "${KERNEL_DEVICETREE}"; then |
| 22 | for DTB in ${KERNEL_DEVICETREE}; do |
| 23 | if echo ${DTB} | grep -q '/dts/'; then |
| 24 | bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used." |
| 25 | DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'` |
| 26 | fi |
| 27 | DTB_BASE_NAME=`basename ${DTB} .dtb` |
| 28 | DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
| 29 | DTB_PATH="${B}/arch/${ARCH}/boot/dts/${DTB}" |
| 30 | if [ ! -e "${DTB_PATH}" ]; then |
| 31 | DTB_PATH="${B}/arch/${ARCH}/boot/${DTB}" |
| 32 | fi |
| 33 | install -m 0644 ${DTB_PATH} ${D}/${KERNEL_IMAGEDEST}/devicetree-${DTB_SYMLINK_NAME}.dtb |
| 34 | done |
| 35 | fi |
| 36 | } |
| 37 | |
| 38 | do_deploy_append() { |
| 39 | if test -n "${KERNEL_DEVICETREE}"; then |
| 40 | for DTB in ${KERNEL_DEVICETREE}; do |
| 41 | if echo ${DTB} | grep -q '/dts/'; then |
| 42 | bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used." |
| 43 | DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'` |
| 44 | fi |
| 45 | DTB_BASE_NAME=`basename ${DTB} .dtb` |
| 46 | DTB_NAME=`echo ${KERNEL_IMAGE_BASE_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
| 47 | DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
| 48 | DTB_PATH="${B}/arch/${ARCH}/boot/dts/${DTB}" |
| 49 | if [ ! -e "${DTB_PATH}" ]; then |
| 50 | DTB_PATH="${B}/arch/${ARCH}/boot/${DTB}" |
| 51 | fi |
| 52 | install -d ${DEPLOYDIR} |
| 53 | install -m 0644 ${DTB_PATH} ${DEPLOYDIR}/${DTB_NAME}.dtb |
| 54 | cd ${DEPLOYDIR} |
| 55 | ln -sf ${DTB_NAME}.dtb ${DTB_SYMLINK_NAME}.dtb |
| 56 | cd - |
| 57 | done |
| 58 | fi |
| 59 | } |
| 60 | |
| 61 | pkg_postinst_kernel-devicetree () { |
| 62 | cd /${KERNEL_IMAGEDEST} |
| 63 | for DTB_FILE in ${KERNEL_DEVICETREE} |
| 64 | do |
| 65 | DTB_BASE_NAME=`basename ${DTB_FILE} | awk -F "." '{print $1}'` |
| 66 | DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
| 67 | update-alternatives --install /${KERNEL_IMAGEDEST}/${DTB_BASE_NAME}.dtb ${DTB_BASE_NAME}.dtb devicetree-${DTB_SYMLINK_NAME}.dtb ${KERNEL_PRIORITY} || true |
| 68 | done |
| 69 | } |
| 70 | |
| 71 | pkg_postrm_kernel-devicetree () { |
| 72 | cd /${KERNEL_IMAGEDEST} |
| 73 | for DTB_FILE in ${KERNEL_DEVICETREE} |
| 74 | do |
| 75 | DTB_BASE_NAME=`basename ${DTB_FILE} | awk -F "." '{print $1}'` |
| 76 | DTB_SYMLINK_NAME=`echo ${KERNEL_IMAGE_SYMLINK_NAME} | sed "s/${MACHINE}/${DTB_BASE_NAME}/g"` |
| 77 | update-alternatives --remove ${DTB_BASE_NAME}.dtb devicetree-${DTB_SYMLINK_NAME}.dtb ${KERNEL_PRIORITY} || true |
| 78 | done |
| 79 | } |