From patchwork Tue Jul 30 17:57:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 2835819 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9A84FC031A for ; Tue, 30 Jul 2013 17:58:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8578920356 for ; Tue, 30 Jul 2013 17:58:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DA0A20343 for ; Tue, 30 Jul 2013 17:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756339Ab3G3R5u (ORCPT ); Tue, 30 Jul 2013 13:57:50 -0400 Received: from mail-ea0-f180.google.com ([209.85.215.180]:47911 "EHLO mail-ea0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756391Ab3G3R5r (ORCPT ); Tue, 30 Jul 2013 13:57:47 -0400 Received: by mail-ea0-f180.google.com with SMTP id h10so1242755eaj.25 for ; Tue, 30 Jul 2013 10:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=37KDWzJkIr5jN68l2Zjzawk+LNw8N4yFQeH35uezzDA=; b=Nb1IQuX//IQqCnwC2HnGzJ/HyBkliVEe5lx6ZBFYO9TGPkmZkm8K3RH7lariKNrSAa 3PhY5chjTx39a1VttrBSAL6Ll9wvepHnL9yjnH69s/NLrjLCV/DDuaHdXOAR279Y2jys VeMPfRNEoiUALRZQBUkDjLuccW4sxSA0OKAMunhwE+HOFCrrexitMF/WD3OvZoG9umO7 wutIPeC4FlxEmWy/E6WmcceY+Zvc34Uvdo74g+XOHUPNf9JSgqoxLjnTOveXCIhpmW2D JoK9xiH16wJRqDoj/x0QRWt7Dpql7zeN4aO6Nv9hinKGt9LzCa9Hzp+vGSlaXhwGAjYa OopA== X-Received: by 10.15.82.132 with SMTP id a4mr66054429eez.107.1375207065609; Tue, 30 Jul 2013 10:57:45 -0700 (PDT) Received: from groucho.site (188-195-161-203-dynip.superkabel.de. [188.195.161.203]) by mx.google.com with ESMTPSA id e44sm112264244eeh.11.2013.07.30.10.57.44 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Jul 2013 10:57:44 -0700 (PDT) From: Ulrich Hecht To: linux-sh@vger.kernel.org Cc: magnus.damm@gmail.com, kuninori.morimoto.gx@renesas.com, Ulrich Hecht Subject: [RFC 4/5] arm: boot: kzm9g: blink LEDs and check if DRAM works Date: Tue, 30 Jul 2013 19:57:26 +0200 Message-Id: <1375207047-8655-5-git-send-email-ulrich.hecht@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375207047-8655-1-git-send-email-ulrich.hecht@gmail.com> References: <1375207047-8655-1-git-send-email-ulrich.hecht@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is test code that shows the progress of kernel decompression and does a quick DRAM test: - all LEDs on: start of decompress_kernel() - LED 1 off: DRAM test. Usually the system hangs here; if it doesn't it will most often report an incorrect read by blinking out the address and value read nibble by nibble through the LEDs. - LED 2 off: start of kernel decompression - LED 3 off: end of kernel decompression; if the decompressor has returned an error, LED 1 will be turned back on. - all LEDs off: end of decompress_kernel() The likelihood of a hang is greatly reduced by inserting code between DRAM writes, e.g. by blinking an LED. This also eliminates readback errors. --- arch/arm/boot/compressed/misc.c | 123 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c index 31bd43b..0c54a3d 100644 --- a/arch/arm/boot/compressed/misc.c +++ b/arch/arm/boot/compressed/misc.c @@ -129,6 +129,81 @@ asmlinkage void __div0(void) extern int do_decompress(u8 *input, int len, u8 *output, void (*error)(char *x)); +static void led_setup(void) { + volatile unsigned char *led_cr; + led_cr = (void*)0xe6050014; + led_cr[0] = led_cr[1] = led_cr[2] = led_cr[3] = 0x10; +} +static void led_set(int n, int on) { + volatile unsigned int *led_dxr; + if (on) { + led_dxr = (void*)0xe6074200; + led_dxr[0] = 0x100000 << n; + } + else { + led_dxr = (void*)0xe6074100; + led_dxr[0] = 0x100000 << n; + } +} + +static void led_delay(int n) +{ + n *= 1000000; + int i = 0; + for (i = 0; i < n; i++) { + asm("nop"); + } +} + +static void morse_bits(unsigned int bits) +{ +#define DEL 200 + led_setup(); + led_set(0, 0); + led_set(1, 0); + led_set(2, 0); + led_set(3, 0); + led_delay(DEL); + led_set(0, 1); + led_set(1, 1); + led_set(2, 1); + led_set(3, 1); + led_delay(DEL / 2); + led_set(0, 0); + led_set(1, 0); + led_set(2, 0); + led_set(3, 0); + led_delay(DEL); + int i; + for (i = 28; i >= 0; i -= 4) { + int nibble = bits >> i; + led_set(0, 0); + led_set(1, 0); + led_set(2, 0); + led_set(3, 0); + led_delay(DEL / 2); + led_set(0, 1); + led_set(1, 1); + led_set(2, 1); + led_set(3, 1); + led_delay(DEL / 4); + led_set(0, 0); + led_set(1, 0); + led_set(2, 0); + led_set(3, 0); + led_delay(DEL / 2); + led_set(0, nibble & 1); + led_set(1, nibble & 2); + led_set(2, nibble & 4); + led_set(3, nibble & 8); + led_delay(DEL * 8); + } + led_set(0, 0); + led_set(1, 0); + led_set(2, 0); + led_set(3, 0); +} + void decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p, @@ -142,13 +217,57 @@ decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p, free_mem_end_ptr = free_mem_ptr_end_p; __machine_arch_type = arch_id; + led_setup(); + //morse_bits((unsigned int)output_data); + led_set(0, 1); + led_set(1, 1); + led_set(2, 1); + led_set(3, 1); + + led_set(0, 0); +#if 1 + int i; + volatile unsigned int *dram = output_data;// + 0x10000000; +#define DRAM_TEST_SIZE 10000000 + for (i = 0; i < DRAM_TEST_SIZE; i++) + { + //led_set(0, i & 32768); + //led_set(1, i & 131072); + dram[i] = 0xd00df00d; + dram[i] = 0xcafebabe + i; + } + led_set(0, 0); + led_set(1, 1); +#if 1 + for (i = 0; i < DRAM_TEST_SIZE; i++) { + //led_set(2, i & 32768); + //led_set(3, i & 65536); +#if 1 + if (dram[i] != 0xcafebabe + i) { + //led_set(0, 1); + morse_bits((unsigned int)&dram[i]); + morse_bits(dram[i]); + } +#endif + } + led_set(2, 1); + led_set(3, 1); +#endif +#endif + arch_decomp_setup(); + led_set(1, 0); putstr("Uncompressing Linux..."); ret = do_decompress(input_data, input_data_end - input_data, output_data, error); - if (ret) + led_set(2, 0); + if (ret) { error("decompressor returned an error"); - else + led_set(0, 1); + } + else { putstr(" done, booting the kernel.\n"); + } + led_set(3, 0); }