diff options
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.bb | 99 |
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. | ||
15 | KERNEL_INCLUDE ?= "" | ||
16 | |||
12 | inherit devicetree image-artifact-names | 17 | inherit 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. |
18 | SYSTEM_DTFILE ??= "" | 23 | SYSTEM_DTFILE ??= "" |
19 | CONFIG_DTFILE ??= "${SYSTEM_DTFILE}" | 24 | CONFIG_DTFILE ??= "${SYSTEM_DTFILE}" |
20 | DT_FILES_PATH = "${@os.path.dirname(d.getVar('CONFIG_DTFILE')) if d.getVar('CONFIG_DTFILE') else d.getVar('S')}" | 25 | |
26 | BASE_DTS ?= "${@os.path.basename(d.getVar('CONFIG_DTFILE') or '').rstrip('.dtb').rstrip('.dts') or 'system-top'}" | ||
27 | |||
28 | EXTRA_DT_FILES ?= "" | ||
29 | EXTRA_DTFILE_PREFIX ?= "system-top" | ||
30 | EXTRA_DTFILES_BUNDLE ?= "" | ||
31 | UBOOT_DT_FILES ?= "" | ||
32 | UBOOT_DTFILE_PREFIX ?= "system-top" | ||
33 | UBOOT_DTFILES_BUNDLE ?= "" | ||
34 | EXTRA_OVERLAYS ?= "" | ||
35 | |||
36 | SYSTEM_DTFILE[doc] = "System Device Tree which accepts at 0...1 dts file" | ||
37 | CONFIG_DTFILE[doc] = "Domain Specific Device Tree which accepts 0...1 dts file" | ||
38 | EXTRA_DT_FILES[doc] = "Add extra files to DT_FILES_PATH, it accepts 1...n dtsi files and adds to SRC_URI" | ||
39 | EXTRA_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 | ||
43 | FILESEXTRAPATHS:prepend := "${@'%s:' % os.path.dirname(d.getVar('CONFIG_DTFILE') or '') if (d.getVar('CONFIG_DTFILE')) else ''}" | ||
44 | SRC_URI:append := " ${@'file://%s' % os.path.basename(d.getVar('CONFIG_DTFILE') or '') if (d.getVar('CONFIG_DTFILE')) else ''}" | ||
45 | |||
46 | SRC_URI:append = " ${@" ".join(["file://%s" % f for f in (d.getVar('EXTRA_DT_FILES') or "").split()])}" | ||
47 | SRC_URI:append = " ${@" ".join(["file://%s" % f for f in (d.getVar('EXTRA_OVERLAYS') or "").split()])}" | ||
21 | 48 | ||
22 | COMPATIBLE_MACHINE:zynq = ".*" | 49 | COMPATIBLE_MACHINE:zynq = ".*" |
23 | COMPATIBLE_MACHINE:zynqmp = ".*" | 50 | COMPATIBLE_MACHINE:zynqmp = ".*" |
@@ -30,11 +57,71 @@ PROVIDES = "virtual/dtb" | |||
30 | # common zynq include | 57 | # common zynq include |
31 | SRC_URI:append:zynq = " file://zynq-7000-qspi-dummy.dtsi" | 58 | SRC_URI:append:zynq = " file://zynq-7000-qspi-dummy.dtsi" |
32 | 59 | ||
33 | DTB_FILE_NAME = "${@os.path.basename(d.getVar('CONFIG_DTFILE')).replace('.dts', '.dtb') if d.getVar('CONFIG_DTFILE') else ''}" | 60 | DTB_FILE_NAME ?= "${BASE_DTS}.dtb" |
34 | 61 | ||
35 | DTB_BASE_NAME ?= "${MACHINE}-system${IMAGE_VERSION_SUFFIX}" | 62 | DTB_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. | ||
66 | do_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 | |||
79 | do_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 | |||
93 | devicetree_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 | |||
37 | FILES:${PN} += "/boot/system.dtb" | 123 | FILES:${PN} += "/boot/system.dtb" |
124 | |||
38 | devicetree_do_install:append() { | 125 | devicetree_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 | ||
85 | python() { | 164 | python() { |
86 | # Need to allow bbappends to change the check | 165 | # Need to allow bbappends to change the check |