summaryrefslogtreecommitdiffstats
path: root/recipes-bsp/u-boot/u-boot-zynq-uenv.bb
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-bsp/u-boot/u-boot-zynq-uenv.bb')
-rw-r--r--recipes-bsp/u-boot/u-boot-zynq-uenv.bb94
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"
6PACKAGE_ARCH = "${MACHINE_ARCH}" 6PACKAGE_ARCH = "${MACHINE_ARCH}"
7 7
8COMPATIBLE_MACHINE = "^$" 8COMPATIBLE_MACHINE = "^$"
9COMPATIBLE_MACHINE_zynq = "zynq" 9COMPATIBLE_MACHINE_zynq = ".*"
10COMPATIBLE_MACHINE_zynqmp = ".*"
10 11
11inherit deploy 12inherit 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
44do_compile() { 46def 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 55def 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
91KERNEL_BOOTARGS_zynq = "earlyprintk console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait"
92KERNEL_BOOTARGS_zynqmp = "earlycon clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait"
93
94KERNEL_LOAD_ADDRESS_zynq = "0x2080000"
95KERNEL_LOAD_ADDRESS_zynqmp = "0x80000"
96DEVICETREE_LOAD_ADDRESS_zynq = "0x2000000"
97DEVICETREE_LOAD_ADDRESS_zynqmp = "0x4000000"
98
99python 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
74FILES_${PN} += "/boot/uEnv.txt" 106FILES_${PN} += "/boot/uEnv.txt"