Skip to contentSkip to conversation

xilinx: Enable redundant variables for all Xilinx SoCs

PATCH New Michal Simek 2 participants 6 messages Mar 30, 2021 – Apr 23, 2021 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

cover xilinx: Enable redundant variables for all Xilinx SoCs

Hi,

based on discussion with Tom here
https://lists.denx.de/pipermail/u-boot/2021-January/437234.html
I decided to enable redundant variables on all Xilinx SoCs. Users who don't want to use it can disable this option. But having extended structure for variable storing is based on that thread above the right way to go. It means switch to the right approach is better to do earlier rather than later.

Thanks,
Michal

Ashok Reddy Soma (2):
xilinx: zynq: Add support for saving env based on bootmode
xilinx: versal: Add support for saving env based on bootmode

Michal Simek (2):
env: Setup default value for ENV_OFFSET_REDUND
xilinx: Enable redundant variable handling

 board/xilinx/versal/board.c          | 30 ++++++++++++++++++++++++++
 board/xilinx/zynq/board.c            | 32 ++++++++++++++++++++++++++++
 configs/microblaze-generic_defconfig |  1 +
 configs/xilinx_versal_virt_defconfig |  4 ++++
 configs/xilinx_zynq_virt_defconfig   |  6 +++++-
 configs/xilinx_zynqmp_virt_defconfig |  1 +
 env/Kconfig                          |  3 ++-
 7 files changed, 75 insertions(+), 2 deletions(-)
Signature · 1 line
2.31.0
#1 lore raw

PATCH 1/4 env: Setup default value for ENV_OFFSET_REDUND

This variable is used for pointing to location where redundant variables are located. There is no default value. And it doesn't need to be specified which is showing as warning when savedefconfig is called.

make xilinx_zynqmp_virt_defconfig
#

 # configuration written to .config
 #
make savedefconfig
 scripts/kconfig/conf  --savedefconfig=defconfig Kconfig
 .config:199:warning: symbol value '' invalid for ENV_OFFSET_REDUND

---

 env/Kconfig | 1 +
 1 file changed, 1 insertion(+)
env/Kconfig +1 -0
index b473d7cfe1e9..bc4f7d8f4ee4 100644
@@ -534,6 +534,7 @@ config ENV_OFFSET_REDUND
 	hex "Redundant environment offset"
 	depends on (ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \
 		    ENV_IS_IN_SPI_FLASH) && SYS_REDUNDAND_ENVIRONMENT
+	default 0
 	help
 	  Offset from the start of the device (or partition) of the redundant
 	  environment location.
Signature · 1 line
2.31.0
#2 lore raw

PATCH 2/4 xilinx: zynq: Add support for saving env based on bootmode

In reply to Michal Simek

From: Ashok Reddy Soma <[email protected]>

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).

---

 board/xilinx/zynq/board.c          | 32 ++++++++++++++++++++++++++++++
 configs/xilinx_zynq_virt_defconfig |  5 ++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
board/xilinx/zynq/board.c +32 -0
index 7533dddb9b65..e2e9b3f0f78c 100644
@@ -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;
+	}
+}
configs/xilinx_zynq_virt_defconfig +4 -1
index 2fe53182caa8..bdd6be2b9079 100644
@@ -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
Signature · 1 line
2.31.0
#3 lore raw

PATCH 3/4 xilinx: versal: Add support for saving env based on bootmode

In reply to Michal Simek

From: Ashok Reddy Soma <[email protected]>

Enable saving variables to MMC(FAT) and SPI based on primary bootmode. If bootmode is JTAG, dont save env anywhere(NOWHERE).

Enable ENV_FAT_DEVICE_AND_PART="0:auto" for Versal platforms as well.

---

 board/xilinx/versal/board.c          | 30 ++++++++++++++++++++++++++++
 configs/xilinx_versal_virt_defconfig |  3 +++
 env/Kconfig                          |  2 +-
 3 files changed, 34 insertions(+), 1 deletion(-)
board/xilinx/versal/board.c +30 -0
index c644fe8dc068..042f3ec4f3a0 100644
@@ -9,6 +9,7 @@
 #include <env.h>
 #include <fdtdec.h>
 #include <init.h>
+#include <env_internal.h>
 #include <log.h>
 #include <malloc.h>
 #include <time.h>
@@ -245,3 +246,32 @@ int dram_init(void)
 void reset_cpu(ulong addr)
 {
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+	u32 bootmode = versal_get_bootmode();
+
+	if (prio)
+		return ENVL_UNKNOWN;
+
+	switch (bootmode) {
+	case EMMC_MODE:
+	case SD_MODE:
+	case SD1_LSHFT_MODE:
+	case SD_MODE1:
+		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 OSPI_MODE:
+	case QSPI_MODE_24BIT:
+	case QSPI_MODE_32BIT:
+		if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
+			return ENVL_SPI_FLASH;
+		return ENVL_UNKNOWN;
+	case JTAG_MODE:
+	default:
+		return ENVL_NOWHERE;
+	}
+}
configs/xilinx_versal_virt_defconfig +3 -0
index 2d639a1026a8..fe108d3475c3 100644
@@ -39,6 +39,9 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_UBI=y
 CONFIG_OF_BOARD=y
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_FAT=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y
env/Kconfig +1 -1
index bc4f7d8f4ee4..0cee6a8e310f 100644
@@ -431,7 +431,7 @@ config ENV_FAT_DEVICE_AND_PART
 	string "Device and partition for where to store the environemt in FAT"
 	depends on ENV_IS_IN_FAT
 	default "0:1" if TI_COMMON_CMD_OPTIONS
-	default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP
+	default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL
 	default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
 	default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
 	default "0" if ARCH_AT91
Signature · 1 line
2.31.0
#4 lore raw

PATCH 4/4 xilinx: Enable redundant variable handling

In reply to Michal Simek

Enable this feature by default to be able to work with env import/export commands which are done in this slightly changed variable format (There is addtional flag fields in variable file which is changing CRC calculation).

---

 configs/microblaze-generic_defconfig | 1 +
 configs/xilinx_versal_virt_defconfig | 1 +
 configs/xilinx_zynq_virt_defconfig   | 1 +
 configs/xilinx_zynqmp_virt_defconfig | 1 +
 4 files changed, 4 insertions(+)
configs/microblaze-generic_defconfig +1 -0
index 761cc65cbfab..245763b40877 100644
@@ -40,6 +40,7 @@ CONFIG_CMD_CACHE=y
 CONFIG_CMD_JFFS2=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_EMBED=y
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y
 CONFIG_SPL_DM=y
configs/xilinx_versal_virt_defconfig +1 -0
index fe108d3475c3..da3d2c2a936f 100644
@@ -42,6 +42,7 @@ CONFIG_OF_BOARD=y
 CONFIG_ENV_IS_NOWHERE=y
 CONFIG_ENV_IS_IN_FAT=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y
configs/xilinx_zynq_virt_defconfig +1 -0
index bdd6be2b9079..3892a71eac8b 100644
@@ -60,6 +60,7 @@ 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_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y
configs/xilinx_zynqmp_virt_defconfig +1 -0
index ac45df813268..6eb566e30df0 100644
@@ -74,6 +74,7 @@ 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_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_NETCONSOLE=y
Signature · 1 line
2.31.0
Applied
#5 lore raw

cover xilinx: Enable redundant variables for all Xilinx SoCs

In reply to Michal Simek

?t 30. 3. 2021 v 12:10 odes?latel Michal Simek <[email protected]> napsal:

Quoted 32 lines

Hi,

based on discussion with Tom here
https://lists.denx.de/pipermail/u-boot/2021-January/437234.html
I decided to enable redundant variables on all Xilinx SoCs. Users who don't want to use it can disable this option. But having extended structure for variable storing is based on that thread above the right way to go. It means switch to the right approach is better to do earlier rather than later.

Thanks,
Michal

Ashok Reddy Soma (2):
xilinx: zynq: Add support for saving env based on bootmode
xilinx: versal: Add support for saving env based on bootmode

Michal Simek (2):
env: Setup default value for ENV_OFFSET_REDUND
xilinx: Enable redundant variable handling

 board/xilinx/versal/board.c          | 30 ++++++++++++++++++++++++++
 board/xilinx/zynq/board.c            | 32 ++++++++++++++++++++++++++++
 configs/microblaze-generic_defconfig |  1 +
 configs/xilinx_versal_virt_defconfig |  4 ++++
 configs/xilinx_zynq_virt_defconfig   |  6 +++++-
 configs/xilinx_zynqmp_virt_defconfig |  1 +
 env/Kconfig                          |  3 ++-
 7 files changed, 75 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.31.0

Applied.
M

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs