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