This change improves and does a number of clean up to the device-tree
recipe. This includes adding support for building overlays, default
inclusion of kernel device tree sources, updated license value and
general clean ups to the logic.

This change also removes the support for MACHINE_DEVICETREE, and
additionally the now unused xilinx-utils.bbclass.

Note: In order to support overlays dtc version 1.4.3 or newer is needed,
currently in oe-core only 1.4.2 is available.

Signed-off-by: Nathan Rossi <nat...@nathanrossi.com>
---
 classes/xilinx-utils.bbclass           |  58 ------------------
 recipes-bsp/device-tree/device-tree.bb | 107 +++++++++++++--------------------
 2 files changed, 41 insertions(+), 124 deletions(-)
 delete mode 100644 classes/xilinx-utils.bbclass

diff --git a/classes/xilinx-utils.bbclass b/classes/xilinx-utils.bbclass
deleted file mode 100644
index 0d007b9465..0000000000
--- a/classes/xilinx-utils.bbclass
+++ /dev/null
@@ -1,58 +0,0 @@
-# Utility functions for various Xilinx specific recipes
-
-# Returns a ':' seperated list of expanded '${BBPATH}/$path'
-def get_additional_bbpath_filespath(path, d):
-    board_extrapaths = []
-    bbpath = d.getVar("BBPATH", True) or ""
-    for i in bbpath.split(":"):
-        board_extrapaths.append(os.path.join(i, path))
-    if len(board_extrapaths):
-        return ":".join(board_extrapaths) + ":"
-    return ""
-
-# Add a prefix or suffix to all paths in the list of paths
-#   e.g. add 'file://' to all paths
-def paths_affix(paths, suffix = "", prefix = ""):
-    if paths:
-        files=set()
-        for path in paths.split():
-            newpath = path
-            if suffix and len(suffix) != 0:
-                newpath = newpath + suffix
-            if prefix and len(prefix) != 0:
-                newpath = prefix + newpath
-            files.add(newpath)
-        if len(files) != 0:
-            return ' '.join(files)
-    return ''
-
-# Expand all relative paths to absolute based on the WORKDIR location
-def expand_workdir_paths(variable, d):
-    workdir = d.getVar("WORKDIR", True)
-    variable_value = d.getVar(variable, True) or ''
-    if variable_value:
-        files=set()
-        for path in variable_value.split():
-            if workdir:
-                files.add(os.path.join(workdir, path))
-            else:
-                files.add(path)
-        if len(files) != 0:
-            return ' '.join(files)
-    return ''
-
-# Returns a space seperated list of all files which match the extension, joined
-# with the dir path.
-def expand_dir_basepaths_by_extension(variable, dir, extension, d):
-    variable_value = d.getVar(variable, True) or ''
-    if variable_value:
-        files=set()
-        for path in variable_value.split():
-            if os.path.splitext(path)[1] == extension or extension == None:
-                if dir:
-                    files.add(os.path.join(dir, os.path.basename(path)))
-                else:
-                    files.add(os.path.basename(path))
-        if len(files) != 0:
-            return ' '.join(files)
-    return ''
diff --git a/recipes-bsp/device-tree/device-tree.bb 
b/recipes-bsp/device-tree/device-tree.bb
index 2846ca9900..c71f7ddb79 100644
--- a/recipes-bsp/device-tree/device-tree.bb
+++ b/recipes-bsp/device-tree/device-tree.bb
@@ -2,100 +2,75 @@ SUMMARY = "Device Trees for BSPs"
 DESCRIPTION = "Device Tree generation and packaging for BSP Device Trees."
 SECTION = "bsp"
 
-LICENSE = "MIT"
-LIC_FILES_CHKSUM = 
"file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+LICENSE = "MIT & GPLv2"
+LIC_FILES_CHKSUM = " \
+               
file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \
+               
file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 \
+               "
 
 inherit deploy
+inherit kernel-arch
 
 INHIBIT_DEFAULT_DEPS = "1"
-PACKAGE_ARCH = "${MACHINE_ARCH}"
-
 DEPENDS += "dtc-native"
 
-FILES_${PN} = "/boot/devicetree*"
-DEVICETREE_FLAGS ?= "-R 8 -p 0x3000 \
-               -i ${WORKDIR}/devicetree \
-               ${@' '.join(['-i %s' % i for i in 
d.getVar('KERNEL_DTS_INCLUDE', True).split()])} \
-               "
-DEVICETREE_PP_FLAGS ?= "-nostdinc -Ulinux \
-               -I${WORKDIR}/devicetree \
-               ${@' '.join(['-I%s' % i for i in d.getVar('KERNEL_DTS_INCLUDE', 
True).split()])} \
-               -x assembler-with-cpp \
-               "
+PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
-MACHINE_DEVICETREE_prepend_zynq = " \
-               common/zynq-7000-qspi-dummy.dtsi \
-               "
+FILES_${PN} = "/boot/devicetree/*.dtb /boot/devicetree/*.dtbo"
 
 S = "${WORKDIR}"
+B = "${WORKDIR}/build"
 
-KERNEL_DTS_INCLUDE ??= ""
-KERNEL_DTS_INCLUDE_zynq = " \
-               ${STAGING_KERNEL_DIR}/arch/arm/boot/dts \
-               ${STAGING_KERNEL_DIR}/arch/arm/boot/dts/include \
+# By default provide the current kernel arch's boot/dts and boot/dts/include.
+KERNEL_DTS_INCLUDE ??= " \
+               ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts \
+               ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/include \
                "
-KERNEL_DTS_INCLUDE_zynqmp = " \
-               ${STAGING_KERNEL_DIR}/arch/arm64/boot/dts \
-               ${STAGING_KERNEL_DIR}/arch/arm64/boot/dts/include \
-               ${STAGING_KERNEL_DIR}/arch/arm64/boot/dts/xilinx \
+# For arm64/zynqmp the xilinx specific includes are subdired under a vendor 
directory.
+KERNEL_DTS_INCLUDE_append_zynqmp = " \
+               ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/xilinx \
+               "
+
+DEVICETREE_FLAGS ?= " \
+               -R 8 -p 0x3000 -b 0 -i ${S} \
+               ${@' '.join(['-i %s' % i for i in 
d.getVar('KERNEL_DTS_INCLUDE', True).split()])} \
+               "
+DEVICETREE_OFLAGS ?= "-@ -H epapr"
+DEVICETREE_PP_FLAGS ?= " \
+               -nostdinc -Ulinux -x assembler-with-cpp -I${S} \
+               ${@' '.join(['-I%s' % i for i in d.getVar('KERNEL_DTS_INCLUDE', 
True).split()])} \
                "
 
 python () {
     # auto add dependency on kernel tree
-    if d.getVar("KERNEL_DTS_INCLUDE", True) != "":
-        d.setVarFlag("do_compile", "depends",
-            " ".join([d.getVarFlag("do_compile", "depends", True) or "", 
"virtual/kernel:do_shared_workdir"]))
+    if d.getVar("KERNEL_DTS_INCLUDE") != "":
+        d.appendVarFlag("do_compile", "depends", " 
virtual/kernel:do_shared_workdir")
 }
 
 do_compile() {
-       if test -n "${MACHINE_DEVICETREE}"; then
-               mkdir -p ${WORKDIR}/devicetree
-               for i in ${MACHINE_DEVICETREE}; do
-                       if test -e ${WORKDIR}/$i; then
-                               cp ${WORKDIR}/$i ${WORKDIR}/devicetree
-                       fi
-               done
-       fi
-
-       for DTS_FILE in ${DEVICETREE}; do
+       for DTS_FILE in ${S}/*.dts; do
                DTS_NAME=`basename -s .dts ${DTS_FILE}`
-               ${BUILD_CPP} ${DEVICETREE_PP_FLAGS} -o ${DTS_FILE}.pp 
${DTS_FILE}
-               dtc -I dts -O dtb ${DEVICETREE_FLAGS} -o ${DTS_NAME}.dtb 
${DTS_FILE}.pp
+               ${BUILD_CPP} ${DEVICETREE_PP_FLAGS} -o `basename 
${DTS_FILE}`.pp ${DTS_FILE}
+
+               # for now use the existance of the '/plugin/' tag to detect 
overlays
+               if grep -qse "/plugin/;" `basename ${DTS_FILE}`.pp; then
+                       dtc ${DEVICETREE_OFLAGS} -I dts -O dtb 
${DEVICETREE_FLAGS} -o ${DTS_NAME}.dtbo `basename ${DTS_FILE}`.pp
+               else
+                       dtc -I dts -O dtb ${DEVICETREE_FLAGS} -o 
${DTS_NAME}.dtb `basename ${DTS_FILE}`.pp
+               fi
        done
 }
 
 do_install() {
-       for DTS_FILE in ${DEVICETREE}; do
-               if [ ! -f ${DTS_FILE} ]; then
-                       echo "Warning: ${DTS_FILE} is not available!"
-                       continue
-               fi
-               DTS_NAME=`basename -s .dts ${DTS_FILE}`
-               install -d ${D}/boot/devicetree
-               install -m 0644 ${B}/${DTS_NAME}.dtb 
${D}/boot/devicetree/${DTS_NAME}.dtb
+       for DTB_FILE in `ls *.dtb *.dtbo`; do
+               install -Dm 0644 ${B}/${DTB_FILE} 
${D}/boot/devicetree/${DTB_FILE}
        done
 }
 
 do_deploy() {
-       for DTS_FILE in ${DEVICETREE}; do
-               if [ ! -f ${DTS_FILE} ]; then
-                       echo "Warning: ${DTS_FILE} is not available!"
-                       continue
-               fi
-               DTS_NAME=`basename -s .dts ${DTS_FILE}`
-               install -d ${DEPLOYDIR}
-               install -m 0644 ${B}/${DTS_NAME}.dtb 
${DEPLOYDIR}/${DTS_NAME}.dtb
+       for DTB_FILE in `ls *.dtb *.dtbo`; do
+               install -Dm 0644 ${B}/${DTB_FILE} ${DEPLOYDIR}/${DTB_FILE}
        done
 }
-
 addtask deploy before do_build after do_install
 
-inherit xilinx-utils
-
-DEVICETREE ?= "${@expand_dir_basepaths_by_extension("MACHINE_DEVICETREE", 
os.path.join(d.getVar("WORKDIR", True), 'devicetree'), '.dts', d)}"
-FILESEXTRAPATHS_append := 
"${@get_additional_bbpath_filespath('conf/machine/boards', d)}"
-
-# Using the MACHINE_DEVICETREE and MACHINE_KCONFIG vars, append them to SRC_URI
-SRC_URI += "${@paths_affix(d.getVar("MACHINE_DEVICETREE", True) or '', prefix 
= 'file://')}"
-
-- 
2.11.0

-- 
_______________________________________________
meta-xilinx mailing list
meta-xilinx@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx

Reply via email to