summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-core/classes/image-wic-utils.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/image-wic-utils.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/image-wic-utils.bbclass')
-rw-r--r--meta-xilinx-core/classes/image-wic-utils.bbclass51
1 files changed, 51 insertions, 0 deletions
diff --git a/meta-xilinx-core/classes/image-wic-utils.bbclass b/meta-xilinx-core/classes/image-wic-utils.bbclass
new file mode 100644
index 00000000..562f3263
--- /dev/null
+++ b/meta-xilinx-core/classes/image-wic-utils.bbclass
@@ -0,0 +1,51 @@
1# Helper/utility functions to work with the IMAGE_BOOT_FILES variable and its
2# expected behvaior with regards to the contents of the DEPLOY_DIR_IMAGE.
3#
4# The use of these functions assume that the deploy directory is populated with
5# any dependent files/etc. Such that the recipe using these functions depends
6# on the recipe that provides the files being used/queried.
7
8def boot_files_split_expand(d):
9 # IMAGE_BOOT_FILES has extra renaming info in the format '<source>;<target>'
10 for f in (d.getVar("IMAGE_BOOT_FILES") or "").split(" "):
11 parts = f.split(";", 1)
12 sources = [parts[0].strip()]
13 if "*" in parts[0]:
14 # has glob part
15 import glob
16 deployroot = d.getVar("DEPLOY_DIR_IMAGE")
17 sources = []
18 for i in glob.glob(os.path.join(deployroot, parts[0])):
19 sources.append(os.path.basename(i))
20
21 # for all sources, yield an entry
22 for s in sources:
23 if len(parts) == 2:
24 yield s, parts[1].strip()
25 yield s, s
26
27def boot_files_bitstream(d):
28 expectedfiles = [("bitstream", True)]
29 expectedexts = [(".bit", True), (".bin", False)]
30 # search for bitstream paths, use the renamed file. First matching is used
31 for source, target in boot_files_split_expand(d):
32 # skip boot.bin and u-boot.bin, it is not a bitstream
33 skip = ["boot.bin", "u-boot.bin"]
34 if source in skip or target in skip:
35 continue
36
37 for e, t in expectedfiles:
38 if source == e or target == e:
39 return target, t
40 for e, t in expectedexts:
41 if source.endswith(e) or target.endswith(e):
42 return target, t
43 return "", False
44
45def boot_files_dtb_filepath(d):
46 dtbs = (d.getVar("IMAGE_BOOT_FILES") or "").split(" ")
47 for source, target in boot_files_split_expand(d):
48 if target.endswith(".dtb"):
49 return target
50 return ""
51