summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-core/classes/fpgamanager_custom.bbclass
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@xilinx.com>2021-12-15 13:52:16 -0800
committerMark Hatle <mark.hatle@xilinx.com>2021-12-22 08:19:01 -0800
commit322e23dc213d51a12345ca705b3776f189dc413f (patch)
treee257ca97fa6d3eef83c845b67d711b2d8ecba5ba /meta-xilinx-core/classes/fpgamanager_custom.bbclass
parentdd95dde009dc7968f6e6e4c0609e7b443c55c627 (diff)
downloadmeta-xilinx-322e23dc213d51a12345ca705b3776f189dc413f.tar.gz
Initial restructure/split of meta-xilinx-bsp
Create a new meta-xilinx-core, move core functionality to the core, keeping board specific files in the bsp layer. zynqmp-generic changed from require <board> to include, so if meta-xilinx-bsp is not available it will not fail. Signed-off-by: Mark Hatle <mark.hatle@xilinx.com>
Diffstat (limited to 'meta-xilinx-core/classes/fpgamanager_custom.bbclass')
-rw-r--r--meta-xilinx-core/classes/fpgamanager_custom.bbclass85
1 files changed, 85 insertions, 0 deletions
diff --git a/meta-xilinx-core/classes/fpgamanager_custom.bbclass b/meta-xilinx-core/classes/fpgamanager_custom.bbclass
new file mode 100644
index 00000000..0b5fa249
--- /dev/null
+++ b/meta-xilinx-core/classes/fpgamanager_custom.bbclass
@@ -0,0 +1,85 @@
1LICENSE = "MIT"
2LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
3
4inherit devicetree
5
6DEPENDS = "dtc-native bootgen-native"
7
8COMPATIBLE_MACHINE ?= "^$"
9COMPATIBLE_MACHINE:zynqmp = ".*"
10COMPATIBLE_MACHINE:zynq = ".*"
11
12PROVIDES = ""
13
14do_fetch[cleandirs] = "${B}"
15
16DT_PADDING_SIZE = "0x1000"
17BOOTGEN_FLAGS ?= " -arch ${SOC_FAMILY} ${@bb.utils.contains('SOC_FAMILY','zynqmp','-w','-process_bitstream bin',d)}"
18
19S ?= "${WORKDIR}"
20FW_DIR ?= ""
21DTSI_PATH ?= ""
22DT_FILES_PATH = "${S}/${DTSI_PATH}"
23
24python (){
25
26 if "git://" in d.getVar("SRC_URI") or "https://" in d.getVar("SRC_URI"):
27 d.setVar("S",'${WORKDIR}/git/'+d.getVar("FW_DIR"))
28 else:
29 if d.getVar("SRC_URI").count(".dtsi") != 1 or d.getVar("SRC_URI").count(".bit") != 1 \
30 or d.getVar("SRC_URI").count("shell.json") != 1:
31 raise bb.parse.SkipRecipe("Need one '.dtsi', one '.bit' and one 'shell.json' file added to SRC_URI")
32
33 d.setVar("DTSI_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split('file://') if '.dtsi' in a][0]))
34 d.setVar("BIT_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split('file://') if '.bit' in a][0]))
35 d.setVar("JSON_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split('file://') if 'shell.json' in a][0]))
36
37 #optional input
38 if '.xclbin' in d.getVar("SRC_URI"):
39 d.setVar("XCL_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split('file://') if '.xclbin' in a][0]))
40}
41python do_configure() {
42 import glob, re, shutil
43
44 if bb.utils.contains('MACHINE_FEATURES', 'fpga-overlay', False, True, d):
45 bb.warn("Using fpga-manager.bbclass requires fpga-overlay MACHINE_FEATURE to be enabled")
46
47 #renaming firmware-name using $PN as bitstream will be renamed using $PN when generating the bin file
48 orig_dtsi = glob.glob(d.getVar('S')+ (d.getVar('DTSI_PATH') or '') + '/*.dtsi')[0]
49 new_dtsi = d.getVar('S') + '/pl.dtsi_firmwarename'
50 with open(new_dtsi, 'w') as newdtsi:
51 with open(orig_dtsi) as olddtsi:
52 for line in olddtsi:
53 newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.bit.bin\"',line))
54 shutil.move(new_dtsi,orig_dtsi)
55}
56
57python devicetree_do_compile:append() {
58 import glob, subprocess
59 pn = d.getVar('PN')
60 biffile = pn + '.bif'
61
62 with open(biffile, 'w') as f:
63 f.write('all:\n{\n\t' + glob.glob(d.getVar('S')+(d.getVar('BIT_PATH') or '') + '/*.bit')[0] + '\n}')
64
65 bootgenargs = ["bootgen"] + (d.getVar("BOOTGEN_FLAGS") or "").split()
66 bootgenargs += ["-image", biffile, "-o", pn + ".bit.bin"]
67 subprocess.run(bootgenargs, check = True)
68
69 if not os.path.isfile(pn + ".bit.bin"):
70 bb.fatal("bootgen failed. Enable -log debug with bootgen and check logs")
71}
72
73do_install() {
74 install -d ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/
75 install -Dm 0644 *.dtbo ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.dtbo
76 install -Dm 0644 ${PN}.bit.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.bit.bin
77 if ls ${S}/${XCL_PATH}/*.xclbin >/dev/null 2>&1; then
78 install -Dm 0644 ${S}/${XCL_PATH}/*.xclbin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.xclbin
79 fi
80 install -Dm 0644 ${S}/${JSON_PATH}/shell.json ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/shell.json
81}
82
83do_deploy[noexec] = "1"
84
85FILES:${PN} += "${nonarch_base_libdir}/firmware/xilinx/${PN}"