Skip to contentSkip to conversation

MIPS: board.c: fix monitor length calculations

PATCH New Gabor Juhos 1 participant 2 messages Jan 16, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: board.c: fix monitor length calculations

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.

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(-)
arch/mips/include/asm/u-boot-mips.h +1 -0
index 6f26dfa..4421696 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2003 Wolfgang Denk, DENX Software Engineering, wd at denx.de
  */
 
+extern ulong _start;
 extern ulong uboot_end_data;
 extern ulong uboot_end;
 
arch/mips/lib/board.c +3 -2
index d79e183..5c4d0eb 100644
@@ -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();
 
Signature · 1 line
1.7.10
#1 lore raw

PATCH 1/1 MIPS: board.c: fix monitor length calculations

2013.01.16. 15:39 keltez?ssel, Gabor Juhos ?rta:

Quoted 9 lines

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.

Quoted 8 lines

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.

Cc Daniel Schwierzeck <[email protected]>

Forget this. It still does not work as expected.

-Gabor