public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm: fix bug on relocation address
@ 2013-01-31 14:29 Luca Ellero
  2013-01-31 19:08 ` Jeroen Hofstee
  2013-02-01  8:17 ` Heiko Schocher
  0 siblings, 2 replies; 7+ messages in thread
From: Luca Ellero @ 2013-01-31 14:29 UTC (permalink / raw)
  To: u-boot

If (N. SDRAM banks > 1) and they are not contiguous, don't relocate
u-boot at (CONFIG_SYS_SDRAM_BASE + gd->ram_size), which is a bug.
Instead use the end of 2nd bank (even if there are more than 2 banks)

Signed-off-by: Luca Ellero <lroluk@gmail.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Heiko Schocher <hs@denx.de>
---

On ARM architectures there is a bug getting top of SDRAM (where u-boot 
will be relocated). Top of SDRAM will always be:

CONFIG_SYS_SDRAM_BASE + gd->ram_size

anyway this can be wrong since SDRAM can be composed by more that one 
bank in not-contiguous address space.
(CONFIG_SYS_SDRAM_BASE + gd->ram_size) can land to not existent SDRAM 
addresses and can be very dangerous since it can potentially corrupt 
real SDRAM (in most cases SDRAM is aliased so writing to some 
not-existent address can write to real address).
Some arch use more than 2 banks but implementing all macros checks to 
PHYS_SDRAM_* leads to very ugly code, so I think using 2nd bank is good 
and does not generates bloated code


 arch/arm/lib/board.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 9f861cc..98634ab 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -333,7 +333,19 @@ void board_init_f(ulong bootflag)
 	gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
 #endif
 
+#if defined(PHYS_SDRAM_2) && defined(PHYS_SDRAM_2_SIZE)
+	if (CONFIG_NR_DRAM_BANKS > 1 &&
+		(PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE) != PHYS_SDRAM_2)
+		addr =  PHYS_SDRAM_2 + PHYS_SDRAM_2_SIZE;
+	else
+		addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
+#else
 	addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
+#endif
+
+
+
+
 
 #ifdef CONFIG_LOGBUFFER
 #ifndef CONFIG_ALT_LB_ADDR
-- 
1.7.0.4

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

end of thread, other threads:[~2013-02-07  9:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-31 14:29 [U-Boot] [PATCH] arm: fix bug on relocation address Luca Ellero
2013-01-31 19:08 ` Jeroen Hofstee
2013-02-01  8:50   ` Luca Ellero
2013-02-01 10:07     ` Heiko Schocher
2013-02-01  9:49       ` Luca Ellero
2013-02-07  9:07         ` Luca Ellero
2013-02-01  8:17 ` Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox