summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass
diff options
context:
space:
mode:
authorSandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>2023-12-01 09:39:52 -0700
committerMark Hatle <mark.hatle@amd.com>2023-12-08 11:30:55 -0600
commit410a0d133485390ef4bd1148bfcd43d5b225fbd8 (patch)
treedbf367a0cc580c5ebf6c7467d72a8c0bce38e4d0 /meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass
parent9b391bbaf9ed0b83a493f20e48594a1c1e3004ce (diff)
downloadmeta-xilinx-410a0d133485390ef4bd1148bfcd43d5b225fbd8.tar.gz
dfx_user_dts.bbclass: Make bitstream bin as default loadable file
Make bitstream bin as default loadable file for Zynq 7000(Full) and ZynqMP(Full, DFx) dynamic configurations. Below use case are covered as part this patch. 1. If user provides a .bin file as input to dfx_user_dts bbclass then deploy this bin file to lib/firmware directory without any conversion. 2. If user provides a .bit file as input to dfx_user_dts bbclass then convert .bit file to .bin file using bootgen tool and deploy this bin file to lib/firmware directory. 3. Refactor fpga-manager.bbclass with dfx_user_dts.bbclass. Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com> Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass')
-rw-r--r--meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass48
1 files changed, 27 insertions, 21 deletions
diff --git a/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass b/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass
index 4404aa05..bde5be5d 100644
--- a/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass
+++ b/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass
@@ -1,3 +1,8 @@
1#
2# Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved.
3#
4# SPDX-License-Identifier: MIT
5#
1# This bbclass is inherited by flat, DFx Static and DFx RP firmware recipes. 6# This bbclass is inherited by flat, DFx Static and DFx RP firmware recipes.
2# dfx_user_dts.bbclass expects user to generate pl dtsi for flat, DFx Static 7# dfx_user_dts.bbclass expects user to generate pl dtsi for flat, DFx Static
3# and DFx RP xsa outside of yocto. 8# and DFx RP xsa outside of yocto.
@@ -59,7 +64,7 @@ python() {
59 64
60 if '.bin' in d.getVar("SRC_URI") and soc_family != "versal": 65 if '.bin' in d.getVar("SRC_URI") and soc_family != "versal":
61 bin_found = True 66 bin_found = True
62 d.setVar("BIT_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.bin' in a][0].lstrip('file://'))) 67 d.setVar("BIN_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.bin' in a][0].lstrip('file://')))
63 68
64 if '.pdi' in d.getVar("SRC_URI") and soc_family == "versal": 69 if '.pdi' in d.getVar("SRC_URI") and soc_family == "versal":
65 pdi_found = True 70 pdi_found = True
@@ -129,7 +134,7 @@ python do_configure() {
129 soc_family = d.getVar("SOC_FAMILY") 134 soc_family = d.getVar("SOC_FAMILY")
130 135
131 if bb.utils.contains('MACHINE_FEATURES', 'fpga-overlay', False, True, d): 136 if bb.utils.contains('MACHINE_FEATURES', 'fpga-overlay', False, True, d):
132 bb.warn("Using fpga-manager.bbclass requires fpga-overlay MACHINE_FEATURE to be enabled") 137 bb.warn("Using dfx_user_dts.bbclass requires fpga-overlay MACHINE_FEATURE to be enabled")
133 138
134 # Renaming firmware-name using $PN as bitstream/PDI will be renamed using 139 # Renaming firmware-name using $PN as bitstream/PDI will be renamed using
135 # $PN when generating the bin/pdi file. 140 # $PN when generating the bin/pdi file.
@@ -142,7 +147,7 @@ python do_configure() {
142 if soc_family == 'versal': 147 if soc_family == 'versal':
143 newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.pdi\"',line)) 148 newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.pdi\"',line))
144 else: 149 else:
145 newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.bit.bin\"',line)) 150 newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.bin\"',line))
146 shutil.move(new_dtsi,orig_dtsi) 151 shutil.move(new_dtsi,orig_dtsi)
147} 152}
148 153
@@ -153,13 +158,14 @@ python devicetree_do_compile:append() {
153 soc_family = d.getVar("SOC_FAMILY") 158 soc_family = d.getVar("SOC_FAMILY")
154 159
155 dtbo_count = sum(1 for f in glob.iglob((d.getVar('S') + '/*.dtbo'),recursive=True) if os.path.isfile(f)) 160 dtbo_count = sum(1 for f in glob.iglob((d.getVar('S') + '/*.dtbo'),recursive=True) if os.path.isfile(f))
156 161 bin_count = sum(1 for f in glob.iglob((d.getVar('S') + '/*.bin'),recursive=True) if os.path.isfile(f))
157 # Skip devicetree do_compile task if input file is dtbo in SRC_URI 162
158 if not dtbo_count: 163 # Skip devicetree do_compile task if input file is dtbo or bin in SRC_URI
159 # Convert .bit to bit.bin format only if dtsi is input. 164 if not dtbo_count and not bin_count:
160 # In case of dtbo as input, bbclass doesn't know if firmware-name is .bit or 165 # Convert .bit to .bin format only if dtsi is input.
161 # .bit.bin format and corresponding file name. Hence we are not doing 166 # In case of dtbo as input, bbclass doesn't know if firmware-name is .bit
162 # bit.bin conversion. 167 # or .bin format and corresponding file name. Hence we are not doing .bin
168 # conversion.
163 if soc_family != 'versal' and glob.glob(d.getVar('S') + '/' + d.getVar('FIRMWARE_NAME_DT_FILE')): 169 if soc_family != 'versal' and glob.glob(d.getVar('S') + '/' + d.getVar('FIRMWARE_NAME_DT_FILE')):
164 pn = d.getVar('PN') 170 pn = d.getVar('PN')
165 biffile = pn + '.bif' 171 biffile = pn + '.bif'
@@ -168,23 +174,23 @@ python devicetree_do_compile:append() {
168 f.write('all:\n{\n\t' + glob.glob(d.getVar('S')+(d.getVar('BIT_PATH') or '') + '/*.bit')[0] + '\n}') 174 f.write('all:\n{\n\t' + glob.glob(d.getVar('S')+(d.getVar('BIT_PATH') or '') + '/*.bit')[0] + '\n}')
169 175
170 bootgenargs = ["bootgen"] + (d.getVar("BOOTGEN_FLAGS") or "").split() 176 bootgenargs = ["bootgen"] + (d.getVar("BOOTGEN_FLAGS") or "").split()
171 bootgenargs += ["-image", biffile, "-o", pn + ".bit.bin"] 177 bootgenargs += ["-image", biffile, "-o", pn + ".bin"]
172 subprocess.run(bootgenargs, check = True) 178 subprocess.run(bootgenargs, check = True)
173 179
174 # In Zynq7k using both "-process_bitstream bin" and "-o" in bootgen flag, 180 # In Zynq7k using both "-process_bitstream bin" and "-o" in bootgen flag,
175 # to convert bit file to bin format, "-o" option will not be effective 181 # to convert bit file to bin format, "-o" option will not be effective
176 # and generated output file name is ${S}+${BIT_PATH}/<bit_file_name>.bit.bin 182 # and generated output file name is ${S}+${BIT_PATH}/<bit_file_name>.bin
177 # file, Hence we need to rename this file from <bit_file_name>.bit.bin to 183 # file, Hence we need to rename this file from <bit_file_name>.bin to
178 # ${PN}.bit.bin which matches the firmware name in dtbo and move 184 # ${PN}.bin which matches the firmware name in dtbo and move
179 # ${PN}.bit.bin to ${B} directory. 185 # ${PN}.bin to ${B} directory.
180 if soc_family == 'zynq': 186 if soc_family == 'zynq':
181 src_bitbin_file = glob.glob(d.getVar('S') + (d.getVar('BIT_PATH') or '') + '/*.bit.bin')[0] 187 src_bitbin_file = glob.glob(d.getVar('S') + (d.getVar('BIT_PATH') or '') + '/*.bin')[0]
182 dst_bitbin_file = d.getVar('B') + '/' + pn + '.bit.bin' 188 dst_bitbin_file = d.getVar('B') + '/' + pn + '.bin'
183 shutil.move(src_bitbin_file, dst_bitbin_file) 189 shutil.move(src_bitbin_file, dst_bitbin_file)
184 190
185 if not os.path.isfile(pn + ".bit.bin"): 191 if not os.path.isfile(pn + ".bin"):
186 bb.fatal("Couldn't find %s file, Enable '-log trace' in BOOTGEN_FLAGS" \ 192 bb.fatal("Couldn't find %s file, Enable '-log trace' in BOOTGEN_FLAGS" \
187 "and check bootgen_log.txt" % (d.getVar('B') + '/' + pn + '.bit.bin')) 193 "and check bootgen_log.txt" % (d.getVar('B') + '/' + pn + '.bin'))
188} 194}
189 195
190# If user inputs both dtsi and dts files then device-tree will generate dtbo 196# If user inputs both dtsi and dts files then device-tree will generate dtbo
@@ -246,8 +252,8 @@ do_install() {
246 install -Dm 0644 ${S}/*.bit ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ 252 install -Dm 0644 ${S}/*.bit ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/
247 elif [ `ls ${S}/*.bin | wc -l` -eq 1 ] && [ `ls ${S}/*.dtbo | wc -l` -eq 1 ]; then 253 elif [ `ls ${S}/*.bin | wc -l` -eq 1 ] && [ `ls ${S}/*.dtbo | wc -l` -eq 1 ]; then
248 install -Dm 0644 ${S}/*.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ 254 install -Dm 0644 ${S}/*.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/
249 elif [ -f ${B}/${PN}.bit.bin ] && [ -f ${B}/${USER_DTS_FILE}.dtbo ]; then 255 elif [ -f ${B}/${PN}.bin ] && [ -f ${B}/${USER_DTS_FILE}.dtbo ]; then
250 install -Dm 0644 ${B}/${PN}.bit.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.bit.bin 256 install -Dm 0644 ${B}/${PN}.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.bin
251 else 257 else
252 bbfatal "A bitstream file with '.bit' or '.bin' expected but not found" 258 bbfatal "A bitstream file with '.bit' or '.bin' expected but not found"
253 fi 259 fi