diff options
-rw-r--r-- | meta-xilinx-bsp/classes/image-wic-utils.bbclass | 51 | ||||
-rw-r--r-- | meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-zynq-uenv.bb | 55 |
2 files changed, 71 insertions, 35 deletions
diff --git a/meta-xilinx-bsp/classes/image-wic-utils.bbclass b/meta-xilinx-bsp/classes/image-wic-utils.bbclass new file mode 100644 index 00000000..6f66d553 --- /dev/null +++ b/meta-xilinx-bsp/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 | |||
8 | def 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]] | ||
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] | ||
25 | yield s, s | ||
26 | |||
27 | def 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 | |||
45 | def 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 | |||
diff --git a/meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-zynq-uenv.bb b/meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-zynq-uenv.bb index f6c2a00d..952077d1 100644 --- a/meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-zynq-uenv.bb +++ b/meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-zynq-uenv.bb | |||
@@ -5,43 +5,28 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda | |||
5 | INHIBIT_DEFAULT_DEPS = "1" | 5 | INHIBIT_DEFAULT_DEPS = "1" |
6 | PACKAGE_ARCH = "${MACHINE_ARCH}" | 6 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
7 | 7 | ||
8 | python () { | ||
9 | # The device trees must be populated in the deploy directory to correctly | ||
10 | # detect them and their names. This means that this recipe needs to depend | ||
11 | # on those deployables just like the image recipe does. | ||
12 | deploydeps = ["virtual/kernel"] | ||
13 | for i in (d.getVar("MACHINE_ESSENTIAL_EXTRA_RDEPENDS") or "").split(): | ||
14 | if i != d.getVar("BPN"): | ||
15 | deploydeps.append(i) | ||
16 | for i in (d.getVar("EXTRA_IMAGEDEPENDS") or "").split(): | ||
17 | if i != d.getVar("BPN"): | ||
18 | deploydeps.append(i) | ||
19 | |||
20 | # add as DEPENDS since the targets might not have do_deploy tasks | ||
21 | if len(deploydeps) != 0: | ||
22 | d.appendVar("DEPENDS", " " + " ".join(deploydeps)) | ||
23 | } | ||
24 | |||
8 | COMPATIBLE_MACHINE = "^$" | 25 | COMPATIBLE_MACHINE = "^$" |
9 | COMPATIBLE_MACHINE_zynq = ".*" | 26 | COMPATIBLE_MACHINE_zynq = ".*" |
10 | COMPATIBLE_MACHINE_zynqmp = ".*" | 27 | COMPATIBLE_MACHINE_zynqmp = ".*" |
11 | 28 | ||
12 | inherit deploy | 29 | inherit deploy image-wic-utils |
13 | |||
14 | def bootfiles_bitstream(d): | ||
15 | expectedfiles = [("bitstream", True)] | ||
16 | expectedexts = [(".bit", True), (".bin", False)] | ||
17 | # search for bitstream paths, use the renamed file. First matching is used | ||
18 | for f in (d.getVar("IMAGE_BOOT_FILES") or "").split(): | ||
19 | sf, rf = f, f | ||
20 | if ';' in f: | ||
21 | sf, rf = f.split(';') | ||
22 | |||
23 | # skip boot.bin and u-boot.bin, it is not a bitstream | ||
24 | skip = ["boot.bin", "u-boot.bin"] | ||
25 | if sf in skip or rf in skip: | ||
26 | continue | ||
27 | |||
28 | for e, t in expectedfiles: | ||
29 | if sf == e or rf == e: | ||
30 | return rf, t | ||
31 | for e, t in expectedexts: | ||
32 | if sf.endswith(e) or rf.endswith(e): | ||
33 | return rf, t | ||
34 | return "", False | ||
35 | |||
36 | def bootfiles_dtb_filepath(d): | ||
37 | if d.getVar("IMAGE_BOOT_FILES"): | ||
38 | dtbs = d.getVar("IMAGE_BOOT_FILES").split(" ") | ||
39 | # IMAGE_BOOT_FILES has extra renaming info in the format '<source>;<target>' | ||
40 | dtbs = [f.split(";")[0] for f in dtbs] | ||
41 | dtbs = [f for f in dtbs if f.endswith(".dtb")] | ||
42 | if len(dtbs) != 0: | ||
43 | return dtbs[0] | ||
44 | return "" | ||
45 | 30 | ||
46 | def uboot_boot_cmd(d): | 31 | def uboot_boot_cmd(d): |
47 | if d.getVar("KERNEL_IMAGETYPE") in ["uImage", "fitImage"]: | 32 | if d.getVar("KERNEL_IMAGETYPE") in ["uImage", "fitImage"]: |
@@ -61,7 +46,7 @@ def uenv_populate(d): | |||
61 | env["kernel_image"] = d.getVar("KERNEL_IMAGETYPE") | 46 | env["kernel_image"] = d.getVar("KERNEL_IMAGETYPE") |
62 | env["kernel_load_address"] = d.getVar("KERNEL_LOAD_ADDRESS") | 47 | env["kernel_load_address"] = d.getVar("KERNEL_LOAD_ADDRESS") |
63 | 48 | ||
64 | env["devicetree_image"] = bootfiles_dtb_filepath(d) | 49 | env["devicetree_image"] = boot_files_dtb_filepath(d) |
65 | env["devicetree_load_address"] = d.getVar("DEVICETREE_LOAD_ADDRESS") | 50 | env["devicetree_load_address"] = d.getVar("DEVICETREE_LOAD_ADDRESS") |
66 | 51 | ||
67 | env["bootargs"] = d.getVar("KERNEL_BOOTARGS") | 52 | env["bootargs"] = d.getVar("KERNEL_BOOTARGS") |
@@ -73,7 +58,7 @@ def uenv_populate(d): | |||
73 | # default uenvcmd does not load bitstream | 58 | # default uenvcmd does not load bitstream |
74 | env["uenvcmd"] = "run bootkernel" | 59 | env["uenvcmd"] = "run bootkernel" |
75 | 60 | ||
76 | bitstream, bitstreamtype = bootfiles_bitstream(d) | 61 | bitstream, bitstreamtype = boot_files_bitstream(d) |
77 | if bitstream: | 62 | if bitstream: |
78 | env["bitstream_image"] = bitstream | 63 | env["bitstream_image"] = bitstream |
79 | env["bitstream_load_address"] = "0x100000" | 64 | env["bitstream_load_address"] = "0x100000" |