[meta-xilinx] [PATCH 17/20] u-boot_2016.03: Add SPL load bitstream and uEnv.txt support

Jason Wu jason.wu.misc at gmail.com
Mon Apr 11 06:23:22 PDT 2016


Adds two patches that supports the follows:
- SPL loading bistream support
- Loading uEnv.txt via MMC or USB and enable u-boot to load uEnv.txt
  from MMC when set to MMC boot mode.

Signed-off-by: Jason Wu <jason.wu.misc at gmail.com>
---
 .../configs-zynq-common-Add-uEnv.txt-support.patch |  66 +++++++++++
 .../zynq-Add-fpga-support-to-u-boot-SPL.patch      | 130 +++++++++++++++++++++
 recipes-bsp/u-boot/u-boot_2016.03.bbappend         |   4 +
 3 files changed, 200 insertions(+)
 create mode 100644 recipes-bsp/u-boot/u-boot/configs-zynq-common-Add-uEnv.txt-support.patch
 create mode 100644 recipes-bsp/u-boot/u-boot/zynq-Add-fpga-support-to-u-boot-SPL.patch

diff --git a/recipes-bsp/u-boot/u-boot/configs-zynq-common-Add-uEnv.txt-support.patch b/recipes-bsp/u-boot/u-boot/configs-zynq-common-Add-uEnv.txt-support.patch
new file mode 100644
index 0000000..06d0b9d
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot/configs-zynq-common-Add-uEnv.txt-support.patch
@@ -0,0 +1,66 @@
+From 4dd0f06c46085cacc607dabbdf288bef6ad67115 Mon Sep 17 00:00:00 2001
+From: Michal Simek <monstr at monstr.eu>
+Date: Fri, 18 Mar 2016 23:43:39 +0100
+Subject: [PATCH] configs: zynq-common: Add uEnv.txt support
+
+preboot macro load the uEnv.txt from mmc 0 when bootmode is mmc. uenvcmd is
+executed after load of uEnv.txt if it is defined in the uEnv.txt env text
+file.
+
+The default importbootenv macro reads the uEnv.txt from mmc.
+
+Additional to this, usb_loadbootenv is added to support loading uEnv.txt
+from usb dev 0.
+
+Upstream-Status: Pending
+
+Signed-off-by: Michal Simek <monstr at monstr.eu>
+Signed-off-by: Jason Wu <jason.wu.misc at gmail.com>
+
+diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
+index 4cb490b..5e3ce95 100644
+--- a/include/configs/zynq-common.h
++++ b/include/configs/zynq-common.h
+@@ -206,6 +206,9 @@
+ # define CONFIG_ENV_OFFSET		0xE0000
+ #endif
+ 
++/* enable preboot to be loaded before CONFIG_BOOTDELAY */
++#define CONFIG_PREBOOT
++
+ /* Default environment */
+ #ifndef CONFIG_EXTRA_ENV_SETTINGS
+ #define CONFIG_EXTRA_ENV_SETTINGS	\
+@@ -216,6 +219,29 @@
+ 	"nor_flash_off=0xE2100000\0"	\
+ 	"fdt_high=0x20000000\0"		\
+ 	"initrd_high=0x20000000\0"	\
++	"loadbootenv_addr=0x2000000\0" \
++	"bootenv=uEnv.txt\0" \
++	"bootenv_dev=mmc\0" \
++	"loadbootenv=load ${bootenv_dev} 0 ${loadbootenv_addr} ${bootenv}\0" \
++	"importbootenv=echo Importing environment from ${bootenv_dev} ...; " \
++		"env import -t ${loadbootenv_addr} $filesize\0" \
++	"bootenv_existence_test=test -e ${bootenv_dev} 0 /${bootenv}\0" \
++	"setbootenv=if env run bootenv_existence_test; then " \
++			"if env run loadbootenv; then " \
++				"env run importbootenv; " \
++			"fi; " \
++		"fi; \0" \
++	"sd_loadbootenv=set bootenv_dev mmc && " \
++			"run setbootenv \0" \
++	"usb_loadbootenv=set bootenv_dev usb && usb start && run setbootenv \0" \
++	"preboot=if test $modeboot = sdboot; then " \
++			"run sd_loadbootenv; " \
++			"echo Checking if uenvcmd is set ...; " \
++			"if test -n $uenvcmd; then " \
++				"echo Running uenvcmd ...; " \
++				"run uenvcmd; " \
++			"fi; " \
++		"fi; \0" \
+ 	"norboot=echo Copying FIT from NOR flash to RAM... && " \
+ 		"cp.b ${nor_flash_off} ${load_addr} ${fit_size} && " \
+ 		"bootm ${load_addr}\0" \
+-- 
+1.9.1
+
diff --git a/recipes-bsp/u-boot/u-boot/zynq-Add-fpga-support-to-u-boot-SPL.patch b/recipes-bsp/u-boot/u-boot/zynq-Add-fpga-support-to-u-boot-SPL.patch
new file mode 100644
index 0000000..ab355af
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot/zynq-Add-fpga-support-to-u-boot-SPL.patch
@@ -0,0 +1,130 @@
+From 14c84972b2c0a32664b3b392d18161998cd1200f Mon Sep 17 00:00:00 2001
+From: Michal Simek <michal.simek at xilinx.com>
+Date: Fri, 18 Mar 2016 17:24:48 +0100
+Subject: [PATCH] zynq: Add fpga support to u-boot SPL
+
+Load bitstream in SPL. "bitstream" can be in bit or bin format.
+
+Upstream-Status: Pending
+
+Signed-off-by: Jason Wu <jason.hy.wu at gmail.com>
+Signed-off-by: Michal Simek <michal.simek at xilinx.com>
+
+diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
+index c27a250..181e40f 100644
+--- a/common/spl/spl_mmc.c
++++ b/common/spl/spl_mmc.c
+@@ -15,6 +15,9 @@
+ #include <errno.h>
+ #include <mmc.h>
+ #include <image.h>
++#include <fat.h>
++#include <fpga.h>
++#include <xilinx.h>
+ 
+ DECLARE_GLOBAL_DATA_PTR;
+ 
+@@ -175,6 +178,39 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
+ }
+ #endif
+ 
++#ifdef CONFIG_SPL_FPGA_SUPPORT
++static int mmc_load_fpga_image_fat(struct mmc *mmc)
++{
++	int err;
++	int devnum = 0;
++	const fpga_desc *const desc = fpga_get_desc(devnum);
++	xilinx_desc *desc_xilinx = desc->devdesc;
++
++	err = spl_load_image_fat(&mmc->block_dev,
++					CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
++					CONFIG_SPL_FPGA_LOAD_ARGS_NAME);
++
++	if (err) {
++#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
++		printf("spl: error reading image %s, err - %d\n",
++		       CONFIG_SPL_FPGA_LOAD_ARGS_NAME, err);
++#endif
++		return -1;
++	}
++
++	err =  fpga_loadbitstream(devnum, (char *)spl_image.load_addr,
++				  desc_xilinx->size, BIT_FULL);
++	if (err) {
++		printf("spl: fail to load bitstream, err - %d\n", err);
++		printf("spl: retry fpga_load\n");
++		err = fpga_load(devnum, (const void *)spl_image.load_addr,
++				desc_xilinx->size, BIT_FULL);
++	}
++
++	return err;
++}
++#endif
++
+ #ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
+ int spl_mmc_do_fs_boot(struct mmc *mmc)
+ {
+@@ -288,6 +324,10 @@ int spl_mmc_load_image(u32 boot_device)
+ 	case MMCSD_MODE_FS:
+ 		debug("spl: mmc boot mode: fs\n");
+ 
++#ifdef CONFIG_SPL_FPGA_SUPPORT
++		mmc_load_fpga_image_fat(mmc);
++#endif
++
+ 		err = spl_mmc_do_fs_boot(mmc);
+ 		if (!err)
+ 			return err;
+diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c
+index ef889ea..41d72ce 100644
+--- a/drivers/fpga/zynqpl.c
++++ b/drivers/fpga/zynqpl.c
+@@ -400,7 +400,7 @@ static int zynq_load(xilinx_desc *desc, const void *buf, size_t bsize,
+ 	return FPGA_SUCCESS;
+ }
+ 
+-#if defined(CONFIG_CMD_FPGA_LOADFS)
++#if defined(CONFIG_CMD_FPGA_LOADFS) && !defined(CONFIG_SPL_BUILD)
+ static int zynq_loadfs(xilinx_desc *desc, const void *buf, size_t bsize,
+ 		       fpga_fs_info *fsinfo)
+ {
+@@ -488,7 +488,7 @@ static int zynq_dump(xilinx_desc *desc, const void *buf, size_t bsize)
+ 
+ struct xilinx_fpga_op zynq_op = {
+ 	.load = zynq_load,
+-#if defined(CONFIG_CMD_FPGA_LOADFS)
++#if defined(CONFIG_CMD_FPGA_LOADFS) && !defined(CONFIG_SPL_BUILD)
+ 	.loadfs = zynq_loadfs,
+ #endif
+ 	.dump = zynq_dump,
+diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
+index 0ddbc99..4cb490b 100644
+--- a/include/configs/zynq-common.h
++++ b/include/configs/zynq-common.h
+@@ -310,6 +310,11 @@
+ 
+ #define CONFIG_SPL_LDSCRIPT	"arch/arm/mach-zynq/u-boot-spl.lds"
+ 
++/* FPGA support */
++#define CONFIG_SPL_FPGA_SUPPORT
++#define CONFIG_SPL_FPGA_LOAD_ADDR      0x1000000
++#define CONFIG_SPL_FPGA_LOAD_ARGS_NAME "bitstream"
++
+ /* MMC support */
+ #ifdef CONFIG_ZYNQ_SDHCI
+ #define CONFIG_SPL_MMC_SUPPORT
+diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
+index 4424284..3c0d937 100644
+--- a/scripts/Makefile.spl
++++ b/scripts/Makefile.spl
+@@ -58,6 +58,7 @@ libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
+ libs-y += drivers/
+ libs-y += dts/
+ libs-y += fs/
++libs-$(CONFIG_SPL_FPGA_SUPPORT) += drivers/fpga/
+ libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
+ libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
+ libs-$(CONFIG_SPL_NET_SUPPORT) += net/
+-- 
+1.9.1
+
diff --git a/recipes-bsp/u-boot/u-boot_2016.03.bbappend b/recipes-bsp/u-boot/u-boot_2016.03.bbappend
index 096f42e..d132ad6 100644
--- a/recipes-bsp/u-boot/u-boot_2016.03.bbappend
+++ b/recipes-bsp/u-boot/u-boot_2016.03.bbappend
@@ -3,6 +3,10 @@ include u-boot-spl-zynq-init.inc
 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
 SRC_URI_append_picozed-zynq7 = " file://ARM-zynq-Configure-picozed-to-use-custom-init.patch"
 
+SRC_URI_append = " file://zynq-Add-fpga-support-to-u-boot-SPL.patch \
+		file://configs-zynq-common-Add-uEnv.txt-support.patch \
+"
+
 # u-boot 2016.03 has support for these
 HAS_PS7INIT ?= " \
 		zynq_microzed_config \
-- 
1.9.1




More information about the meta-xilinx mailing list