blob: dc49cbbff033f11b35e5b28882f1a3f2d463f668 [file] [log] [blame]
Brad Bishop286d45c2018-10-02 15:21:57 -04001SUMMARY = "Device Trees for BSPs"
2DESCRIPTION = "Device Tree generation and packaging for BSP Device Trees."
3SECTION = "bsp"
4
5LICENSE = "MIT & GPLv2"
6LIC_FILES_CHKSUM = " \
7 file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \
8 file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 \
9 "
10
11inherit deploy kernel-arch
12
13PROVIDES = "virtual/dtb"
14
15INHIBIT_DEFAULT_DEPS = "1"
16DEPENDS += "dtc-native"
17
18COMPATIBLE_MACHINE ?= "^$"
19
20PACKAGE_ARCH = "${MACHINE_ARCH}"
21
22FILES_${PN} = "/boot/devicetree/*.dtb /boot/devicetree/*.dtbo"
23
24S = "${WORKDIR}"
25B = "${WORKDIR}/build"
26
27SYSROOT_DIRS += "/boot/devicetree"
28
29# By default provide the current kernel arch's boot/dts and boot/dts/include.
30KERNEL_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.
35KERNEL_DTS_INCLUDE_append_zynqmp = " \
36 ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/xilinx \
37 "
38
39DTS_FILES_PATH ?= "${S}"
40DTS_INCLUDE ?= "${DTS_FILES_PATH} ${KERNEL_DTS_INCLUDE}"
41
42DT_PADDING_SIZE ?= "0x3000"
43DEVICETREE_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 "
47DEVICETREE_OFLAGS ?= "-@ -H epapr"
48DEVICETREE_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
53python () {
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
59do_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
73do_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
79do_deploy() {
80 for DTB_FILE in `ls *.dtb *.dtbo`; do
81 install -Dm 0644 ${B}/${DTB_FILE} ${DEPLOYDIR}/${DTB_FILE}
82 done
83}
84addtask deploy before do_build after do_install
85