From patchwork Wed Dec 1 08:10:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 73760 X-Patchwork-Delegate: albert.aribaud@free.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7FE1CB7080 for ; Wed, 1 Dec 2010 19:11:23 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1CF6F280F9; Wed, 1 Dec 2010 09:11:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J6OQC1n3vfol; Wed, 1 Dec 2010 09:11:20 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37DF0280D6; Wed, 1 Dec 2010 09:11:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 17174280D6 for ; Wed, 1 Dec 2010 09:11:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bjsbi8vZO1y7 for ; Wed, 1 Dec 2010 09:11:17 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-bw0-f66.google.com (mail-bw0-f66.google.com [209.85.214.66]) by theia.denx.de (Postfix) with ESMTP id 06340280D4 for ; Wed, 1 Dec 2010 09:11:15 +0100 (CET) Received: by bwz7 with SMTP id 7so3508946bwz.9 for ; Wed, 01 Dec 2010 00:11:15 -0800 (PST) Received: by 10.204.68.199 with SMTP id w7mr63752bki.17.1291191075246; Wed, 01 Dec 2010 00:11:15 -0800 (PST) Received: from andreas-mbp.erlangen.biessmann.tld (dslb-092-075-127-153.pools.arcor-ip.net [92.75.127.153]) by mx.google.com with ESMTPS id b17sm3207151bku.8.2010.12.01.00.11.13 (version=SSLv3 cipher=RC4-MD5); Wed, 01 Dec 2010 00:11:14 -0800 (PST) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: u-boot@lists.denx.de Date: Wed, 1 Dec 2010 09:10:50 +0100 Message-Id: <1291191050-46774-1-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 Subject: [U-Boot] [TEST] arm:board_init_f(): mirror BSS and check after each init_fnc() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 : 20100478: e59f3064 ldr r3, [pc, #100] ; 201004e4 --->8--- Signed-off-by: Andreas Bießmann --- 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 !!