以下是将能在sdram中运行的linux内核和文件系统烧写到flash中的方法!
从内部rom启动后,加载loader.bin和uboot.bin(重新编译的)
发送boot.bin :在提示符下我们输入如下命令
Uboot> loadb 20000000 将boot.bin上传到0x20000000的sdram地址。
Uboot> cp.b 20000000 10000000 ffff将boot.bin烧写到0x10000000的flash地址。
发送u-boot.bin.gz:在提示符下我们输入如下命令
Uboot> loadb 20000000 将u-boot.bin.gz上传到0x20000000的sdram地址。
Uboot> cp.b 20000000 10020000 ffff将u-boot.bin.gz烧写到0x10020000的flash地址。
(说明:这里需要将boot的原始码中的0x10010000修改为0x10020000,再重新编译生成boot.bin!)
登陆linux服务器后:
[tank@redhat9 tank]$ cd AT91RM9200-U-Boot/
[tank@redhat9 AT91RM9200-U-Boot]$ ls
arm_config.mk drivers MAINTAINERS tmp uboot.PFI
board dtt MAKEALL tools uboot.PO
CHANGELOG examples Makefile u-boot uboot.PR
common fs mips_config.mk u-boot1.gz uboot.PRI
config.mk i386_config.mk mkconfig u-boot.bin uboot.PS
COPYING include net u-boot.bin.gz uboot.SearchResults
cpu lib_arm post uboot.IAB u-boot.srec
CREDITS lib_generic ppc_config.mk uboot.IAD uboot.WK3
CVS lib_i386 README uboot.IMB
disk lib_mips rtc uboot.IMD
doc lib_ppc System.map u-boot.map
[tank@redhat9 AT91RM9200-U-Boot]$ cd tools
[tank@redhat9 tools]$ ls
bddb CVS environment.c img2srec Makefile.win32 updater
bmp_logo easylogo environment.o img2srec.c mkimage zImage
bmp_logo.c env gdb img2srec.o mkimage.c tdramdisk.gz
bmp_logo.o envcrc gen_eth_addr inca-swap-bytes.c mkimage.o
crc32.c envcrc.c gen_eth_addr.c logos scripts
crc32.o envcrc.o gen_eth_addr.o Makefile uImage
把内核镜象文件zImage(能在sdram中运行的)拷贝到这个tools目录下后,再执行如下命令(注意参数大小写):
[tank@redhat9 tools]$ ./mkimage -A arm -O linux -T kernel -C none -a 0x20008000 -e 0x20008000 -n "linux2.4.19-rmk7" -d zImage uImage
提示信息:
Image Name: linux2.4.19-rmk7
Created: Fri Jun 17 13:41:08 2005
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 523504 Bytes = 511.23 kB = 0.50 MB
Load Address: 0x20008000
Entry Point: 0x20008000
把根文件系统tdramdisk.gz(能在sdram中运行的)拷贝到这个tools目录下后,再执行如下命令(注意参数大小写):
[tank@redhat9 tools]$ ./mkimage -A arm -O linux -T RAMDisk -C gzip -a 0x21000000 -e 0x21000000 -n "ramdisk file sysytem" -d tdramdisk.gz tdramdisk
提示信息:
Image Name: ramdisk file system
Created: Thu Jul 14 11:40:36 2005
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 5249216 Bytes = 5126.19 kB = 5.01 MB
Load Address: 0x21000000
Entry Point: 0x21000000
这样就生成了要烧写到flash上的内核镜象文件uImage和根文件系统tdramdisk。
具体烧到flash中的地址自己根据内核大小(0x10030000开始)和根文件系统大小确定。
setenv以下这些环境变量:
只要是擦除,修改环境变量,先打开flash写保护
protect off all
setenv ethaddr 12:12:12:12:12:12 //0~f字符随意
setenv bootdelay 3 //默认为3秒
setenv loadaddr 21000000 //下载到SDRAM中的地址
setenv netmask 255.255.255.0 //默认存在
setenv ipaddr 192.168.0.112 //目标板ip地址
setenv serverip 192.168.0.111 //pc机ip地址
setenv bootcmd bootm 0x10030000 0x100e0000 //内核、文件系统的烧写地址
saveenv //保存环境变量
protect on all
保存环境变量后,能用printenv查看环境变量。
再将之前编译的内核镜象文件uImage和根文件系统tdramdisk,烧写固化到flash中。
能通过tftp的方式先将uImage和tdramdisk上传到sdram中,再进行烧写。即:
Uboot> protect off all
Uboot> erase 0x10030000 0x107fffff //从0x10030000到8MB
Uboot> tftp 20000000 uImage
Uboot> cp.b 20000000 10030000 bffff //64kB*12,大约用时3分钟
Uboot> tftp 20000000 tdramdisk
Uboot> cp.b 20000000 100e0000 5fffff //6MB,大约用时20分钟左右
Uboot> protect on all //此处flash烧写地址应和上面设置一致
然后从就能从flash启动uboot并直接加载运行linux。
boot 1.0 (May 31 2005 - 20:27:47)
Uncompressing image...
U-Boot 0.3.2 (Jun 5 2005 - 18:52:28)
U-Boot code: 21F00000 -> 21F133EC BSS: -> 21F16E98
DRAM Configuration:
Bank #0: 20000000 32 MB
Spansion: S29GL064M90TAIR7 (64Mbit)
flash_nb_blocks= 1
Flash: 8 MB
Hit any key to stop autoboot: 0
[RUN_COMMAND] cmd[21f1ef0e]="bootm 0x10030000 0x100e0000"
[PROCESS_SEPARATORS] bootm 0x10030000 0x100e0000
token: "bootm 0x10030000 0x100e0000"
[PROCESS_MACROS] INPUT len 27: "bootm 0x10030000 0x100e0000"
[PROCESS_MACROS] OUTPUT len 27: "bootm 0x10030000 0x100e0000"
parse_line: "bootm 0x10030000 0x100e0000"
parse_line: nargs=3
starting run command...go into do_bootm
## Booting image at 10030000 ...
count=40
dest=21f15a50,src=10030000
dest > src Image Name: linux2.4.19-rmk7
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 670000 Bytes = 654.3 kB
Load Address: 20008000
Entry Point: 20008000
Verifying Checksum ... OK
count=a3930
dest=20008000,src=10030040
dest > srcOK
## Loading Ramdisk Image at 100e0000 ...
Image Name: ramdisk file system
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 5249216 Bytes = 5 MB
Load Address: 21000000
Entry Point: 21000000
Verifying Checksum ... OK
count=5018c0
dest=21000000,src=100e0040
dest > src
## Transferring control to Linux (at address 20008000) ...
Starting kernel ...
Uncompressing Linux...................................... done, booting the kern
el.
Linux version 2.4.19-rmk7 (tank@redhat9) (gcc version 2.95.3 20010315 (release))
#3 六 6月 11 17:37:07 CST 2005
CPU: Arm920Tid(wb) revision 0
Machine: ATMEL AT91RM9200
Warning: bad configuration page, trying to continue
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: mem=32M console=ttyS0,115200 initrd=0x21000000,0x800000 roo
t=/dev/ram rw init=/linuxsrc
Calibrating delay loop... 89.70 BogoMIPS
Memory: 32MB = 32MB total
Memory: 22948KB available (984K code, 200K data, 52K init)
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
devfs: v1.12a (20020514) Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
RAMDISK driver initialized: 16 RAM disks of 32768K size 1024 blocksize
physmap flash device: 800000 at 10000000
Amd/Fujitsu Extended Query Table v1.3 at 0x0040
number of CFI chips: 1
cfi_cmdset_0002: Disabling fast programming due to code brokenness.
usb.c: registered new driver hub
ttyS%d0 at MEM 0xfefff200 (irq = 1) is a AT91_SERIAL
ttyS%d1 at MEM 0xfefc4000 (irq = 7) is a AT91_SERIAL
eth0: Link now 100-FullDuplex
eth0: AT91 ethernet at 0xfefbc000 int=24 100-FullDuplex (12:12:12:12:12:12)
AT91 Watchdog Timer enabled (5 seconds)
AT91 Real Time Clock driver
usb-ohci.c: USB OHCI at membase 0xc3006000, IRQ 23
usb.c: new USB bus registered, assigned bus number 1
hub.c: USB hub found
hub.c: 2 ports detected
i2c-dev.o: Registered ’AT91RM9200’ as minor 0
Found AT91 i2c
AT91 SPI driver loaded
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 2048)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NetWinder Floating Point Emulator V0.95 (c) 1998-1999 Rebel.com
RAMDISK: Compressed image found at block 0
Freeing initrd memory: 8192K
VFS: Mounted root (ext2 filesystem).
Mounted devfs on /dev
Freeing init memory: 52K
Initializing random number generator... done.
Starting network...
hub.c: USB new device connect on bus1/2, assigned device number 2
usb.c: USB device not accepting new address=2 (error=-110)
run-parts: failed to open directory /etc/network/if-pre-up.d: No such file or di
rectory
hub.c: USB new device connect on bus1/2, assigned device number 3
usb.c: USB device not accepting new address=3 (error=-110)
Starting system logger: syslogd
Starting INET services: inetd
Starting mouse
Starting tty
Starting console mouse services: gpmgpm: oops() invoked from gpn.c(132)
loadlut: is your kernel compiled with CONFIG_SELECTION on?: Invalid argument
Starting rtc
INIT: Id "1" respawning too fast: disabled for 5 minutes
AT91RM9200DK login: root
[root@AT91RM9200DK /root]$cd /
[root@AT91RM9200DK /]$ls
var usr tmp sbin root rd
proc mnt lost+found lib home etc
dev bin drivers
[root@AT91RM9200DK /]$cd drivers/
[root@AT91RM9200DK /drivers]$ls
485 ad can da ioin ioout
lcd pwm keysegment led hello testusb
[root@AT91RM9200DK /drivers]$cd lcd
[root@AT91RM9200DK lcd]$ls
lcd.o testlcd.o
[root@AT91RM9200DK lcd]$insmod lcd.o
[root@AT91RM9200DK lcd]$mknod /dev/lcd c 219 0
[root@AT91RM9200DK lcd]$./testlcd.o
[root@AT91RM9200DK lcd]$