public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Reduce OneNAND IPL common code (v3)
@ 2009-03-03  0:05 Kyungmin Park
  2009-03-03 23:12 ` Scott Wood
  0 siblings, 1 reply; 2+ messages in thread
From: Kyungmin Park @ 2009-03-03  0:05 UTC (permalink / raw)
  To: u-boot

OneNAND IPL has common codes for RAM init, load data, and jump to 2nd
bootloader, but it's common code used about 300~400 bytes. So board
specific codes, such as lowlevel_init, can't has enough code. It make
a difficult to implement OneNAND IPL.

his patch make this common code as small as possible. and give
lowlevel_init can have more codes.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
diff --git a/cpu/arm1136/start.S b/cpu/arm1136/start.S
index e622338..c115003 100644
--- a/cpu/arm1136/start.S
+++ b/cpu/arm1136/start.S
@@ -33,23 +33,7 @@
 .globl _start
 _start: b	reset
 #ifdef CONFIG_ONENAND_IPL
-	ldr	pc, _hang
-	ldr	pc, _hang
-	ldr	pc, _hang
-	ldr	pc, _hang
-	ldr	pc, _hang
-	ldr	pc, _hang
-	ldr	pc, _hang
-
-_hang:
-	.word	do_hang
-	.word	0x12345678
-	.word	0x12345678
-	.word	0x12345678
-	.word	0x12345678
-	.word	0x12345678
-	.word	0x12345678
-	.word	0x12345678	/* now 16*4=64 */
+	.	= _start + 64
 #else
 	ldr	pc, _undefined_instruction
 	ldr	pc, _software_interrupt
@@ -362,12 +346,7 @@ cpu_init_crit:
 /*
  * exception handlers
  */
-#ifdef CONFIG_ONENAND_IPL
-	.align	5
-do_hang:
-	ldr	sp, _TEXT_BASE			/* use 32 words about stack */
-	bl	hang				/* hang and never return */
-#else	/* !CONFIG_ONENAND IPL */
+#ifndef CONFIG_ONENAND_IPL
 	.align	5
 undefined_instruction:
 	get_bad_stack
diff --git a/onenand_ipl/onenand_boot.c b/onenand_ipl/onenand_boot.c
index aff62d2..04735e7 100644
--- a/onenand_ipl/onenand_boot.c
+++ b/onenand_ipl/onenand_boot.c
@@ -28,54 +28,17 @@
 
 #include "onenand_ipl.h"
 
-#ifdef CONFIG_SYS_PRINTF
-int print_info(void)
-{
-	printf(XLOADER_VERSION);
-
-	return 0;
-}
-#endif
-
 typedef int (init_fnc_t)(void);
 
-init_fnc_t *init_sequence[] = {
-	board_init,		/* basic board dependent setup */
-#ifdef CONFIG_SYS_PRINTF
-	serial_init,		/* serial communications setup */
-	print_info,
-#endif
-	NULL,
-};
-
 void start_oneboot(void)
 {
-	init_fnc_t **init_fnc_ptr;
 	uchar *buf;
 
-	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-		if ((*init_fnc_ptr)() != 0)
-			hang();
-	}
-
 	buf = (uchar *) CONFIG_SYS_LOAD_ADDR;
 
-	if (!onenand_read_block0(buf))
-		buf += ONENAND_BLOCK_SIZE;
-
-	if (buf == (uchar *)CONFIG_SYS_LOAD_ADDR)
-		hang();
+	onenand_read_block0(buf);
 
-	/* go run U-Boot and never return */
-	printf("Starting OS Bootloader...\n");
 	((init_fnc_t *)CONFIG_SYS_LOAD_ADDR)();
 
 	/* should never come here */
 }
-
-void hang(void)
-{
-	/* if board_hang() returns, hange here */
-	printf("X-Loader hangs\n");
-	for (;;);
-}
diff --git a/onenand_ipl/onenand_ipl.h b/onenand_ipl/onenand_ipl.h
index 3387998..57e54f5 100644
--- a/onenand_ipl/onenand_ipl.h
+++ b/onenand_ipl/onenand_ipl.h
@@ -23,12 +23,6 @@
 
 #include <linux/mtd/onenand_regs.h>
 
-#define ONENAND_BLOCK_SIZE              2048
-
-#ifndef CONFIG_SYS_PRINTF
-#define printf(format, args...)
-#endif
-
 #define onenand_readw(a)        readw(a)
 #define onenand_writew(v, a)    writew(v, a)
 

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

* [U-Boot] [PATCH] Reduce OneNAND IPL common code (v3)
  2009-03-03  0:05 [U-Boot] [PATCH] Reduce OneNAND IPL common code (v3) Kyungmin Park
@ 2009-03-03 23:12 ` Scott Wood
  0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2009-03-03 23:12 UTC (permalink / raw)
  To: u-boot

On Tue, Mar 03, 2009 at 09:05:53AM +0900, Kyungmin Park wrote:
> OneNAND IPL has common codes for RAM init, load data, and jump to 2nd
> bootloader, but it's common code used about 300~400 bytes. So board
> specific codes, such as lowlevel_init, can't has enough code. It make
> a difficult to implement OneNAND IPL.
> 
> his patch make this common code as small as possible. and give
> lowlevel_init can have more codes.
> 
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

Applied generic bits to u-boot-nand-flash/next (minus the complete
removal of hang(), which is pending the ARM change).  The ARM part should
go through the ARM maintainer, and I still think you can have the
exceptions hang with a branch-to-self without needing external code;
something like this (apologies if it's been too long since I've done ARM
ASM):

_start:
	b	reset
#ifdef CONFIG_ONENAND_IPL
	sub	pc, pc, #4
	sub	pc, pc, #4
	sub	pc, pc, #4
	sub	pc, pc, #4
	sub	pc, pc, #4
	sub	pc, pc, #4
	sub	pc, pc, #4

	. = _start + 64
#else
	...
#endif

This would make it easier to see what happened with a JTAG, and prevent
any possibility of it getting stuck in a loop that keeps banging on the
flash chip.

-Scott

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

end of thread, other threads:[~2009-03-03 23:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-03  0:05 [U-Boot] [PATCH] Reduce OneNAND IPL common code (v3) Kyungmin Park
2009-03-03 23:12 ` Scott Wood

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