This is only a patch to test if BSS was accessed in any function in init
function array!

DO NOT APPLY TO MAINLINE!

To run the test adopt the bss_mirror value to point somwhere in RAM with
sufficient space!

A step by step guide is like this:
 * apply the patch
 * adopt bss_mirror in arch/arm/lib/board.c:board_init_f()
 * build and run like always
 * search for something like: 'BSS got corrupted after init_fnc @ 0x20100478'
   after banner
 * use objdump to search the symbol
  ---8<--- 
  arm-unknown-linux-gnueabi-objdump -S ../build_uboot-at91rm9200ek/u-boot | 
grep 20100478
   20100478 <timer_init>:
   20100478:    e59f3064        ldr     r3, [pc, #100]  ; 201004e4 
<timer_init+0x6c>
  --->8---

Signed-off-by: Andreas Bießmann <andreas.de...@googlemail.com>
---
 arch/arm/lib/board.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 1fd5f83..890e6f1 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -274,6 +274,10 @@ void board_init_f (ulong bootflag)
        init_fnc_t **init_fnc_ptr;
        gd_t *id;
        ulong addr, addr_sp;
+       uint32_t *bss_mirror;
+       uint32_t *bss_start;
+       size_t bss_length;
+       init_fnc_t *break_bss = NULL;
 
        /* Pointer is writable since we allocated a register for it */
        gd = (gd_t *) (CONFIG_SYS_INIT_SP_ADDR);
@@ -284,12 +288,26 @@ void board_init_f (ulong bootflag)
 
        gd->mon_len = _bss_end_ofs;
 
+       /* take a location in SDRAM which might be free */
+       bss_mirror = (uint32_t*)(CONFIG_SYS_SDRAM_BASE + 0x600000);
+       bss_start = (uint32_t*)(_bss_start_ofs + _TEXT_BASE);
+       bss_length = _bss_end_ofs - _bss_start_ofs;
+       memcpy((void*)bss_mirror, (void*)bss_start, bss_length);
+
        for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
                if ((*init_fnc_ptr)() != 0) {
                        hang ();
                }
+               if (!break_bss)
+                       if (memcmp((void*)bss_mirror, bss_start, bss_length) != 
0)
+                               break_bss = *init_fnc_ptr;
        }
 
+       if (break_bss)
+               printf("BSS got corrupted after init_fnc @ 0x%p\n", *break_bss);
+       else
+               printf("BSS is still OK after init_fnc\n");
+
        debug ("monitor len: %08lX\n", gd->mon_len);
        /*
         * Ram is setup, size stored in gd !!
-- 
1.7.3.2

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to