Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 1 | SUMMARY = "Device Trees for BSPs" |
| 2 | DESCRIPTION = "Device Tree generation and packaging for BSP Device Trees." |
| 3 | SECTION = "bsp" |
| 4 | |
| 5 | LICENSE = "MIT & GPLv2" |
| 6 | LIC_FILES_CHKSUM = " \ |
| 7 | file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \ |
| 8 | file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 \ |
| 9 | " |
| 10 | |
| 11 | inherit deploy kernel-arch |
| 12 | |
| 13 | PROVIDES = "virtual/dtb" |
| 14 | |
| 15 | INHIBIT_DEFAULT_DEPS = "1" |
| 16 | DEPENDS += "dtc-native" |
| 17 | |
| 18 | COMPATIBLE_MACHINE ?= "^$" |
| 19 | |
| 20 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 21 | |
| 22 | FILES_${PN} = "/boot/devicetree/*.dtb /boot/devicetree/*.dtbo" |
| 23 | |
| 24 | S = "${WORKDIR}" |
| 25 | B = "${WORKDIR}/build" |
| 26 | |
| 27 | SYSROOT_DIRS += "/boot/devicetree" |
| 28 | |
| 29 | # By default provide the current kernel arch's boot/dts and boot/dts/include. |
| 30 | KERNEL_DTS_INCLUDE ??= " \ |
| 31 | ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts \ |
| 32 | ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/include \ |
| 33 | " |
| 34 | # For arm64/zynqmp the xilinx specific includes are subdired under a vendor directory. |
| 35 | KERNEL_DTS_INCLUDE_append_zynqmp = " \ |
| 36 | ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/xilinx \ |
| 37 | " |
| 38 | |
| 39 | DTS_FILES_PATH ?= "${S}" |
| 40 | DTS_INCLUDE ?= "${DTS_FILES_PATH} ${KERNEL_DTS_INCLUDE}" |
| 41 | |
| 42 | DT_PADDING_SIZE ?= "0x3000" |
| 43 | DEVICETREE_FLAGS ?= " \ |
| 44 | -R 8 -p ${DT_PADDING_SIZE} -b 0 \ |
| 45 | ${@' '.join(['-i %s' % i for i in d.getVar('DTS_INCLUDE', True).split()])} \ |
| 46 | " |
| 47 | DEVICETREE_OFLAGS ?= "-@ -H epapr" |
| 48 | DEVICETREE_PP_FLAGS ?= " \ |
| 49 | -nostdinc -Ulinux -x assembler-with-cpp \ |
| 50 | ${@' '.join(['-I%s' % i for i in d.getVar('DTS_INCLUDE', True).split()])} \ |
| 51 | " |
| 52 | |
| 53 | python () { |
| 54 | # auto add dependency on kernel tree |
| 55 | if d.getVar("KERNEL_DTS_INCLUDE") != "": |
| 56 | d.appendVarFlag("do_compile", "depends", " virtual/kernel:do_configure") |
| 57 | } |
| 58 | |
| 59 | do_compile() { |
| 60 | for DTS_FILE in ${DTS_FILES_PATH}/*.dts; do |
| 61 | DTS_NAME=`basename -s .dts ${DTS_FILE}` |
| 62 | ${BUILD_CPP} ${DEVICETREE_PP_FLAGS} -o `basename ${DTS_FILE}`.pp ${DTS_FILE} |
| 63 | |
| 64 | # for now use the existance of the '/plugin/' tag to detect overlays |
| 65 | if grep -qse "/plugin/;" `basename ${DTS_FILE}`.pp; then |
| 66 | dtc ${DEVICETREE_OFLAGS} -I dts -O dtb ${DEVICETREE_FLAGS} -o ${DTS_NAME}.dtbo `basename ${DTS_FILE}`.pp |
| 67 | else |
| 68 | dtc -I dts -O dtb ${DEVICETREE_FLAGS} -o ${DTS_NAME}.dtb `basename ${DTS_FILE}`.pp |
| 69 | fi |
| 70 | done |
| 71 | } |
| 72 | |
| 73 | do_install() { |
| 74 | for DTB_FILE in `ls *.dtb *.dtbo`; do |
| 75 | install -Dm 0644 ${B}/${DTB_FILE} ${D}/boot/devicetree/${DTB_FILE} |
| 76 | done |
| 77 | } |
| 78 | |
| 79 | do_deploy() { |
| 80 | for DTB_FILE in `ls *.dtb *.dtbo`; do |
| 81 | install -Dm 0644 ${B}/${DTB_FILE} ${DEPLOYDIR}/${DTB_FILE} |
| 82 | done |
| 83 | } |
| 84 | addtask deploy before do_build after do_install |
| 85 | |