S3C2410平台上支持NAND boot的u-boot移植和共享

  小弟现有一个可用的nand flash启动的u-boot源代码愿意分享,具体下载地址如下:
  http://www.hhcn.org/maindoc/nandboot-2410-luofuchong.rar 在此感谢华恒斑竹hn的帮助和提供空间^_^。
  小弟不敢贪功,先注明一下这个源码的出处: 补丁来源于以下网站:
  http://linux.insigma.com.cn/devbbs/dispbbs.asp?boardID=15&ID=382&page=1
  其实这个补丁早就下载了,但小弟不懂cvs的用法,怕麻烦一直没下载其对应版本的源码(在这里的显示版本虽然是1.1.4,但可是经过多人修改的,所以和官方的版本相差甚远)。
  后来我哥把它下载下来,于是就抽空把它编译了一下,串口居然有输出,兴致来了,花了几天搞了一下,现在基本可以用了。

这是cvs下载源码的方法:
cvs -d:pserver:anonymous@u-boot.cvs.sourceforge.net:/cvsroot/u-boot login
cvs -z3 -d:pserver:anonymous@u-boot.cvs.sourceforge.net:/cvsroot/u-boot co -D 20060523 -P u-boot
我经已经试过可以下载的了,不过最好晚上再下载成功率会高一点^_^
登录的时候提示密码的时候直接按回车就行。

在些说一下这几天编译的经验:
1)打上补丁的过程中提示2、3个文件有些地方未能正常打补丁,但不影响编译。
2)要用2.95.3的交叉编译器来编译,我试过用3.3.2的编译器来编译通过,但nand flash检测的那段代码没有运行,导致nand flash检测不出来,这可花了我不少的时间~_~
3)附上的补丁是我修改过的(主要是一些提示信息和env地址的修改),打补丁的方法如下(假如你把补丁放到u-boot目录下):

代码:
---------------------------------------------------------------------------------------------
patch -p1 <u-boot-lfc.patch
---------------------------------------------------------------------------------------------
好了,下面介绍一下这个u-boot的用法:
U-Boot 1.1.4 (Oct 23 2006 - 22:04:37)

U-Boot code: 33F80000 -> 33F9DC98 BSS: -> 33FA2308
RAM Configuration:
Bank #0: 30000000 64 MB
Nor Flash: 512 kB
Nand Flash: 64 MB

In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0

sbc2410=> printenv
bootargs=noinitrd root=/dev/mtdblock/3 console=ttySAC0
bootdelay=3
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
bootfile="zImage"
filesize=13469c
fileaddr=30008000
netmask=255.255.255.0
ipaddr=192.168.1.128
serverip=192.168.1.15
bootcmd=nand read 30008000 30000 1d0000;go 30008000
stdin=serial
stdout=serial
stderr=serial
Environment size: 319/65532 bytes

sbc2410=> nand
nand - NAND sub-system
info - show available NAND devices
nand device [dev] - show or set current device
nand read[.jffs2[s] addr off size
nand write[.jffs2] addr off size - read/write `size' bytes starting at offset `off' to/from memory address `addr'
nand erase [clean] [off size] - erase `size' bytes from offset `off' (entire device if not specified)
nand bad - show bad blocks
nand read.oob addr off size - read out-of-band data
nand write.oob addr off size - read out-of-band data

注:这是对nand flash操作的命令,我修改过源码好让它提示出来(默认好像没有提示)
按照提示应该都会它的用法了吧?不过在此还是举一个烧写内核的例子吧:
sbc2410=> tftp
TFTP from server 192.168.1.15; our IP address is 192.168.1.128
Filename 'zImage'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
####################################################
done
Bytes transferred = 1263260 (13469c hex)
注:可以看出,网络也是好的^_^

sbc2410=> nand erase 30000 1d0000
NAND erase: device 0 offset 196608, size 1900544 ... OK

sbc2410=> nand write 30008000 30000 1d0000
NAND write: device 0 offset 196608, size 1900544 ... 1900544 bytes written: OK

OK,现在内核已经写入nand flash了,想开机引导它?

sbc2410=> setenv bootcmd nand read 30008000 30000 1d0000\;go 30008000
sbc2410=> saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done

这样就可以了。好了,现在按一下你的复位键试试:
U-Boot 1.1.4 (Oct 23 2006 - 21:28:24)

U-Boot code: 33F80000 -> 33F9DC88 BSS: -> 33FA22F8
RAM Configuration:
Bank #0: 30000000 64 MB
Nor Flash: 512 kB
Nand Flash: 64 MB

In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0

NAND read: device 0 offset 196608, size 1900544 ... 1900544 bytes read: OK
## Starting application at 0x30008000 ...
Uncompressing Linux................................................................................. done, booting the kernel.
Linux version 2.6.14 (root@luofuchong) (gcc version 3.4.1) #21 Fri Oct 20 17:20:39 CST 2006
CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)
Machine: SMDK2410
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
S3C2410 Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
USB Control, (c) 2006 sbc2410
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists
Kernel command line: noinitrd root=/dev/mtdblock/3 console=ttySAC0
irq: clearing subpending status 00000002
PID hash table entries: 512 (order: 9, 8192 bytes)
timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 64MB = 64MB total
Memory: 62208KB available (1924K code, 529K data, 108K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
softlockup thread 0 started up.
NET: Registered protocol family 16
S3C2410: Initialising architecture
SCSI subsystem initialized
usbcore: registered new driver usbfs
usbcore: registered new driver hub
S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
NetWinder Floating Point Emulator V0.97 (double precision)
devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
devfs: devfs_debug: 0x0
devfs: boot_options: 0x1
yaffs Oct 18 2006 12:39:51 Installing.
Console: switching to colour frame buffer device 30x40
fb0: s3c2410fb frame buffer device
fb1: Virtual frame buffer device, using 1024K of video memory
led driver initialized
s3c2410 buttons successfully loaded
s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
usbcore: registered new driver ub
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: CS8900A rev E at 0xe0000300 irq=53, no eeprom , addr: 08: 0:3E:26:0A:5B
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2410-nand: mapped registers at c4980000
s3c2410-nand: timing: Tacls 10ns, Twrph0 30ns, Twrph1 10ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 1884 at 0x01d70000
Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x00020000 : "vivi"
0x00020000-0x00030000 : "param"
0x00030000-0x00200000 : "kernel"
0x00200000-0x04000000 : "root"
usbmon: debugfs is not available
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
usbcore: registered new driver usbmouse
drivers/usb/input/usbmouse.c: v1.6:USB HID Boot Protocol mouse driver
mice: PS/2 mouse device common for all mice
s3c2410 TouchScreen successfully loaded
UDA1341 audio driver initialized
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
Root-NFS: No NFS server available, giving up.
VFS: Unable to mount root fs via NFS, trying floppy.
yaffs: dev is 32505859 name is "mtdblock3"
yaffs: Attempting MTD mount on 31.3, "mtdblock3"
block 1757 is bad
VFS: Mounted root (yaffs filesystem).
Mounted devfs on /dev
Freeing init memory: 108K

init started: BusyBox v1.1.3 (2006.09.20-14:52+0000) multi-call binary
Starting pid 695, console /dev/tts/0: '/etc/init.d/rcS'
Please press Enter to activate this console.
注:这就是在我的板上的启动信息了^_^

遗留的问题:
1:这个u-boot只提供jffs2文件系统的烧写功能(具体未用过,因为我只搞过yaffs文件系统~_~),没有对yaffs文件系统的烧写支持,我想这部分就留给各位去做吧^_^
2:好像用同样的方法来启动2.4内核解压后内核不能启动,但2.6内核就可以,具体不知道原因,知道的朋友请告知并把修改好的补丁共享,发挥一下共享精神,谢谢!