[U-Boot] [PATCH 03/14] armV7R: K3: j721e: Allow using SPL BSS pre-relocation

Lokesh Vutla lokeshvutla at ti.com
Wed May 22 18:36:56 UTC 2019


From: Andreas Dannenberg <dannenberg at ti.com>

In order to be able to use more advanced driver functionality which often
relies on having BSS initialized during early boot prior to relocation
several things need to be in place:

1) Memory needs to be available for BSS to use. For this, we locate BSS
   at the top of the MCU SRAM area, with the stack starting right below
   it,
2) We need to zero-initialize BSS ourselves which will we do during
   board_init_f(),
3) We would also like to skip the implicit zero-initialization as part of
   SPL relocation, so that already initialized variables will carry over
   post-relocation. We will do this with a separate commit by turning on
   the respective CONFIG option.

In this commit we only zero-initialize BSS. Assignment of SP will be
done in the environment setup.

Signed-off-by: Andreas Dannenberg <dannenberg at ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla at ti.com>
---
 arch/arm/mach-k3/j721e_init.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index d798aed481..6da4cf6d22 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -24,6 +24,13 @@ void board_init_f(ulong dummy)
 
 #ifdef CONFIG_CPU_V7R
 	setup_k3_mpu_regions();
+
+	/*
+	 * When running SPL on R5 we are using SRAM for BSS to have global
+	 * data etc. working prior to relocation. Since this means we need
+	 * to self-manage BSS, clear that section now.
+	 */
+	memset(__bss_start, 0, __bss_end - __bss_start);
 #endif
 
 	/* Init DM early */
-- 
2.17.1



More information about the U-Boot mailing list