blob: 228396ebdb6bbdeef0691b2bd7e4dde227a5819f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
SUMMARY = "U-Boot uEnv.txt SD boot environment generation for Zynq targets"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
INHIBIT_DEFAULT_DEPS = "1"
COMPATIBLE_MACHINE = "^$"
COMPATIBLE_MACHINE:zynq = ".*"
COMPATIBLE_MACHINE:zynqmp = ".*"
PACKAGE_ARCH = "${MACHINE_ARCH}"
inherit deploy image-wic-utils
def remove_task_from_depends(d):
extra_imagedepends = d.getVar('EXTRA_IMAGEDEPENDS') or ''
uenv_depends = ''
for imagedepend in extra_imagedepends.split():
if imagedepend == d.getVar("BPN"):
continue
elif ':' in imagedepend:
uenv_depends += ' %s' % imagedepend.split(':')[0]
else:
uenv_depends += ' %s' % imagedepend
return uenv_depends
def uboot_boot_cmd(d):
if d.getVar("KERNEL_IMAGETYPE") in ["uImage", "fitImage"]:
return "bootm"
if d.getVar("KERNEL_IMAGETYPE") in ["zImage"]:
return "bootz"
if d.getVar("KERNEL_IMAGETYPE") in ["Image"]:
return "booti"
raise bb.parse.SkipRecipe("Unsupport kernel image type")
def get_sdbootdev(d):
if d.getVar("SOC_FAMILY") in ["zynqmp"]:
return "${devnum}"
else:
return "0"
def uenv_populate(d):
# populate the environment values
env = {}
env["machine_name"] = d.getVar("MACHINE")
env["kernel_image"] = d.getVar("KERNEL_IMAGETYPE")
env["kernel_load_address"] = d.getVar("KERNEL_LOAD_ADDRESS")
env["devicetree_image"] = boot_files_dtb_filepath(d)
env["devicetree_load_address"] = d.getVar("DEVICETREE_LOAD_ADDRESS")
env["devicetree_overlay_load_address" ] = d.getVar("DEVICETREE_OVERLAY_LOAD_ADDRESS")
env["bootargs"] = d.getVar("KERNEL_BOOTARGS")
env["loadkernel"] = "fatload mmc " + get_sdbootdev(d) + " ${kernel_load_address} ${kernel_image}"
env["loaddtb"] = "fatload mmc " + get_sdbootdev(d) + " ${devicetree_load_address} ${devicetree_image}"
env["loaddtbo"] = "if test -e mmc " + get_sdbootdev(d) + " /devicetree/openamp.dtbo; then fatload mmc " + get_sdbootdev(d) + " ${devicetree_overlay_load_address} /devicetree/openamp.dtbo ; fdt addr ${devicetree_load_address} ; fdt resize 8192 ; fdt apply ${devicetree_overlay_load_address} ; fi"
env["bootkernel"] = "run loadkernel && run loaddtb && run loaddtbo && " + uboot_boot_cmd(d) + " ${kernel_load_address} - ${devicetree_load_address}"
if d.getVar("SOC_FAMILY") in ["zynqmp"]:
env["bootkernel"] = "setenv bootargs " + d.getVar("KERNEL_BOOTARGS") + " ; " + env["bootkernel"]
# default uenvcmd does not load bitstream
env["uenvcmd"] = "run bootkernel"
bitstream, bitstreamtype = boot_files_bitstream(d)
if bitstream:
env["bitstream_image"] = bitstream
env["bitstream_load_address"] = "0x100000"
# if bitstream is "bit" format use loadb, otherwise use load
env["bitstream_type"] = "loadb" if bitstreamtype else "load"
# load bitstream first with loadfpa
env["loadfpga"] = "fatload mmc " + get_sdbootdev(d) + " ${bitstream_load_address} ${bitstream_image} && fpga ${bitstream_type} 0 ${bitstream_load_address} ${filesize}"
env["uenvcmd"] = "run loadfpga && run bootkernel"
return env
DEPENDS:append := " virtual/kernel ${@remove_task_from_depends(d)}"
# bootargs, default to booting with the rootfs device being partition 2
KERNEL_BOOTARGS:zynq = "earlyprintk console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait"
KERNEL_BOOTARGS:zynqmp = "earlycon clk_ignore_unused root=/dev/mmcblk${devnum}p2 rw rootwait"
KERNEL_LOAD_ADDRESS:zynq = "0x2080000"
KERNEL_LOAD_ADDRESS:zynqmp = "0x200000"
DEVICETREE_LOAD_ADDRESS:zynq = "0x2000000"
DEVICETREE_LOAD_ADDRESS:zynqmp = "0x4000000"
DEVICETREE_OVERLAY_LOAD_ADDRESS = "${@hex(int(d.getVar("DEVICETREE_LOAD_ADDRESS"),16) + 0xf00000)}"
python do_compile() {
env = uenv_populate(d)
with open(d.expand("${WORKDIR}/uEnv.txt"), "w") as f:
for k, v in env.items():
f.write("{0}={1}\n".format(k, v))
}
FILES:${PN} += "/boot/uEnv.txt"
do_install() {
install -Dm 0644 ${WORKDIR}/uEnv.txt ${D}/boot/uEnv.txt
}
do_deploy() {
install -Dm 0644 ${WORKDIR}/uEnv.txt ${DEPLOYDIR}/uEnv.txt
}
addtask do_deploy after do_compile before do_build
|