summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2017-04-15 20:36:07 +1000
committerNathan Rossi <nathan@nathanrossi.com>2017-04-26 15:33:30 +1000
commita765a5bdbf0da72704bbe88171571ecc82668a0a (patch)
tree6194606636666401f6a9e954007783a8aa71a9f2
parent063c92bf64e21c419823313c00fd351179ad413b (diff)
downloadmeta-xilinx-a765a5bdbf0da72704bbe88171571ecc82668a0a.tar.gz
device-tree: Improve, clean up and remove MACHINE_DEVICETREE
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 <nathan@nathanrossi.com>
-rw-r--r--classes/xilinx-utils.bbclass58
-rw-r--r--recipes-bsp/device-tree/device-tree.bb107
2 files changed, 41 insertions, 124 deletions
diff --git a/classes/xilinx-utils.bbclass b/classes/xilinx-utils.bbclass
deleted file mode 100644
index 0d007b94..00000000
--- a/classes/xilinx-utils.bbclass
+++ /dev/null
@@ -1,58 +0,0 @@
1# Utility functions for various Xilinx specific recipes
2
3# Returns a ':' seperated list of expanded '${BBPATH}/$path'
4def get_additional_bbpath_filespath(path, d):
5 board_extrapaths = []
6 bbpath = d.getVar("BBPATH", True) or ""
7 for i in bbpath.split(":"):
8 board_extrapaths.append(os.path.join(i, path))
9 if len(board_extrapaths):
10 return ":".join(board_extrapaths) + ":"
11 return ""
12
13# Add a prefix or suffix to all paths in the list of paths
14# e.g. add 'file://' to all paths
15def paths_affix(paths, suffix = "", prefix = ""):
16 if paths:
17 files=set()
18 for path in paths.split():
19 newpath = path
20 if suffix and len(suffix) != 0:
21 newpath = newpath + suffix
22 if prefix and len(prefix) != 0:
23 newpath = prefix + newpath
24 files.add(newpath)
25 if len(files) != 0:
26 return ' '.join(files)
27 return ''
28
29# Expand all relative paths to absolute based on the WORKDIR location
30def expand_workdir_paths(variable, d):
31 workdir = d.getVar("WORKDIR", True)
32 variable_value = d.getVar(variable, True) or ''
33 if variable_value:
34 files=set()
35 for path in variable_value.split():
36 if workdir:
37 files.add(os.path.join(workdir, path))
38 else:
39 files.add(path)
40 if len(files) != 0:
41 return ' '.join(files)
42 return ''
43
44# Returns a space seperated list of all files which match the extension, joined
45# with the dir path.
46def expand_dir_basepaths_by_extension(variable, dir, extension, d):
47 variable_value = d.getVar(variable, True) or ''
48 if variable_value:
49 files=set()
50 for path in variable_value.split():
51 if os.path.splitext(path)[1] == extension or extension == None:
52 if dir:
53 files.add(os.path.join(dir, os.path.basename(path)))
54 else:
55 files.add(os.path.basename(path))
56 if len(files) != 0:
57 return ' '.join(files)
58 return ''
diff --git a/recipes-bsp/device-tree/device-tree.bb b/recipes-bsp/device-tree/device-tree.bb
index 2846ca99..c71f7ddb 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"
2DESCRIPTION = "Device Tree generation and packaging for BSP Device Trees." 2DESCRIPTION = "Device Tree generation and packaging for BSP Device Trees."
3SECTION = "bsp" 3SECTION = "bsp"
4 4
5LICENSE = "MIT" 5LICENSE = "MIT & GPLv2"
6LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" 6LIC_FILES_CHKSUM = " \
7 file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302 \
8 file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 \
9 "
7 10
8inherit deploy 11inherit deploy
12inherit kernel-arch
9 13
10INHIBIT_DEFAULT_DEPS = "1" 14INHIBIT_DEFAULT_DEPS = "1"
11PACKAGE_ARCH = "${MACHINE_ARCH}"
12
13DEPENDS += "dtc-native" 15DEPENDS += "dtc-native"
14 16
15FILES_${PN} = "/boot/devicetree*" 17PACKAGE_ARCH = "${MACHINE_ARCH}"
16DEVICETREE_FLAGS ?= "-R 8 -p 0x3000 \
17 -i ${WORKDIR}/devicetree \
18 ${@' '.join(['-i %s' % i for i in d.getVar('KERNEL_DTS_INCLUDE', True).split()])} \
19 "
20DEVICETREE_PP_FLAGS ?= "-nostdinc -Ulinux \
21 -I${WORKDIR}/devicetree \
22 ${@' '.join(['-I%s' % i for i in d.getVar('KERNEL_DTS_INCLUDE', True).split()])} \
23 -x assembler-with-cpp \
24 "
25 18
26FILESEXTRAPATHS_prepend := "${THISDIR}/files:" 19FILES_${PN} = "/boot/devicetree/*.dtb /boot/devicetree/*.dtbo"
27MACHINE_DEVICETREE_prepend_zynq = " \
28 common/zynq-7000-qspi-dummy.dtsi \
29 "
30 20
31S = "${WORKDIR}" 21S = "${WORKDIR}"
22B = "${WORKDIR}/build"
32 23
33KERNEL_DTS_INCLUDE ??= "" 24# By default provide the current kernel arch's boot/dts and boot/dts/include.
34KERNEL_DTS_INCLUDE_zynq = " \ 25KERNEL_DTS_INCLUDE ??= " \
35 ${STAGING_KERNEL_DIR}/arch/arm/boot/dts \ 26 ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts \
36 ${STAGING_KERNEL_DIR}/arch/arm/boot/dts/include \ 27 ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/include \
37 " 28 "
38KERNEL_DTS_INCLUDE_zynqmp = " \ 29# For arm64/zynqmp the xilinx specific includes are subdired under a vendor directory.
39 ${STAGING_KERNEL_DIR}/arch/arm64/boot/dts \ 30KERNEL_DTS_INCLUDE_append_zynqmp = " \
40 ${STAGING_KERNEL_DIR}/arch/arm64/boot/dts/include \ 31 ${STAGING_KERNEL_DIR}/arch/${ARCH}/boot/dts/xilinx \
41 ${STAGING_KERNEL_DIR}/arch/arm64/boot/dts/xilinx \ 32 "
33
34DEVICETREE_FLAGS ?= " \
35 -R 8 -p 0x3000 -b 0 -i ${S} \
36 ${@' '.join(['-i %s' % i for i in d.getVar('KERNEL_DTS_INCLUDE', True).split()])} \
37 "
38DEVICETREE_OFLAGS ?= "-@ -H epapr"
39DEVICETREE_PP_FLAGS ?= " \
40 -nostdinc -Ulinux -x assembler-with-cpp -I${S} \
41 ${@' '.join(['-I%s' % i for i in d.getVar('KERNEL_DTS_INCLUDE', True).split()])} \
42 " 42 "
43 43
44python () { 44python () {
45 # auto add dependency on kernel tree 45 # auto add dependency on kernel tree
46 if d.getVar("KERNEL_DTS_INCLUDE", True) != "": 46 if d.getVar("KERNEL_DTS_INCLUDE") != "":
47 d.setVarFlag("do_compile", "depends", 47 d.appendVarFlag("do_compile", "depends", " virtual/kernel:do_shared_workdir")
48 " ".join([d.getVarFlag("do_compile", "depends", True) or "", "virtual/kernel:do_shared_workdir"]))
49} 48}
50 49
51do_compile() { 50do_compile() {
52 if test -n "${MACHINE_DEVICETREE}"; then 51 for DTS_FILE in ${S}/*.dts; do
53 mkdir -p ${WORKDIR}/devicetree
54 for i in ${MACHINE_DEVICETREE}; do
55 if test -e ${WORKDIR}/$i; then
56 cp ${WORKDIR}/$i ${WORKDIR}/devicetree
57 fi
58 done
59 fi
60
61 for DTS_FILE in ${DEVICETREE}; do
62 DTS_NAME=`basename -s .dts ${DTS_FILE}` 52 DTS_NAME=`basename -s .dts ${DTS_FILE}`
63 ${BUILD_CPP} ${DEVICETREE_PP_FLAGS} -o ${DTS_FILE}.pp ${DTS_FILE} 53 ${BUILD_CPP} ${DEVICETREE_PP_FLAGS} -o `basename ${DTS_FILE}`.pp ${DTS_FILE}
64 dtc -I dts -O dtb ${DEVICETREE_FLAGS} -o ${DTS_NAME}.dtb ${DTS_FILE}.pp 54
55 # for now use the existance of the '/plugin/' tag to detect overlays
56 if grep -qse "/plugin/;" `basename ${DTS_FILE}`.pp; then
57 dtc ${DEVICETREE_OFLAGS} -I dts -O dtb ${DEVICETREE_FLAGS} -o ${DTS_NAME}.dtbo `basename ${DTS_FILE}`.pp
58 else
59 dtc -I dts -O dtb ${DEVICETREE_FLAGS} -o ${DTS_NAME}.dtb `basename ${DTS_FILE}`.pp
60 fi
65 done 61 done
66} 62}
67 63
68do_install() { 64do_install() {
69 for DTS_FILE in ${DEVICETREE}; do 65 for DTB_FILE in `ls *.dtb *.dtbo`; do
70 if [ ! -f ${DTS_FILE} ]; then 66 install -Dm 0644 ${B}/${DTB_FILE} ${D}/boot/devicetree/${DTB_FILE}
71 echo "Warning: ${DTS_FILE} is not available!"
72 continue
73 fi
74 DTS_NAME=`basename -s .dts ${DTS_FILE}`
75 install -d ${D}/boot/devicetree
76 install -m 0644 ${B}/${DTS_NAME}.dtb ${D}/boot/devicetree/${DTS_NAME}.dtb
77 done 67 done
78} 68}
79 69
80do_deploy() { 70do_deploy() {
81 for DTS_FILE in ${DEVICETREE}; do 71 for DTB_FILE in `ls *.dtb *.dtbo`; do
82 if [ ! -f ${DTS_FILE} ]; then 72 install -Dm 0644 ${B}/${DTB_FILE} ${DEPLOYDIR}/${DTB_FILE}
83 echo "Warning: ${DTS_FILE} is not available!"
84 continue
85 fi
86 DTS_NAME=`basename -s .dts ${DTS_FILE}`
87 install -d ${DEPLOYDIR}
88 install -m 0644 ${B}/${DTS_NAME}.dtb ${DEPLOYDIR}/${DTS_NAME}.dtb
89 done 73 done
90} 74}
91
92addtask deploy before do_build after do_install 75addtask deploy before do_build after do_install
93 76
94inherit xilinx-utils
95
96DEVICETREE ?= "${@expand_dir_basepaths_by_extension("MACHINE_DEVICETREE", os.path.join(d.getVar("WORKDIR", True), 'devicetree'), '.dts', d)}"
97FILESEXTRAPATHS_append := "${@get_additional_bbpath_filespath('conf/machine/boards', d)}"
98
99# Using the MACHINE_DEVICETREE and MACHINE_KCONFIG vars, append them to SRC_URI
100SRC_URI += "${@paths_affix(d.getVar("MACHINE_DEVICETREE", True) or '', prefix = 'file://')}"
101