[meta-xilinx] [PATCH 1/12] u-boot-zynq-uenv.bb: Add recipe to generate uEnv.txt environment
Nathan Rossi
nathan at nathanrossi.com
Sun May 7 07:07:06 PDT 2017
Add a recipe to generate uEnv.txt environments for SD boot of Zynq
targets. This replaces the existing uEnv.txt for zc702/zedboard that
were manually created and populated only for u-boot-xlnx builds.
The generated uEnv.txt files also support auto loading of the fpga
bitstream before the kernel.
Also enable the use of this recipe for all *-zynq7 machines that use
U-Boot and have SD/eMMC available. And additionally setup
IMAGE_BOOT_FILES for these machines.
Signed-off-by: Nathan Rossi <nathan at nathanrossi.com>
---
conf/machine/microzed-zynq7.conf | 8 ++-
conf/machine/picozed-zynq7.conf | 8 ++-
conf/machine/zc702-zynq7.conf | 2 +
conf/machine/zc706-zynq7.conf | 8 +++
conf/machine/zedboard-zynq7.conf | 2 +
conf/machine/zybo-linux-bd-zynq7.conf | 6 +-
conf/machine/zybo-zynq7.conf | 8 ++-
.../u-boot/u-boot-xlnx/zc702-zynq7/uEnv.txt | 4 --
.../u-boot/u-boot-xlnx/zedboard-zynq7/uEnv.txt | 4 --
recipes-bsp/u-boot/u-boot-xlnx_2016.4.bb | 6 --
recipes-bsp/u-boot/u-boot-zynq-uenv.bb | 82 ++++++++++++++++++++++
11 files changed, 120 insertions(+), 18 deletions(-)
delete mode 100644 recipes-bsp/u-boot/u-boot-xlnx/zc702-zynq7/uEnv.txt
delete mode 100644 recipes-bsp/u-boot/u-boot-xlnx/zedboard-zynq7/uEnv.txt
create mode 100644 recipes-bsp/u-boot/u-boot-zynq-uenv.bb
diff --git a/conf/machine/microzed-zynq7.conf b/conf/machine/microzed-zynq7.conf
index 8e24d5f581..ec28c3ffbf 100644
--- a/conf/machine/microzed-zynq7.conf
+++ b/conf/machine/microzed-zynq7.conf
@@ -12,9 +12,15 @@ MACHINE_FEATURES = "ext2 vfat usbhost"
UBOOT_MACHINE = "zynq_microzed_config"
SPL_BINARY = "spl/boot.bin"
+EXTRA_IMAGEDEPENDS += "u-boot-zynq-uenv"
+
SERIAL_CONSOLE = "115200 ttyPS0"
MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "device-tree"
-IMAGE_BOOT_FILES += "boot.bin ${MACHINE}.dtb"
+IMAGE_BOOT_FILES += " \
+ boot.bin \
+ ${MACHINE}.dtb \
+ uEnv.txt \
+ "
diff --git a/conf/machine/picozed-zynq7.conf b/conf/machine/picozed-zynq7.conf
index e1d723c490..2fb310b97c 100644
--- a/conf/machine/picozed-zynq7.conf
+++ b/conf/machine/picozed-zynq7.conf
@@ -16,9 +16,15 @@ MACHINE_FEATURES = "ext2 vfat usbhost usbgadget"
UBOOT_MACHINE = "zynq_picozed_config"
SPL_BINARY = "spl/boot.bin"
+EXTRA_IMAGEDEPENDS += "u-boot-zynq-uenv"
+
SERIAL_CONSOLE = "115200 ttyPS0"
MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "device-tree"
-IMAGE_BOOT_FILES += "boot.bin ${MACHINE}.dtb"
+IMAGE_BOOT_FILES += " \
+ boot.bin \
+ ${MACHINE}.dtb \
+ uEnv.txt \
+ "
diff --git a/conf/machine/zc702-zynq7.conf b/conf/machine/zc702-zynq7.conf
index 503caa3134..ef42301376 100644
--- a/conf/machine/zc702-zynq7.conf
+++ b/conf/machine/zc702-zynq7.conf
@@ -19,6 +19,8 @@ MACHINE_FEATURES = "rtc ext2 ext3 vfat usbhost"
UBOOT_MACHINE = "zynq_zc702_config"
SPL_BINARY = "spl/boot.bin"
+EXTRA_IMAGEDEPENDS += "u-boot-zynq-uenv"
+
SERIAL_CONSOLE = "115200 ttyPS0"
KERNEL_DEVICETREE = "zynq-zc702.dtb"
diff --git a/conf/machine/zc706-zynq7.conf b/conf/machine/zc706-zynq7.conf
index 1aff9d099b..0df5aa7117 100644
--- a/conf/machine/zc706-zynq7.conf
+++ b/conf/machine/zc706-zynq7.conf
@@ -19,8 +19,16 @@ MACHINE_FEATURES = "rtc ext2 ext3 vfat usbhost usbgadget"
UBOOT_MACHINE = "zynq_zc706_config"
SPL_BINARY = "spl/boot.bin"
+EXTRA_IMAGEDEPENDS += "u-boot-zynq-uenv"
+
SERIAL_CONSOLE = "115200 ttyPS0"
KERNEL_DEVICETREE = "zynq-zc706.dtb"
KERNEL_FEATURES += "features/rtc/rtc.scc"
+IMAGE_BOOT_FILES += " \
+ boot.bin \
+ ${KERNEL_IMAGETYPE}-zynq-zc706.dtb \
+ uEnv.txt \
+ "
+
diff --git a/conf/machine/zedboard-zynq7.conf b/conf/machine/zedboard-zynq7.conf
index 90dc993b40..58cee372fd 100644
--- a/conf/machine/zedboard-zynq7.conf
+++ b/conf/machine/zedboard-zynq7.conf
@@ -16,6 +16,8 @@ require conf/machine/include/machine-xilinx-board.inc
UBOOT_MACHINE = "zynq_zed_config"
SPL_BINARY = "spl/boot.bin"
+EXTRA_IMAGEDEPENDS += "u-boot-zynq-uenv"
+
SERIAL_CONSOLE = "115200 ttyPS0"
KERNEL_DEVICETREE = "zynq-zed.dtb"
diff --git a/conf/machine/zybo-linux-bd-zynq7.conf b/conf/machine/zybo-linux-bd-zynq7.conf
index a5505c068f..d44575bdfa 100644
--- a/conf/machine/zybo-linux-bd-zynq7.conf
+++ b/conf/machine/zybo-linux-bd-zynq7.conf
@@ -21,11 +21,15 @@ UBOOT_MACHINE = "zynq_zybo_config"
SPL_BINARY = "spl/boot.bin"
FORCE_PLATFORM_INIT = "1"
+EXTRA_IMAGEDEPENDS += "u-boot-zynq-uenv"
+
EXTRA_IMAGEDEPENDS += "virtual/bitstream"
-IMAGE_BOOT_FILES += "boot.bin \
+IMAGE_BOOT_FILES += " \
+ boot.bin \
${MACHINE}.dtb \
bitstream \
+ uEnv.txt \
"
KERNEL_FEATURES += " \
diff --git a/conf/machine/zybo-zynq7.conf b/conf/machine/zybo-zynq7.conf
index 361d7ccd65..ddddfba1d4 100644
--- a/conf/machine/zybo-zynq7.conf
+++ b/conf/machine/zybo-zynq7.conf
@@ -16,9 +16,15 @@ MACHINE_FEATURES = "ext2 vfat usbhost usbgadget"
UBOOT_MACHINE = "zynq_zybo_config"
SPL_BINARY = "spl/boot.bin"
+EXTRA_IMAGEDEPENDS += "u-boot-zynq-uenv"
+
SERIAL_CONSOLE = "115200 ttyPS0"
KERNEL_DEVICETREE = "zynq-zybo.dtb"
-IMAGE_BOOT_FILES += "boot.bin ${KERNEL_IMAGETYPE}-zynq-zybo.dtb"
+IMAGE_BOOT_FILES += " \
+ boot.bin \
+ ${KERNEL_IMAGETYPE}-zynq-zybo.dtb \
+ uEnv.txt \
+ "
diff --git a/recipes-bsp/u-boot/u-boot-xlnx/zc702-zynq7/uEnv.txt b/recipes-bsp/u-boot/u-boot-xlnx/zc702-zynq7/uEnv.txt
deleted file mode 100644
index b7d5739659..0000000000
--- a/recipes-bsp/u-boot/u-boot-xlnx/zc702-zynq7/uEnv.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-kernel_image=uImage
-devicetree_image=uImage-zynq-zc702.dtb
-bootargs=console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait earlyprintk
-uenvcmd=echo Copying Linux from SD to RAM... && fatload mmc 0 0x3000000 ${kernel_image} && fatload mmc 0 0x2A00000 ${devicetree_image} && bootm 0x3000000 - 0x2A00000
diff --git a/recipes-bsp/u-boot/u-boot-xlnx/zedboard-zynq7/uEnv.txt b/recipes-bsp/u-boot/u-boot-xlnx/zedboard-zynq7/uEnv.txt
deleted file mode 100644
index 22b922a512..0000000000
--- a/recipes-bsp/u-boot/u-boot-xlnx/zedboard-zynq7/uEnv.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-kernel_image=uImage
-devicetree_image=uImage-zynq-zed.dtb
-bootargs=console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait earlyprintk
-uenvcmd=echo Copying Linux from SD to RAM... && fatload mmc 0 0x3000000 ${kernel_image} && fatload mmc 0 0x2A00000 ${devicetree_image} && bootm 0x3000000 - 0x2A00000
diff --git a/recipes-bsp/u-boot/u-boot-xlnx_2016.4.bb b/recipes-bsp/u-boot/u-boot-xlnx_2016.4.bb
index 99ce95a031..71d11324ca 100644
--- a/recipes-bsp/u-boot/u-boot-xlnx_2016.4.bb
+++ b/recipes-bsp/u-boot/u-boot-xlnx_2016.4.bb
@@ -20,12 +20,6 @@ SRC_URI_append_kc705-microblazeel = " file://microblaze-kc705-Convert-microblaze
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://README;beginline=1;endline=6;md5=157ab8408beab40cd8ce1dc69f702a6c"
-UBOOT_ENV_zc702-zynq7 = "uEnv"
-UBOOT_ENV_zedboard-zynq7 = "uEnv"
-
-SRC_URI_append_zc702-zynq7 = " file://uEnv.txt"
-SRC_URI_append_zedboard-zynq7 = " file://uEnv.txt"
-
# u-boot 2016.07 has support for these
HAS_PLATFORM_INIT ?= " \
zynq_microzed_config \
diff --git a/recipes-bsp/u-boot/u-boot-zynq-uenv.bb b/recipes-bsp/u-boot/u-boot-zynq-uenv.bb
new file mode 100644
index 0000000000..60b2759cb5
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-zynq-uenv.bb
@@ -0,0 +1,82 @@
+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"
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+COMPATIBLE_MACHINE = "^$"
+COMPATIBLE_MACHINE_zynq = "zynq"
+
+inherit deploy
+
+def bootfiles_bitstream(d):
+ expectedfiles = [("bitstream", True)]
+ expectedexts = [(".bit", True), (".bin", False)]
+ # search for bitstream paths, use the renamed file. First matching is used
+ for f in (d.getVar("IMAGE_BOOT_FILES") or "").split():
+ sf, rf = f, f
+ if ';' in f:
+ sf, rf = f.split(';')
+
+ # skip boot.bin, it is not a bitstream
+ if sf == "boot.bin" or rf == "boot.bin":
+ continue
+
+ for e, t in expectedfiles:
+ if sf == e or rf == e:
+ return rf, t
+ for e, t in expectedexts:
+ if sf.endswith(e) or rf.endswith(e):
+ return rf, t
+ return "", False
+
+def bootfiles_dtb_filepath(d):
+ if d.getVar("IMAGE_BOOT_FILES"):
+ dtbs = d.getVar("IMAGE_BOOT_FILES").split(" ")
+ # IMAGE_BOOT_FILES has extra renaming info in the format '<source>;<target>'
+ dtbs = [f.split(";")[0] for f in dtbs]
+ dtbs = [f for f in dtbs if f.endswith(".dtb")]
+ if len(dtbs) != 0:
+ return dtbs[0]
+ return ""
+
+do_compile() {
+ echo "machine_name=${MACHINE}" > ${WORKDIR}/uEnv.txt
+
+ echo "kernel_image=${KERNEL_IMAGETYPE}" >> ${WORKDIR}/uEnv.txt
+ echo "devicetree_image=${@bootfiles_dtb_filepath(d)}" >> ${WORKDIR}/uEnv.txt
+
+ # bootargs, default to booting with the rootfs device being partition 2 of the first mmc device
+ echo 'bootargs=console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait earlyprintk' >> ${WORKDIR}/uEnv.txt
+
+ echo 'loadkernel=fatload mmc 0 ${kernel_load_address} ${kernel_image}' >> ${WORKDIR}/uEnv.txt
+ echo 'loaddtb=fatload mmc 0 ${devicetree_load_address} ${devicetree_image}' >> ${WORKDIR}/uEnv.txt
+ echo 'bootkernel=run loadkernel && run loaddtb && bootm ${kernel_load_address} - ${devicetree_load_address}' >> ${WORKDIR}/uEnv.txt
+
+ BITSTREAMPATH="${@bootfiles_bitstream(d)[0]}"
+ if [ ! -z "$BITSTREAMPATH" ]; then
+ echo "bitstream_image=$BITSTREAMPATH" >> ${WORKDIR}/uEnv.txt
+ # if bitstream is "bit" format use loadb, otherwise use load
+ echo "bitstream_type=${@'loadb' if bootfiles_bitstream(d)[1] else 'load'}" >> ${WORKDIR}/uEnv.txt
+ echo 'loadfpga=fatload mmc 0 ${loadbit_addr} ${bitstream_image} && fpga ${bitstream_type} 0 ${loadbit_addr} ${filesize}' >> ${WORKDIR}/uEnv.txt
+
+ # load bitstream first
+ echo "uenvcmd=run loadfpga && run bootkernel" >> ${WORKDIR}/uEnv.txt
+ else
+ # no need to load bitstream during boot
+ echo "uenvcmd=run bootkernel" >> ${WORKDIR}/uEnv.txt
+ fi
+}
+
+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
+
--
2.11.0
More information about the meta-xilinx
mailing list