mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC] imx21ads nand boot
@ 2010-03-19 10:49 Ivo Clarysse
  2010-03-19 11:03 ` Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ivo Clarysse @ 2010-03-19 10:49 UTC (permalink / raw)
  To: barebox

Hi all,

I tried getting barebox MX21ADS to boot from NAND, but I can't get it to work.

Booting in bootstrap mode (copying the barebox image to RAM, and then
executing it from RAM) does work, and "nand_boot_test" copies the nand
image correctly to RAM.

Any clues, anyone ?



diff --git a/board/imx21ads/imx21ads.c b/board/imx21ads/imx21ads.c
index 88dcfb2..5f73fcb 100644
--- a/board/imx21ads/imx21ads.c
+++ b/board/imx21ads/imx21ads.c
@@ -148,3 +148,12 @@ static int mx21ads_console_init(void)
 }

 console_initcall(mx21ads_console_init);
+
+#ifdef CONFIG_NAND_IMX_BOOT
+void __bare_init nand_boot(void)
+{
+        PCCR0 |= PCCR0_NFC_EN;
+	imx_nand_load_image((void *)TEXT_BASE, 256 * 1024);
+}
+#endif
+
diff --git a/board/imx21ads/lowlevel_init.S b/board/imx21ads/lowlevel_init.S
index 1705d79..1d4c594 100644
--- a/board/imx21ads/lowlevel_init.S
+++ b/board/imx21ads/lowlevel_init.S
@@ -20,12 +20,13 @@
 #include <config.h>
 #include <mach/imx-regs.h>

+	.section ".text_bare_init","ax"

 .globl board_init_lowlevel
 board_init_lowlevel:

 /* Save lr, because it is overwritten by the calls to mem_delay. */
-	mov	r5, lr
+	mov	r10, lr

 /*
  * Initialize the AHB-Lite IP Interface (AIPI) module (to enable access to
@@ -71,6 +72,15 @@ board_init_lowlevel:
 	ldr	r1, =0xffffffc9
 	str	r1, [r0]

+	/* Skip SDRAM initialization if we run from RAM */
+	cmp	pc, #0xc0000000
+	bls	1f
+	cmp	pc, #0xc8000000
+	bhi	1f
+
+	mov	pc, r10
+1:
+
 	/* Precharge */
 	ldr	r0, =SDCTL0
 	ldr	r1, =0x92120300
@@ -105,7 +115,42 @@ board_init_lowlevel:
 	ldr	r1, =0x8212F339
 	str	r1, [r0]

-	mov	pc, r5
+	ldr	r0, =PCDR0
+	ldr	r1, =0x6419a007
+	str	r1, [r0]
+
+#ifdef CONFIG_NAND_IMX_BOOT
+	ldr     sp, =TEXT_BASE - 4	/* Setup a temporary stack in SDRAM */
+
+	ldr	r0, =IMX_NFC_BASE		/* start of NFC SRAM        */
+	ldr	r2, =IMX_NFC_BASE + 0x800	/* end of NFC SRAM          */
+
+	/* skip NAND boot if not running from NFC space */
+	cmp	pc, r0
+	bls	ret
+	cmp	pc, r2
+	bhi	ret
+
+	/* Move ourselves out of NFC SRAM */
+	ldr	r1, =TEXT_BASE
+
+copy_loop:
+	ldmia	r0!, {r3-r9}		/* copy from source address [r0]    */
+	stmia	r1!, {r3-r9}		/* copy to   target address [r1]    */
+	cmp	r0, r2			/* until source end addreee [r2]    */
+	ble	copy_loop
+
+	ldr	pc, =1f			/* Jump to SDRAM                    */
+1:
+	bl	nand_boot		/* Load barebox from NAND Flash     */
+
+	ldr	r1, =IMX_NFC_BASE - TEXT_BASE
+	sub	r10, r10, r1		/* adjust return address from NFC   */
+					/* SRAM to SDRAM                    */
+#endif /* CONFIG_NAND_IMX_BOOT */
+
+ret:
+	mov	pc, r10

 /*
  *  spin for a while.  we need to wait at least 200 usecs.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] imx21ads nand boot
  2010-03-19 10:49 [RFC] imx21ads nand boot Ivo Clarysse
@ 2010-03-19 11:03 ` Sascha Hauer
  2010-03-22 12:07   ` Ivo Clarysse
  2010-03-19 11:04 ` Juergen Beisert
  2010-03-19 13:00 ` Alessandro Rubini
  2 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2010-03-19 11:03 UTC (permalink / raw)
  To: Ivo Clarysse; +Cc: barebox

Hi Ivo,

On Fri, Mar 19, 2010 at 11:49:14AM +0100, Ivo Clarysse wrote:
> Hi all,
> 
> I tried getting barebox MX21ADS to boot from NAND, but I can't get it to work.
> 
> Booting in bootstrap mode (copying the barebox image to RAM, and then
> executing it from RAM) does work, and "nand_boot_test" copies the nand
> image correctly to RAM.
> 
> Any clues, anyone ?

Do you know how far you get? Do you have a JTAG debugger? If not,
switching a gpio might help.

Please check that all code you need is inside the first 2k. You can look
at barebox.S, your code might be to big.

Your code looks good from a first glance, I can't find any obvious
mistake in it.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] imx21ads nand boot
  2010-03-19 10:49 [RFC] imx21ads nand boot Ivo Clarysse
  2010-03-19 11:03 ` Sascha Hauer
@ 2010-03-19 11:04 ` Juergen Beisert
  2010-03-19 13:00 ` Alessandro Rubini
  2 siblings, 0 replies; 5+ messages in thread
From: Juergen Beisert @ 2010-03-19 11:04 UTC (permalink / raw)
  To: barebox

Ivo Clarysse wrote:
> I tried getting barebox MX21ADS to boot from NAND, but I can't get it to
> work.
>
> Booting in bootstrap mode (copying the barebox image to RAM, and then
> executing it from RAM) does work, and "nand_boot_test" copies the nand
> image correctly to RAM.
>
> Any clues, anyone ?

Does the SDRAM setup work?

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] imx21ads nand boot
  2010-03-19 10:49 [RFC] imx21ads nand boot Ivo Clarysse
  2010-03-19 11:03 ` Sascha Hauer
  2010-03-19 11:04 ` Juergen Beisert
@ 2010-03-19 13:00 ` Alessandro Rubini
  2 siblings, 0 replies; 5+ messages in thread
From: Alessandro Rubini @ 2010-03-19 13:00 UTC (permalink / raw)
  To: ivo.clarysse; +Cc: barebox

> I tried getting barebox MX21ADS to boot from NAND, but I can't get
> it to work.
> 
> Any clues, anyone ?


> +	ldmia	r0!, {r3-r9}		/* copy from source address [r0]    */
> +	stmia	r1!, {r3-r9}		/* copy to   target address [r1]    */

This is 7 registers, so 28 bytes at a time. So you copy
28, 56, .... 2044, 2072

I don't know what happens when you access memory over the end of
the SRAM area. Maybe it fires a data abort or something like that?

I'd use 4 registers instead of 7, but it might well not be the problem

> +	cmp	r0, r2			/* until source end addreee [r2]    */
> +	ble	copy_loop

"blt" would be better, because when it is equal you are done. Or using
4 registers will not prevent the extra accesses.

> +	ldr	pc, =1f			/* Jump to SDRAM                    */
> +1:
> +	bl	nand_boot		/* Load barebox from NAND Flash     */
> +

Finally, you should ensure the literary pool is within the first 2kB.
I'd place ".ltorg" before the "1:", or would check the disassembly.

Hope this helps, but it may well not help

/alessandro, who has an mx21ads looking at him but also real work to deliver

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] imx21ads nand boot
  2010-03-19 11:03 ` Sascha Hauer
@ 2010-03-22 12:07   ` Ivo Clarysse
  0 siblings, 0 replies; 5+ messages in thread
From: Ivo Clarysse @ 2010-03-22 12:07 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Fri, Mar 19, 2010 at 12:03 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> Do you know how far you get? Do you have a JTAG debugger? If not,
> switching a gpio might help.

I used the CLKO pin to track down how far the booting from NAND gets.

It hangs in nand_imx.c:wait_op_done, after having sent the first
NAND_CMD_READ0 command from nand_imx.c:imx_nand_load_image. (Weird,
since that routine has a timeout)

So SDRAM init appears to be ok; I also checked barebox.S, and
everything needed to complete imx_nand_load_image is in the first
2KiB.

I'll hook up a BDI2000 and see if that helps.

Best regards,

Ivo.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-03-22 12:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-19 10:49 [RFC] imx21ads nand boot Ivo Clarysse
2010-03-19 11:03 ` Sascha Hauer
2010-03-22 12:07   ` Ivo Clarysse
2010-03-19 11:04 ` Juergen Beisert
2010-03-19 13:00 ` Alessandro Rubini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox