The current code uses the CONFIG_SYS_MONITOR_BASE
constant to calculate the size of the reserved
memory for U-Boot. The constant is also used
explicitly to calcualte the value of the
monitor_flash_len variable.

However this leads to miscalculated values if
CONFIG_SYS_TEXT_BASE != CONFIG_SYS_MONITOR_BASE.

Use the linked address of the _start symbol in
the calculations to fix the miscalculated values.

Also print the calculated monitor length if
debug is enabled.

Signed-off-by: Gabor Juhos <[email protected]>
Cc: Daniel Schwierzeck <[email protected]>
---
 arch/mips/include/asm/u-boot-mips.h |    1 +
 arch/mips/lib/board.c               |    5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/u-boot-mips.h 
b/arch/mips/include/asm/u-boot-mips.h
index 6f26dfa..4421696 100644
--- a/arch/mips/include/asm/u-boot-mips.h
+++ b/arch/mips/include/asm/u-boot-mips.h
@@ -5,6 +5,7 @@
  * Copyright (C) 2003 Wolfgang Denk, DENX Software Engineering, [email protected]
  */
 
+extern ulong _start;
 extern ulong uboot_end_data;
 extern ulong uboot_end;
 
diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c
index d79e183..5c4d0eb 100644
--- a/arch/mips/lib/board.c
+++ b/arch/mips/lib/board.c
@@ -143,7 +143,7 @@ void board_init_f(ulong bootflag)
        gd_t gd_data, *id;
        bd_t *bd;
        init_fnc_t **init_fnc_ptr;
-       ulong addr, addr_sp, len = (ulong)&uboot_end - CONFIG_SYS_MONITOR_BASE;
+       ulong addr, addr_sp, len = (ulong)&uboot_end - (ulong)&_start;
        ulong *s;
 
        /* Pointer is writable since we allocated a register for it.
@@ -261,7 +261,8 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
        gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE;
 
-       monitor_flash_len = (ulong)&uboot_end_data - dest_addr;
+       monitor_flash_len = (ulong)&uboot_end_data - (ulong)&_start;
+       debug("Monitor flash len: %08lX\n", monitor_flash_len);
 
        serial_initialize();
 
-- 
1.7.10

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to