
The common/spl changes gd to gdata in board_init_f. I fail to see why. The only reason I can think of to use the gdata is the case where is won't fit into the region where the stack lives.
Move the init to crt0.S and make it a CONFIG. --- arch/arm/lib/crt0.S | 5 +++++ arch/arm/lib/spl.c | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S index 98d7881..b8fa10e 100644 --- a/arch/arm/lib/crt0.S +++ b/arch/arm/lib/crt0.S @@ -67,9 +67,14 @@ ENTRY(_main) ldr sp, =(CONFIG_SYS_INIT_SP_ADDR) #endif bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ + +#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GD_GLOBAL) + ldr r8, =gdata /* SPL assigns GD directly to &gdata */ +#else sub sp, #GD_SIZE /* allocate one GD above SP */ bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ mov r8, sp /* GD is above SP */ +#endif
bl s_init
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index 583bdb3..52dba2f 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/spl.c @@ -15,7 +15,9 @@
/* Pointer to as well as the global data structure for SPL */ DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_SPL_GD_GLOBAL gd_t gdata __attribute__ ((section(".data"))); +#endif
/* * In the context of SPL, board_init_f must ensure that any clocks/etc for @@ -31,9 +33,6 @@ void __weak board_init_f(ulong dummy) /* Clear the BSS. */ memset(__bss_start, 0, __bss_end - __bss_start);
- /* Set global data pointer. */ - gd = &gdata; - board_init_r(NULL, 0); }