diff options
author | Nathan Rossi <nathan@nathanrossi.com> | 2017-11-14 23:15:23 +1000 |
---|---|---|
committer | Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com> | 2017-11-21 11:19:00 -0800 |
commit | 1b81a517df6b62a37ed7ec14e3c475681ada77d0 (patch) | |
tree | 84d6b72e2130962b00396dfa0d65e556afcee71d | |
parent | 722613acc702623ba392f0a4338160d3b1c79c6b (diff) | |
download | meta-xilinx-1b81a517df6b62a37ed7ec14e3c475681ada77d0.tar.gz |
u-boot-zynq-uenv.bb: Rework into python task and support ZynqMP
Rework the do_compile from shell appends into a python task such that
special string content ('${..}' of u-boot environment vars) can be
handed cleanly.
Additionally rework some variables such that they can be overridden for
zynq/zynqmp specific values, as well as allowing custom overrides to
e.g. bootargs.
This also adds support for differing image load types include Image
(arm64), zImage, fitImage and the existing uImage. The u-boot cmd
(boot*) is automatically selected depending on the type of
KERNEL_IMAGETYPE.
Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
-rw-r--r-- | recipes-bsp/u-boot/u-boot-zynq-uenv.bb | 94 |
1 files changed, 63 insertions, 31 deletions
diff --git a/recipes-bsp/u-boot/u-boot-zynq-uenv.bb b/recipes-bsp/u-boot/u-boot-zynq-uenv.bb index 6cb9b9ec..f6c2a00d 100644 --- a/recipes-bsp/u-boot/u-boot-zynq-uenv.bb +++ b/recipes-bsp/u-boot/u-boot-zynq-uenv.bb | |||
@@ -6,7 +6,8 @@ INHIBIT_DEFAULT_DEPS = "1" | |||
6 | PACKAGE_ARCH = "${MACHINE_ARCH}" | 6 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
7 | 7 | ||
8 | COMPATIBLE_MACHINE = "^$" | 8 | COMPATIBLE_MACHINE = "^$" |
9 | COMPATIBLE_MACHINE_zynq = "zynq" | 9 | COMPATIBLE_MACHINE_zynq = ".*" |
10 | COMPATIBLE_MACHINE_zynqmp = ".*" | ||
10 | 11 | ||
11 | inherit deploy | 12 | inherit deploy |
12 | 13 | ||
@@ -19,8 +20,9 @@ def bootfiles_bitstream(d): | |||
19 | if ';' in f: | 20 | if ';' in f: |
20 | sf, rf = f.split(';') | 21 | sf, rf = f.split(';') |
21 | 22 | ||
22 | # skip boot.bin, it is not a bitstream | 23 | # skip boot.bin and u-boot.bin, it is not a bitstream |
23 | if sf == "boot.bin" or rf == "boot.bin": | 24 | skip = ["boot.bin", "u-boot.bin"] |
25 | if sf in skip or rf in skip: | ||
24 | continue | 26 | continue |
25 | 27 | ||
26 | for e, t in expectedfiles: | 28 | for e, t in expectedfiles: |
@@ -41,34 +43,64 @@ def bootfiles_dtb_filepath(d): | |||
41 | return dtbs[0] | 43 | return dtbs[0] |
42 | return "" | 44 | return "" |
43 | 45 | ||
44 | do_compile() { | 46 | def uboot_boot_cmd(d): |
45 | echo "machine_name=${MACHINE}" > ${WORKDIR}/uEnv.txt | 47 | if d.getVar("KERNEL_IMAGETYPE") in ["uImage", "fitImage"]: |
46 | 48 | return "bootm" | |
47 | echo "kernel_image=${KERNEL_IMAGETYPE}" >> ${WORKDIR}/uEnv.txt | 49 | if d.getVar("KERNEL_IMAGETYPE") in ["zImage"]: |
48 | echo "kernel_load_address=0x2080000" >> ${WORKDIR}/uEnv.txt | 50 | return "bootz" |
49 | echo "devicetree_image=${@bootfiles_dtb_filepath(d)}" >> ${WORKDIR}/uEnv.txt | 51 | if d.getVar("KERNEL_IMAGETYPE") in ["Image"]: |
50 | echo "devicetree_load_address=0x2000000" >> ${WORKDIR}/uEnv.txt | 52 | return "booti" |
51 | 53 | raise bb.parse.SkipRecipe("Unsupport kernel image type") | |
52 | # bootargs, default to booting with the rootfs device being partition 2 of the first mmc device | 54 | |
53 | echo 'bootargs=console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait earlyprintk' >> ${WORKDIR}/uEnv.txt | 55 | def uenv_populate(d): |
54 | 56 | # populate the environment values | |
55 | echo 'loadkernel=fatload mmc 0 ${kernel_load_address} ${kernel_image}' >> ${WORKDIR}/uEnv.txt | 57 | env = {} |
56 | echo 'loaddtb=fatload mmc 0 ${devicetree_load_address} ${devicetree_image}' >> ${WORKDIR}/uEnv.txt | 58 | |
57 | echo 'bootkernel=run loadkernel && run loaddtb && bootm ${kernel_load_address} - ${devicetree_load_address}' >> ${WORKDIR}/uEnv.txt | 59 | env["machine_name"] = d.getVar("MACHINE") |
58 | 60 | ||
59 | BITSTREAMPATH="${@bootfiles_bitstream(d)[0]}" | 61 | env["kernel_image"] = d.getVar("KERNEL_IMAGETYPE") |
60 | if [ ! -z "$BITSTREAMPATH" ]; then | 62 | env["kernel_load_address"] = d.getVar("KERNEL_LOAD_ADDRESS") |
61 | echo "bitstream_image=$BITSTREAMPATH" >> ${WORKDIR}/uEnv.txt | 63 | |
62 | # if bitstream is "bit" format use loadb, otherwise use load | 64 | env["devicetree_image"] = bootfiles_dtb_filepath(d) |
63 | echo "bitstream_type=${@'loadb' if bootfiles_bitstream(d)[1] else 'load'}" >> ${WORKDIR}/uEnv.txt | 65 | env["devicetree_load_address"] = d.getVar("DEVICETREE_LOAD_ADDRESS") |
64 | echo 'loadfpga=fatload mmc 0 ${loadbit_addr} ${bitstream_image} && fpga ${bitstream_type} 0 ${loadbit_addr} ${filesize}' >> ${WORKDIR}/uEnv.txt | 66 | |
65 | 67 | env["bootargs"] = d.getVar("KERNEL_BOOTARGS") | |
66 | # load bitstream first | 68 | |
67 | echo "uenvcmd=run loadfpga && run bootkernel" >> ${WORKDIR}/uEnv.txt | 69 | env["loadkernel"] = "fatload mmc 0 ${kernel_load_address} ${kernel_image}" |
68 | else | 70 | env["loaddtb"] = "fatload mmc 0 ${devicetree_load_address} ${devicetree_image}" |
69 | # no need to load bitstream during boot | 71 | env["bootkernel"] = "run loadkernel && run loaddtb && " + uboot_boot_cmd(d) + " ${kernel_load_address} - ${devicetree_load_address}" |
70 | echo "uenvcmd=run bootkernel" >> ${WORKDIR}/uEnv.txt | 72 | |
71 | fi | 73 | # default uenvcmd does not load bitstream |
74 | env["uenvcmd"] = "run bootkernel" | ||
75 | |||
76 | bitstream, bitstreamtype = bootfiles_bitstream(d) | ||
77 | if bitstream: | ||
78 | env["bitstream_image"] = bitstream | ||
79 | env["bitstream_load_address"] = "0x100000" | ||
80 | |||
81 | # if bitstream is "bit" format use loadb, otherwise use load | ||
82 | env["bitstream_type"] = "loadb" if bitstreamtype else "load" | ||
83 | |||
84 | # load bitstream first with loadfpa | ||
85 | env["loadfpga"] = "fatload mmc 0 ${bitstream_load_address} ${bitstream_image} && fpga ${bitstream_type} 0 ${bitstream_load_address} ${filesize}" | ||
86 | env["uenvcmd"] = "run loadfpga && run bootkernel" | ||
87 | |||
88 | return env | ||
89 | |||
90 | # bootargs, default to booting with the rootfs device being partition 2 of the first mmc device | ||
91 | KERNEL_BOOTARGS_zynq = "earlyprintk console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait" | ||
92 | KERNEL_BOOTARGS_zynqmp = "earlycon clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait" | ||
93 | |||
94 | KERNEL_LOAD_ADDRESS_zynq = "0x2080000" | ||
95 | KERNEL_LOAD_ADDRESS_zynqmp = "0x80000" | ||
96 | DEVICETREE_LOAD_ADDRESS_zynq = "0x2000000" | ||
97 | DEVICETREE_LOAD_ADDRESS_zynqmp = "0x4000000" | ||
98 | |||
99 | python do_compile() { | ||
100 | env = uenv_populate(d) | ||
101 | with open(d.expand("${WORKDIR}/uEnv.txt"), "w") as f: | ||
102 | for k, v in env.items(): | ||
103 | f.write("{0}={1}\n".format(k, v)) | ||
72 | } | 104 | } |
73 | 105 | ||
74 | FILES_${PN} += "/boot/uEnv.txt" | 106 | FILES_${PN} += "/boot/uEnv.txt" |