Skip to contentSkip to conversation

common: Let board decide if env should be loaded

PATCH New Marek Vasut 1 participant 4 messages Apr 16, 2018 – Apr 17, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 common: Let board decide if env should be loaded

Add board_should_load_env() hook which lets board code decide whether environment should be loaded. This is useful when restoring the board over ie. JTAG where the environment may interfere and where it may be desired to ignore the environment present on the board.

The return value of board_should_load_env() is:
0 - do not load environment
1 - load environment
-EAGAIN - default behavior

Cc Nobuhiro Iwamatsu <[email protected]>
Cc Tom Rini <[email protected]>
---
 common/board_r.c | 9 +++++++++
 1 file changed, 9 insertions(+)
common/board_r.c +9 -0
index 0f4479a58b..8b68140b57 100644
@@ -438,8 +438,17 @@ static int initr_mmc(void)
  *
  * @return 0 if environment should not be loaded, !=0 if it is ok to load
  */
+__weak int board_should_load_env(void)
+{
+	return -EAGAIN;
+}
+
 static int should_load_env(void)
 {
+	int ret = board_should_load_env();
+
+	if (ret >= 0)
+		return ret;
 #ifdef CONFIG_OF_CONTROL
 	return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
 #elif defined CONFIG_DELAY_ENVIRONMENT
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/3 common: Let board decide if env should be loaded

Quoted 5 lines · Marek Vasut

Add board_should_load_env() hook which lets board code decide whether environment should be loaded. This is useful when restoring the board over ie. JTAG where the environment may interfere and where it may be desired to ignore the environment present on the board.

Quoted 8 lines

The return value of board_should_load_env() is:
0 - do not load environment
1 - load environment
-EAGAIN - default behavior

Cc Nobuhiro Iwamatsu <[email protected]>
Cc Tom Rini <[email protected]>

Please ignore, there's a better way to do this.

Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 2/3 ARM: rmobile: Ignore U-Boot env when started via JTAG on Porter

In reply to Marek Vasut

When U-Boot is started via JTAG, ignore the installed environment as it may interfere with the recovery of the board.

Cc Nobuhiro Iwamatsu <[email protected]>
Cc Tom Rini <[email protected]>
---
 board/renesas/porter/porter.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
board/renesas/porter/porter.c +10 -0
index acd4f91d59..052e1abe08 100644
@@ -136,3 +136,13 @@ void reset_cpu(ulong addr)
 	if (ret)
 		hang();
 }
+
+int board_should_load_env(void)
+{
+	const u32 load_magic = 0xb33fc0de;
+
+	if (readl(CONFIG_SPL_TEXT_BASE + 0x24) == load_magic)
+		return 0;
+
+	return -EAGAIN;
+}
Signature · 1 line
2.16.2
#3 lore raw

PATCH 3/3 ARM: rmobile: Ignore U-Boot env when started via JTAG on Stout

In reply to Marek Vasut

When U-Boot is started via JTAG, ignore the installed environment as it may interfere with the recovery of the board.

Cc Nobuhiro Iwamatsu <[email protected]>
Cc Tom Rini <[email protected]>
---
 board/renesas/stout/stout.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
board/renesas/stout/stout.c +10 -0
index d7e81292a0..16f4837502 100644
@@ -128,3 +128,13 @@ int board_phy_config(struct phy_device *phydev)
 const struct rmobile_sysinfo sysinfo = {
 	CONFIG_ARCH_RMOBILE_BOARD_STRING
 };
+
+int board_should_load_env(void)
+{
+	const u32 load_magic = 0xb33fc0de;
+
+	if (readl(CONFIG_SPL_TEXT_BASE + 0x24) == load_magic)
+		return 0;
+
+	return -EAGAIN;
+}
Signature · 1 line
2.16.2