[PATCH 2/4] xilinx: zynq: Add support for saving env based on bootmode
Michal Simek
michal.simek at xilinx.com
Tue Mar 30 12:09:58 CEST 2021
From: Ashok Reddy Soma <ashok.reddy.soma at xilinx.com>
Enable saving variables to MMC(FAT), NAND, SPI based on primary
bootmode. If bootmode is JTAG, dont save env anywhere(NOWHERE).
Since most of the flashes on zynq evaluation boards are 16MB in size,
set default ENV_OFFSET to 15MB(0xE00000).
Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma at xilinx.com>
Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---
board/xilinx/zynq/board.c | 32 ++++++++++++++++++++++++++++++
configs/xilinx_zynq_virt_defconfig | 5 ++++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
index 7533dddb9b65..e2e9b3f0f78c 100644
--- a/board/xilinx/zynq/board.c
+++ b/board/xilinx/zynq/board.c
@@ -9,6 +9,7 @@
#include <log.h>
#include <dm/uclass.h>
#include <env.h>
+#include <env_internal.h>
#include <fdtdec.h>
#include <fpga.h>
#include <malloc.h>
@@ -119,3 +120,34 @@ int dram_init(void)
return 0;
}
#endif
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+ u32 bootmode = zynq_slcr_get_boot_mode() & ZYNQ_BM_MASK;
+
+ if (prio)
+ return ENVL_UNKNOWN;
+
+ switch (bootmode) {
+ case ZYNQ_BM_SD:
+ if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
+ return ENVL_FAT;
+ if (IS_ENABLED(CONFIG_ENV_IS_IN_EXT4))
+ return ENVL_EXT4;
+ return ENVL_UNKNOWN;
+ case ZYNQ_BM_NAND:
+ if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND))
+ return ENVL_NAND;
+ if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
+ return ENVL_UBI;
+ return ENVL_UNKNOWN;
+ case ZYNQ_BM_NOR:
+ case ZYNQ_BM_QSPI:
+ if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+ return ENVL_SPI_FLASH;
+ return ENVL_UNKNOWN;
+ case ZYNQ_BM_JTAG:
+ default:
+ return ENVL_NOWHERE;
+ }
+}
diff --git a/configs/xilinx_zynq_virt_defconfig b/configs/xilinx_zynq_virt_defconfig
index 2fe53182caa8..bdd6be2b9079 100644
--- a/configs/xilinx_zynq_virt_defconfig
+++ b/configs/xilinx_zynq_virt_defconfig
@@ -4,6 +4,7 @@ CONFIG_ARCH_ZYNQ=y
CONFIG_SYS_TEXT_BASE=0x4000000
CONFIG_SYS_MEMTEST_START=0x00000000
CONFIG_SYS_MEMTEST_END=0x00001000
+CONFIG_ENV_OFFSET=0xE00000
CONFIG_SYS_SPI_U_BOOT_OFFS=0x100000
CONFIG_DM_GPIO=y
CONFIG_SPL_STACK_R_ADDR=0x200000
@@ -55,7 +56,9 @@ CONFIG_CMD_MTDPARTS_SPREAD=y
CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y
CONFIG_CMD_UBI=y
CONFIG_OF_LIST="zynq-zc702 zynq-zc706 zynq-zc770-xm010 zynq-zc770-xm011 zynq-zc770-xm011-x16 zynq-zc770-xm012 zynq-zc770-xm013 zynq-cc108 zynq-microzed zynq-minized zynq-picozed zynq-zed zynq-zturn zynq-zturn-v5 zynq-zybo zynq-zybo-z7 zynq-dlc20-rev1.0"
-CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_FAT=y
+CONFIG_ENV_IS_IN_NAND=y
CONFIG_ENV_IS_IN_SPI_FLASH=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_NET_RANDOM_ETHADDR=y
--
2.31.0
More information about the U-Boot
mailing list