All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] rockchip: misc: Only assign serial# variable if unset
@ 2019-12-03 15:46 Paul Kocialkowski
  2019-12-03 15:46 ` [PATCH 2/2] rockchip: misc: Don't fail if ethaddr is already set Paul Kocialkowski
  2019-12-03 19:50 ` [PATCH 1/2] rockchip: misc: Only assign serial# variable if unset Heiko Stuebner
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2019-12-03 15:46 UTC (permalink / raw)
  To: u-boot

The serial# environment variable is a read-only special variable, that
can only be set once. As a result, if the environment was saved to a
persistent storage location, attempting to set it again in
rockchip_cpuid_set will fail and halt the boot with the following error:

Solve this by checking whether the variable is already set before.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 arch/arm/mach-rockchip/misc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
index bed4317f7ece..a0c6a1c0b266 100644
--- a/arch/arm/mach-rockchip/misc.c
+++ b/arch/arm/mach-rockchip/misc.c
@@ -108,12 +108,16 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length)
 		high[i] = cpuid[i << 1];
 	}
 
-	serialno = crc32_no_comp(0, low, 8);
-	serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
-	snprintf(serialno_str, sizeof(serialno_str), "%016llx", serialno);
-
 	env_set("cpuid#", cpuid_str);
-	env_set("serial#", serialno_str);
+
+	if (!env_get("serial#")) {
+		serialno = crc32_no_comp(0, low, 8);
+		serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
+		snprintf(serialno_str, sizeof(serialno_str), "%016llx",
+			 serialno);
+
+		env_set("serial#", serialno_str);
+	}
 
 	return 0;
 }
-- 
2.24.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-04 11:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 15:46 [PATCH 1/2] rockchip: misc: Only assign serial# variable if unset Paul Kocialkowski
2019-12-03 15:46 ` [PATCH 2/2] rockchip: misc: Don't fail if ethaddr is already set Paul Kocialkowski
2019-12-03 19:47   ` Heiko Stuebner
2019-12-03 19:50 ` [PATCH 1/2] rockchip: misc: Only assign serial# variable if unset Heiko Stuebner
2019-12-04 11:09   ` Paul Kocialkowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.