Skip to contentSkip to conversation

env: sf: Add support for env init for QSPI-NOR

PATCH New Ashish Kumar 2 participants 8 messages Dec 14, 2017 – Jan 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 env: sf: Add support for env init for QSPI-NOR

ENV variables can now be used before relocation.

---
v2:
replace & with && in #if

Tested on ls1088ardb.
Tested on ls1012hexa after defining CONFIG_ENV_ADDR

 env/sf.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
env/sf.c +21 -0
index e51b1ae..a2e4c93 100644
@@ -34,6 +34,7 @@
 
 #ifndef CONFIG_SPL_BUILD
 #define CMD_SAVEENV
+#define INITENV
 #endif
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
@@ -348,6 +349,23 @@ out:
 }
 #endif
 
+#if defined(INITENV) && defined(CONFIG_ENV_ADDR)
+static int env_sf_init(void)
+{
+	env_t *env_ptr = (env_t *)(CONFIG_ENV_ADDR);
+
+	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
+		gd->env_addr	= (ulong)&(env_ptr->data);
+		gd->env_valid	= 1;
+	} else {
+		gd->env_addr = (ulong)&default_environment[0];
+		gd->env_valid = 1;
+	}
+
+	return 0;
+}
+#endif
+
 U_BOOT_ENV_LOCATION(sf) = {
 	.location	= ENVL_SPI_FLASH,
 	ENV_NAME("SPI Flash")
@@ -355,4 +373,7 @@ U_BOOT_ENV_LOCATION(sf) = {
 #ifdef CMD_SAVEENV
 	.save		= env_save_ptr(env_sf_save),
 #endif
+#if defined(INITENV) && defined(CONFIG_ENV_ADDR)
+	.init		= env_sf_init,
+#endif
 };
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 2/2 armv8: ls1088ardb: Add environment variable address location for QSPI-NOR

---
 include/configs/ls1088a_common.h | 6 ++++++
 include/configs/ls1088aqds.h     | 1 -
 include/configs/ls1088ardb.h     | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)
include/configs/ls1088a_common.h +6 -0
index b99257e..c96d48d 100644
@@ -32,6 +32,12 @@
 
 #define CONFIG_SUPPORT_RAW_INITRD
 
+#ifdef CONFIG_QSPI_BOOT
+#define CONFIG_SYS_FSL_QSPI_BASE	0x20000000
+#define CONFIG_ENV_OFFSET		0x300000        /* 3MB */
+#define CONFIG_ENV_ADDR			(CONFIG_SYS_FSL_QSPI_BASE + \
+						CONFIG_ENV_OFFSET)
+#endif
 
 #define CONFIG_SKIP_LOWLEVEL_INIT
 
include/configs/ls1088aqds.h +0 -1
index e97091d..6b94667 100644
@@ -21,7 +21,6 @@ unsigned long get_board_ddr_clk(void);
 
 #if defined(CONFIG_QSPI_BOOT)
 #define CONFIG_ENV_SIZE			0x2000          /* 8KB */
-#define CONFIG_ENV_OFFSET		0x300000        /* 3MB */
 #define CONFIG_ENV_SECT_SIZE		0x40000
 #elif defined(CONFIG_SD_BOOT)
 #define CONFIG_ENV_OFFSET		(3 * 1024 * 1024)
include/configs/ls1088ardb.h +1 -1
index 1da8153..bffaa76 100644
@@ -12,8 +12,8 @@
 #define CONFIG_DISPLAY_BOARDINFO_LATE
 
 #if defined(CONFIG_QSPI_BOOT)
+#define CONFIG_SYS_FSL_QSPI_BASE	0x20000000
 #define CONFIG_ENV_SIZE			0x2000          /* 8KB */
-#define CONFIG_ENV_OFFSET		0x300000        /* 3MB */
 #define CONFIG_ENV_SECT_SIZE		0x40000
 #elif defined(CONFIG_SD_BOOT)
 #define CONFIG_ENV_OFFSET		(3 * 1024 * 1024)
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 1/2 env: sf: Add support for env init for QSPI-NOR

In reply to Ashish Kumar
Quoted 51 lines · Ashish Kumar

ENV variables can now be used before relocation.

---
v2:
replace & with && in #if

Tested on ls1088ardb.
Tested on ls1012hexa after defining CONFIG_ENV_ADDR

 env/sf.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
env/sf.c +18 -0
index e51b1ae..a2e4c93 100644
@@ -34,6 +34,7 @@
 
 #ifndef CONFIG_SPL_BUILD
 #define CMD_SAVEENV
+#define INITENV
 #endif
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
@@ -348,6 +349,23 @@ out:
 }
 #endif
 
+#if defined(INITENV) && defined(CONFIG_ENV_ADDR)
+static int env_sf_init(void)
+{
+	env_t *env_ptr = (env_t *)(CONFIG_ENV_ADDR);
+
+	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
+		gd->env_addr	= (ulong)&(env_ptr->data);
+		gd->env_valid	= 1;
+	} else {
+		gd->env_addr = (ulong)&default_environment[0];
+		gd->env_valid = 1;
+	}
+
+	return 0;
+}
+#endif
+
 U_BOOT_ENV_LOCATION(sf) = {
 	.location	= ENVL_SPI_FLASH,
 	ENV_NAME("SPI Flash")

env/sf.c U_BOOT_ENV_LOCATION(sf) = { · line 379

Quoted 7 lines
env/sf.c +3 -0
@@ -355,4 +373,7 @@ U_BOOT_ENV_LOCATION(sf) = {
 #ifdef CMD_SAVEENV
 	.save		= env_save_ptr(env_sf_save),
 #endif
+#if defined(INITENV) && defined(CONFIG_ENV_ADDR)
+	.init		= env_sf_init,
+#endif
 };

Please run get_maintainer.pl to get the CC list if you don't use patman.

I wonder how SPI worked before. Did it work, Simon and Jagan?

York

#6 lore raw

PATCH v2 1/2 env: sf: Add support for env init for QSPI-NOR

Quoted 70 lines

-----Original Message-----
From: York Sun
Sent: Monday, January 08, 2018 11:53 PM
To: Ashish Kumar <[email protected]>; u-boot at lists.denx.de; Simon Glass <[email protected]>; Jagan Teki <[email protected]>
Subject: Re: [PATCH v2 1/2] env: sf: Add support for env init for QSPI-NOR

env/sf.c U_BOOT_ENV_LOCATION(sf) = { #ifdef

Quoted 49 lines · Ashish Kumar

ENV variables can now be used before relocation.

---
v2:
replace & with && in #if

Tested on ls1088ardb.
Tested on ls1012hexa after defining CONFIG_ENV_ADDR

 env/sf.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
env/sf.c +17 -0
index e51b1ae..a2e4c93 100644
@@ -34,6 +34,7 @@
 
 #ifndef CONFIG_SPL_BUILD
 #define CMD_SAVEENV
+#define INITENV
 #endif
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
@@ -348,6 +349,23 @@ out:
 }
 #endif
 
+#if defined(INITENV) && defined(CONFIG_ENV_ADDR) static int
+env_sf_init(void) {
+	env_t *env_ptr = (env_t *)(CONFIG_ENV_ADDR);
+
+	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
+		gd->env_addr	= (ulong)&(env_ptr->data);
+		gd->env_valid	= 1;
+	} else {
+		gd->env_addr = (ulong)&default_environment[0];
+		gd->env_valid = 1;
+	}
+
+	return 0;
+}
+#endif
+
 U_BOOT_ENV_LOCATION(sf) = {
 	.location	= ENVL_SPI_FLASH,
 	ENV_NAME("SPI Flash")
@@ -355,4 +373,7 @@ U_BOOT_ENV_LOCATION(sf) = {  #ifdef

CMD_SAVEENV

env/sf.c U_BOOT_ENV_LOCATION(sf) = {

Quoted 7 lines
env/sf.c +3 -0
 	.save		= env_save_ptr(env_sf_save),
 #endif
+#if defined(INITENV) && defined(CONFIG_ENV_ADDR)
+	.init		= env_sf_init,
+#endif
 };
 

Please run get_maintainer.pl to get the CC list if you don't use patman.

Quoted 1 line

I wonder how SPI worked before. Did it work, Simon and Jagan?

SPI is working, this patch adds support to init environment such that it can be used before u-boot relocation similar to that of IFC-NOR.

Regards
Ashish

Quoted 2 lines

York

#2 lore raw

PATCH v2 2/2 armv8: ls1088ardb: Add environment variable address location for QSPI-NOR

In reply to Ashish Kumar
Quoted 41 lines · Ashish Kumar
---
 include/configs/ls1088a_common.h | 6 ++++++
 include/configs/ls1088aqds.h     | 1 -
 include/configs/ls1088ardb.h     | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)
include/configs/ls1088a_common.h +6 -0
index b99257e..c96d48d 100644
@@ -32,6 +32,12 @@
 
 #define CONFIG_SUPPORT_RAW_INITRD
 
+#ifdef CONFIG_QSPI_BOOT
+#define CONFIG_SYS_FSL_QSPI_BASE	0x20000000
+#define CONFIG_ENV_OFFSET		0x300000        /* 3MB */
+#define CONFIG_ENV_ADDR			(CONFIG_SYS_FSL_QSPI_BASE + \
+						CONFIG_ENV_OFFSET)
+#endif
 
 #define CONFIG_SKIP_LOWLEVEL_INIT
 
include/configs/ls1088aqds.h +0 -1
index e97091d..6b94667 100644
@@ -21,7 +21,6 @@ unsigned long get_board_ddr_clk(void);
 
 #if defined(CONFIG_QSPI_BOOT)
 #define CONFIG_ENV_SIZE			0x2000          /* 8KB */
-#define CONFIG_ENV_OFFSET		0x300000        /* 3MB */
 #define CONFIG_ENV_SECT_SIZE		0x40000
 #elif defined(CONFIG_SD_BOOT)
 #define CONFIG_ENV_OFFSET		(3 * 1024 * 1024)
include/configs/ls1088ardb.h +0 -0
index 1da8153..bffaa76 100644

include/configs/ls1088ardb.h line 15

Quoted 4 lines
include/configs/ls1088ardb.h +1 -0
@@ -12,8 +12,8 @@
 #define CONFIG_DISPLAY_BOARDINFO_LATE
 
 #if defined(CONFIG_QSPI_BOOT)
+#define CONFIG_SYS_FSL_QSPI_BASE	0x20000000

Looks like you are redefining this macro. Will remove when I merge it.

York

#3 lore raw

PATCH v2 2/2 armv8: ls1088ardb: Add environment variable address location for QSPI-NOR

Quoted 55 lines

-----Original Message-----
From: York Sun
Sent: Monday, January 15, 2018 11:36 PM
To: Ashish Kumar <[email protected]>; u-boot at lists.denx.de
Subject: Re: [PATCH v2 2/2] armv8: ls1088ardb: Add environment variable address location for QSPI-NOR

Quoted 13 lines · Ashish Kumar
---
 include/configs/ls1088a_common.h | 6 ++++++
 include/configs/ls1088aqds.h     | 1 -
 include/configs/ls1088ardb.h     | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)
include/configs/ls1088a_common.h +0 -0
index b99257e..c96d48d 100644

include/configs/ls1088a_common.h line 38

Quoted 7 lines
include/configs/ls1088a_common.h +4 -0
@@ -32,6 +32,12 @@
 
 #define CONFIG_SUPPORT_RAW_INITRD
 
+#ifdef CONFIG_QSPI_BOOT
+#define CONFIG_SYS_FSL_QSPI_BASE	0x20000000
+#define CONFIG_ENV_OFFSET		0x300000        /* 3MB */
+#define CONFIG_ENV_ADDR			(CONFIG_SYS_FSL_QSPI_BASE

+ \

Quoted 24 lines
include/configs/ls1088a_common.h +2 -0
+						CONFIG_ENV_OFFSET)
+#endif
 
 #define CONFIG_SKIP_LOWLEVEL_INIT
 
(quoted diff) +0 -0

b/include/configs/ls1088aqds.h index e97091d..6b94667 100644

include/configs/ls1088aqds.h +0 -1
@@ -21,7 +21,6 @@ unsigned long get_board_ddr_clk(void);
 
 #if defined(CONFIG_QSPI_BOOT)
 #define CONFIG_ENV_SIZE			0x2000          /* 8KB */
-#define CONFIG_ENV_OFFSET		0x300000        /* 3MB */
 #define CONFIG_ENV_SECT_SIZE		0x40000
 #elif defined(CONFIG_SD_BOOT)
 #define CONFIG_ENV_OFFSET		(3 * 1024 * 1024)
(quoted diff) +0 -0

b/include/configs/ls1088ardb.h index 1da8153..bffaa76 100644

include/configs/ls1088ardb.h +0 -0
@@ -12,8 +12,8 @@
 #define CONFIG_DISPLAY_BOARDINFO_LATE
 
Quoted 4 lines

include/configs/ls1088ardb.h line 15

Quoted 2 lines
include/configs/ls1088ardb.h +1 -0
 #if defined(CONFIG_QSPI_BOOT)
+#define CONFIG_SYS_FSL_QSPI_BASE	0x20000000

Looks like you are redefining this macro. Will remove when I merge it.

Yes. Thanks York.

Quoted 2 lines

York

Applied
#7 lore raw

PATCH v2 1/2 env: sf: Add support for env init for QSPI-NOR

In reply to Ashish Kumar
Quoted 10 lines · Ashish Kumar

ENV variables can now be used before relocation.

---
v2:
replace & with && in #if

Tested on ls1088ardb.
Tested on ls1012hexa after defining CONFIG_ENV_ADDR

Applied to fsl-qoriq master. Thanks.

York