public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] OneNAND alternative to X-Load
@ 2007-05-23  5:29 Pete MacKay
  2007-05-24 11:29 ` Stefan Roese
  0 siblings, 1 reply; 3+ messages in thread
From: Pete MacKay @ 2007-05-23  5:29 UTC (permalink / raw)
  To: u-boot


We're developing a PXA-270-based machine that will boot from OneNAND.  I
wanted to share my ideas (and code) with anyone faced with this challenge,
since this forum (esp. Kyungmin Park - thank you!!) was quite helpful.
 I'll start off explaining my u-boot code, then when I get some time I'll
submit my PXA-270 platform driver as a patch (currently works on 2.6.18).

We use a common approach: in lacking JTAG we have chip select jumpers that
swap CS0/CS1 between NOR and OneNAND.  The OneNAND has a bottom-mapped 2K
boot buffer of which 1K is valid, which is where the level 1 boot loader
fits.  It uses two memory-mapped 'bufferrams' to ping-pong data out of the
NAND pages, but you want to use BUFFERRAM1 only as writing BUFFERRAM0 can
corrupt BOOTRAM0 on some revs of the chip.  (We're executing out of
BOOTRAM0 so that's bad :).

There is open-source code called "x-loader" that is a stripped-down u-boot
for the level 1 boot loader.  What I did was integrate the level 1
function into u-boot itself with a custom configuration and linker script.
In the top u-boot Makefile I added this:

myboard_config	:	unconfig
	@./mkconfig $(@:_config=) arm pxa myboard

myboard_onenand_config	:	unconfig
	@./mkconfig $(@:_config=) arm pxa myboard
	@echo "LDSCRIPT := $(TOPDIR)/board/myboard/u-boot.onenand.lds" >>
include/config.mk

In include/configs/myboard_onenand.h I simply define CONFIG_BOOT_ONENAND
and then include myboard.h, with conditional switches inside for base
address, etc (i.e. define CONFIG_IDENT_STRING as " from OneNAND" or " from
NOR").

The linker script replaces cpu/pxa/start.S with oneboot.S and makes sure
the C code to load the other pages positions there too.  Then it aligns
the rest of u-boot at the 2K boundary (NAND page 1).  The oneboot.S code
melds start.S with lowlevel_init but calls C code to read the rest of the
block 0 pages into RAM.  I later optimized it to replace start.S entirely
for the NOR version.

BTW, I lacked originality and stole (liked) the name: oneboot is not to be
confused with the script that merges x-load and u-boot into one binary
image.

This is the relevant portion of the u-boot linker script:

	. = 0x00000000;

	. = ALIGN(4);
	.text :
	{
	  board/myboard/oneboot.o	(.text)
	  board/myboard/onenand_boot.o	(.text)
	  __oneboot_end = .;	/* must not exceed 0x400! */

	  . = 0x800;		/* reposition to 2K page boundary */
	  __page1_start = .;	/* OneNAND loading starts here */
	  *				(.text)
	}

Look at System.map to make sure your level 1 code fits within 1K.  Also in
oneboot.S I commented out labels and used relative branches to save symbol
space and replaced ldr with mov wherever possible.  And with the 270
optimizations in oneboot.S our system screams!

The full code is at http://code.architechnical.net/onenand, including the
2.6.18 pxa27x OneNAND driver.  Please don't laugh at my lame ancient web
site.  Oh yeah, I'm using arm-linux-gcc 3.4.4.
-- 
View this message in context: http://www.nabble.com/OneNAND-alternative-to-X-Load-tf3802100.html#a10757753
Sent from the Uboot - Users mailing list archive at Nabble.com.

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

* [U-Boot-Users] OneNAND alternative to X-Load
  2007-05-23  5:29 [U-Boot-Users] OneNAND alternative to X-Load Pete MacKay
@ 2007-05-24 11:29 ` Stefan Roese
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2007-05-24 11:29 UTC (permalink / raw)
  To: u-boot

Hi Pete,

On Wednesday 23 May 2007, Pete MacKay wrote:
> We're developing a PXA-270-based machine that will boot from OneNAND.  I
> wanted to share my ideas (and code) with anyone faced with this challenge,
> since this forum (esp. Kyungmin Park - thank you!!) was quite helpful.
>  I'll start off explaining my u-boot code, then when I get some time I'll
> submit my PXA-270 platform driver as a patch (currently works on 2.6.18).
>
> We use a common approach: in lacking JTAG we have chip select jumpers that
> swap CS0/CS1 between NOR and OneNAND.  The OneNAND has a bottom-mapped 2K
> boot buffer of which 1K is valid, which is where the level 1 boot loader
> fits.  It uses two memory-mapped 'bufferrams' to ping-pong data out of the
> NAND pages, but you want to use BUFFERRAM1 only as writing BUFFERRAM0 can
> corrupt BOOTRAM0 on some revs of the chip.  (We're executing out of
> BOOTRAM0 so that's bad :).
>
> There is open-source code called "x-loader" that is a stripped-down u-boot
> for the level 1 boot loader.  What I did was integrate the level 1
> function into u-boot itself with a custom configuration and linker script.
> In the top u-boot Makefile I added this:
>
> myboard_config	:	unconfig
> 	@./mkconfig $(@:_config=) arm pxa myboard
>
> myboard_onenand_config	:	unconfig
> 	@./mkconfig $(@:_config=) arm pxa myboard
> 	@echo "LDSCRIPT := $(TOPDIR)/board/myboard/u-boot.onenand.lds" >>
> include/config.mk

Did you take a look at the currently implemented NAND booting support in 
U-Boot? Right now the PPC440EPx Sequoia board is the only board in this 
NAND_SPL infrastructure. Please take a look at doc/README.nand-boot-ppc440 
for some more details. And the sequoia board config file too of course.

Your approach is a little different. It would be best, if you could at least 
try to match the infrastructure of nand_spl a little better. For example the 
nand_spl/board/xxx directory with the upon compiletime created links to the 
common files.

Please let me know, if you feel that your OneNAND booting support for your 
board can be implemented in this infrastructure.

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

* [U-Boot-Users] OneNAND alternative to X-Load
       [not found] <2453.69.30.123.186.1179897401.squirrel@architechnical.net>
@ 2007-05-30  1:27 ` Kyungmin Park
  0 siblings, 0 replies; 3+ messages in thread
From: Kyungmin Park @ 2007-05-30  1:27 UTC (permalink / raw)
  To: u-boot

Hi Pete Mackay,

Before the main story, I explain the history of x-loader.
First, it was designed for NAND boot from TI for their platforms. With simple
code and similar structure of U-Boot, it's easy to modify for OneNAND.
And at that time, we also considered another bootloader, of course, including
U-Boot. So we released the X-loader for OneNAND as 1st bootloader.

Now you want to add the 1KB bootloader (1st bootloader) for OneNAND at U-Boot. I
think there's no problem except the handling of code position at OneNAND.

The original handling of xloader is like this
1. The xloader (less than 1KB) loads u-boot image to DRAM using BufferRAM0.
2. Jump to DRAM address
3. run u-boot at DRAM

0x0000 (BootRAM0) __xloader_start                   --> load u-boot code to
BufferRAM0
0x03fff                     __xloader_end
0x0400 (not valid)
0x0800 (BufferRAM0) used for xloader buffer ram --> u-boot code
0x0bff                
0x0c00 (BufferRAM1) not used                           --> used for u-boot
buffer ram
0x0fff

But as you mentioned, you can make a u-boot.bin image with linker script
handling. Overall structures are similar except that it's built with one time.

Also you can find the similar idea at
http://linuxdevices.com/articles/AT2779754250.html

And please see the below comment.

Thank you,
Kyungmin Park

> 
> We're developing a PXA-270-based machine that will boot from 
> OneNAND.  I
> wanted to share my ideas (and code) with anyone faced with 
> this challenge,
> since this forum (esp. Kyungmin Park - thank you!!) was quite helpful.
>  I'll start off explaining my u-boot code, then when I get 
> some time I'll
> submit my PXA-270 platform driver as a patch (currently works 
> on 2.6.18).
> 
> We use a common approach: in lacking JTAG we have chip select 
> jumpers that
> swap CS0/CS1 between NOR and OneNAND.  The OneNAND has a 
> bottom-mapped 2K
> boot buffer of which 1K is valid, which is where the level 1 
> boot loader
> fits.  It uses two memory-mapped 'bufferrams' to ping-pong 
> data out of the
> NAND pages, but you want to use BUFFERRAM1 only as writing 
> BUFFERRAM0 can
> corrupt BOOTRAM0 on some revs of the chip.  (We're executing out of
> BOOTRAM0 so that's bad :).
> 
> There is open-source code called "x-loader" that is a 
> stripped-down u-boot
> for the level 1 boot loader.  What I did was integrate the level 1
> function into u-boot itself with a custom configuration and 
> linker script.
> In the top u-boot Makefile I added this:
> 
> myboard_config	:	unconfig
> 	@./mkconfig $(@:_config=) arm pxa myboard
> 
> myboard_onenand_config	:	unconfig
> 	@./mkconfig $(@:_config=) arm pxa myboard
> 	@echo "LDSCRIPT := 
> $(TOPDIR)/board/myboard/u-boot.onenand.lds" >>
> include/config.mk
> 
> In include/configs/myboard_onenand.h I simply define 
> CONFIG_BOOT_ONENAND
> and then include myboard.h, with conditional switches inside for base
> address, etc (i.e. define CONFIG_IDENT_STRING as " from 
> OneNAND" or " from
> NOR").
> 
> The linker script replaces cpu/pxa/start.S with oneboot.S and 
> makes sure
> the C code to load the other pages positions there too.  Then 
> it aligns
> the rest of u-boot at the 2K boundary (NAND page 1).  The 
> oneboot.S code
> melds start.S with lowlevel_init but calls C code to read the 
> rest of the
> block 0 pages into RAM.  I later optimized it to replace 
> start.S entirely
> for the NOR version.
> 
> BTW, I lacked originality and stole (liked) the name: oneboot 
> is not to be
> confused with the script that merges x-load and u-boot into one binary
> image.
> 
> This is the relevant portion of the u-boot linker script:
> 
> 	. = 0x00000000;
> 
> 	. = ALIGN(4);
> 	.text :
> 	{
> 	  board/myboard/oneboot.o	(.text)
> 	  board/myboard/onenand_boot.o	(.text)

The onenand_boot.c is common code for all platforms. I think it's located in
drivers/onenand or onenand_spl as nand_spl in U-Boot.
Yes I know the OneNAND patch for U-Boot is not merged yet. In this code,
however, there's no problem to boot with OneNAND.

> 	  __oneboot_end = .;	/* must not exceed 0x400! */
> 
> 	  . = 0x800;		/* reposition to 2K page boundary */
> 	  __page1_start = .;	/* OneNAND loading starts here */
> 	  *				(.text)
> 	}
> 
> Look at System.map to make sure your level 1 code fits within 
> 1K.  Also in
> oneboot.S I commented out labels and used relative branches 
> to save symbol
> space and replaced ldr with mov wherever possible.  And with the 270
> optimizations in oneboot.S our system screams!
> 
> The full code is at http://code.architechnical.net/onenand, 
> including the
> 2.6.18 pxa27x OneNAND driver.  Please don't laugh at my lame 
> ancient web
> site.
> 
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
> 
> 

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

end of thread, other threads:[~2007-05-30  1:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-23  5:29 [U-Boot-Users] OneNAND alternative to X-Load Pete MacKay
2007-05-24 11:29 ` Stefan Roese
     [not found] <2453.69.30.123.186.1179897401.squirrel@architechnical.net>
2007-05-30  1:27 ` Kyungmin Park

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