summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-core/recipes-bsp/device-tree/device-tree.bb
diff options
context:
space:
mode:
Diffstat (limited to 'meta-xilinx-core/recipes-bsp/device-tree/device-tree.bb')
-rw-r--r--meta-xilinx-core/recipes-bsp/device-tree/device-tree.bb99
1 files changed, 89 insertions, 10 deletions
diff --git a/meta-xilinx-core/recipes-bsp/device-tree/device-tree.bb b/meta-xilinx-core/recipes-bsp/device-tree/device-tree.bb
index 91a13fa1..8d7211f5 100644
--- a/meta-xilinx-core/recipes-bsp/device-tree/device-tree.bb
+++ b/meta-xilinx-core/recipes-bsp/device-tree/device-tree.bb
@@ -9,6 +9,11 @@ LIC_FILES_CHKSUM = " \
9 file://${COMMON_LICENSE_DIR}/GPL-2.0-or-later;md5=fed54355545ffd980b814dab4a3b312c \ 9 file://${COMMON_LICENSE_DIR}/GPL-2.0-or-later;md5=fed54355545ffd980b814dab4a3b312c \
10 " 10 "
11 11
12# Since we're not based on a kernel default to nothing.
13# This needs to be before the devicetree inherit, as it configured for use
14# with a linux kernel by default.
15KERNEL_INCLUDE ?= ""
16
12inherit devicetree image-artifact-names 17inherit devicetree image-artifact-names
13 18
14# Fall back to SYSTEM_DTFILE if specified... 19# Fall back to SYSTEM_DTFILE if specified...
@@ -17,7 +22,29 @@ inherit devicetree image-artifact-names
17# system. 22# system.
18SYSTEM_DTFILE ??= "" 23SYSTEM_DTFILE ??= ""
19CONFIG_DTFILE ??= "${SYSTEM_DTFILE}" 24CONFIG_DTFILE ??= "${SYSTEM_DTFILE}"
20DT_FILES_PATH = "${@os.path.dirname(d.getVar('CONFIG_DTFILE')) if d.getVar('CONFIG_DTFILE') else d.getVar('S')}" 25
26BASE_DTS ?= "${@os.path.basename(d.getVar('CONFIG_DTFILE') or '').rstrip('.dtb').rstrip('.dts') or 'system-top'}"
27
28EXTRA_DT_FILES ?= ""
29EXTRA_DTFILE_PREFIX ?= "system-top"
30EXTRA_DTFILES_BUNDLE ?= ""
31UBOOT_DT_FILES ?= ""
32UBOOT_DTFILE_PREFIX ?= "system-top"
33UBOOT_DTFILES_BUNDLE ?= ""
34EXTRA_OVERLAYS ?= ""
35
36SYSTEM_DTFILE[doc] = "System Device Tree which accepts at 0...1 dts file"
37CONFIG_DTFILE[doc] = "Domain Specific Device Tree which accepts 0...1 dts file"
38EXTRA_DT_FILES[doc] = "Add extra files to DT_FILES_PATH, it accepts 1...n dtsi files and adds to SRC_URI"
39EXTRA_OVERLAYS[doc] = "Add extra files to DT_FILES_PATH and adds a #include for each to the BASE_DTS, it access 1..n dtsi files and adds to SRC_URI"
40
41# There should only be ONE CONFIG_DTFILE listed
42# These need to be passed in from global, not from a bbappend
43FILESEXTRAPATHS:prepend := "${@'%s:' % os.path.dirname(d.getVar('CONFIG_DTFILE') or '') if (d.getVar('CONFIG_DTFILE')) else ''}"
44SRC_URI:append := " ${@'file://%s' % os.path.basename(d.getVar('CONFIG_DTFILE') or '') if (d.getVar('CONFIG_DTFILE')) else ''}"
45
46SRC_URI:append = " ${@" ".join(["file://%s" % f for f in (d.getVar('EXTRA_DT_FILES') or "").split()])}"
47SRC_URI:append = " ${@" ".join(["file://%s" % f for f in (d.getVar('EXTRA_OVERLAYS') or "").split()])}"
21 48
22COMPATIBLE_MACHINE:zynq = ".*" 49COMPATIBLE_MACHINE:zynq = ".*"
23COMPATIBLE_MACHINE:zynqmp = ".*" 50COMPATIBLE_MACHINE:zynqmp = ".*"
@@ -30,11 +57,71 @@ PROVIDES = "virtual/dtb"
30# common zynq include 57# common zynq include
31SRC_URI:append:zynq = " file://zynq-7000-qspi-dummy.dtsi" 58SRC_URI:append:zynq = " file://zynq-7000-qspi-dummy.dtsi"
32 59
33DTB_FILE_NAME = "${@os.path.basename(d.getVar('CONFIG_DTFILE')).replace('.dts', '.dtb') if d.getVar('CONFIG_DTFILE') else ''}" 60DTB_FILE_NAME ?= "${BASE_DTS}.dtb"
34 61
35DTB_BASE_NAME ?= "${MACHINE}-system${IMAGE_VERSION_SUFFIX}" 62DTB_BASE_NAME ?= "${MACHINE}-system${IMAGE_VERSION_SUFFIX}"
36 63
64# Copy the EXTRA_DT_FILES and EXTRA_OVERLAYS files in prepend operation so that
65# it can be preprocessed.
66do_configure:prepend () {
67 # Create DT_FILES_PATH directory if doesn't exist during prepend operation.
68 if [ ! -d ${DT_FILES_PATH} ]; then
69 mkdir -p ${DT_FILES_PATH}
70 fi
71
72 for f in ${EXTRA_DT_FILES} ${EXTRA_OVERLAYS}; do
73 if [ "$(realpath ${WORKDIR}/${f})" != "$(realpath ${DT_FILES_PATH}/`basename ${f}`)" ]; then
74 cp ${WORKDIR}/${f} ${DT_FILES_PATH}/
75 fi
76 done
77}
78
79do_configure:append () {
80 for f in ${EXTRA_OVERLAYS}; do
81 if [ ! -e ${DT_FILES_PATH}/${BASE_DTS}.dts ]; then
82 if [ -e ${DT_FILES_PATH}/${BASE_DTS}.dtb ]; then
83 bberror "Unable to find ${BASE_DTS}.dts, to use EXTRA_OVERLAYS you must use a 'dts' and not 'dtb' in CONFIG_DTFILE"
84 else
85 bberror "Unable to find ${BASE_DTS}.dts, to use EXTRA_OVERLAYS you must set a valid CONFIG_DTFILE or use system-top.dts"
86 fi
87 exit 1
88 fi
89 echo "/include/ \"$f\"" >> ${DT_FILES_PATH}/${BASE_DTS}.dts
90 done
91}
92
93devicetree_do_compile:append() {
94 import subprocess
95
96 dtb_file = d.getVar('DTB_FILE_NAME') or ''
97 if not dtb_file or not os.path.isfile(dtb_file):
98 bb.error("Expected file ${DTB_FILE_NAME} doesn't exist")
99
100 if d.getVar('EXTRA_DTFILES_BUNDLE'):
101 ccdtb_prefix = d.getVar('EXTRA_DTFILE_PREFIX')
102 extra_dt_files = d.getVar('EXTRA_DT_FILES').split() or []
103
104 for dtsfile in extra_dt_files:
105 dtname = os.path.splitext(os.path.basename(dtsfile))[0]
106 if os.path.isfile(f"{dtname}.dtbo"):
107 fdtargs = ["fdtoverlay", "-o", f"{ccdtb_prefix}-{dtname}.dtb", "-i", dtb_file, f"{dtname}.dtbo"]
108 bb.note("Running {0}".format(" ".join(fdtargs)))
109 subprocess.run(fdtargs, check = True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
110
111 if d.getVar('UBOOT_DTFILES_BUNDLE'):
112 uboot_ccdtb_prefix = d.getVar('UBOOT_DTFILE_PREFIX')
113 uboot_dt_files = d.getVar('UBOOT_DT_FILES').split() or []
114
115 for dtsfile in uboot_dt_files:
116 dtname = os.path.splitext(os.path.basename(dtsfile))[0]
117 if os.path.isfile(f"{dtname}.dtbo"):
118 fdtargs = ["fdtoverlay", "-o", f"{uboot_ccdtb_prefix}-{dtname}.dtb", "-i", dtb_file, f"{dtname}.dtbo"]
119 bb.note("Running {0}".format(" ".join(fdtargs)))
120 subprocess.run(fdtargs, check = True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
121}
122
37FILES:${PN} += "/boot/system.dtb" 123FILES:${PN} += "/boot/system.dtb"
124
38devicetree_do_install:append() { 125devicetree_do_install:append() {
39 if [ -n "${DTB_FILE_NAME}" ]; then 126 if [ -n "${DTB_FILE_NAME}" ]; then
40 # If it's already a dtb, we have to copy from the original location 127 # If it's already a dtb, we have to copy from the original location
@@ -73,14 +160,6 @@ def check_devicetree_variables(d):
73 160
74 if not d.getVar('CONFIG_DTFILE'): 161 if not d.getVar('CONFIG_DTFILE'):
75 raise bb.parse.SkipRecipe("CONFIG_DTFILE or SYSTEM_DTFILE is not defined.") 162 raise bb.parse.SkipRecipe("CONFIG_DTFILE or SYSTEM_DTFILE is not defined.")
76 else:
77 if not os.path.exists(d.getVar('CONFIG_DTFILE')):
78 if not d.getVar('WITHIN_EXT_SDK'):
79 raise bb.parse.SkipRecipe("The device tree %s is not available." % d.getVar('CONFIG_DTFILE'))
80 else:
81 d.appendVar('SRC_URI', ' file://${CONFIG_DTFILE}')
82 d.setVarFlag('do_install', 'file-checksums', '${CONFIG_DTFILE}:True')
83 d.setVarFlag('do_deploy', 'file-checksums', '${CONFIG_DTFILE}:True')
84 163
85python() { 164python() {
86 # Need to allow bbappends to change the check 165 # Need to allow bbappends to change the check