我的过程如下:
(1)内核配置好以后:linux-q4mf:/home/fangdong/linux #make zImage // 这一步是先生成zImage 文件。
(2)然后制作uImag文件:所谓制作uImage,就是在zImage前面加上一个64字节的头部
将fangdong/u-boot-1.2.0/tools下的mkimage复制到linux2.6.30.10/arch/arm/boot下
然后执行:linux-q4mf:/home/fangdong/linux-2.6.30.10/arch/arm/boot # ./mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -n linux-2.6.30.10 -d zImage uImage
参数说明:
-A arm -------- 架构是arm
-O linux -------- 操作系统是linux
-T kernel -------- 类型是kernel
-C none -------- 压缩类型为无压缩
-a 30008000 ---- image的载入地址(hex)
-e 30008000 ---- 内核的入口地址(hex)
-n linux-2.6.30.10 --- image的名字
-d zImage ---- 无头信息的image文件名 uImage ---- 加了头信息之后的image文件名
这样uImage就制作好了,然后我们通过网络下载到RAM中,进行一些设置,使之从NAND FLASH 启动。
(3)设置好ip后下载:
fangdong2410 # tftp 0x30008000 uImage
NE2000 - eeprom ESA: 08:08:08:12:34:56
TFTP from server 10.103.0.154; our IP address is 10.103.0.153
Filename 'uImage'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
############################################################
done
Bytes transferred = 1966616 (1e0218 hex)
fangdong2410 # nand erase 0x00080000 0x00200000
fangdong2410 # nand write 0x30008000 0x00080000 0x1e0218
fangdong2410 # setenv bootcmd nand read 0x30008000 0x00080000 0x1e0218\;bootm 0x30008000
fangdong2410 #saveenv
重启,结果出现以下情况:
NAND read: device 0 offset 524288, size 2097152 ...
2097152 bytes read: OK
## Booting image at 30008000 ...
Image Name: Linux-2.6.30.10
Created: 2010-04-25 9:59:17 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1966552 Bytes = 1.9 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
XIP Kernel Image ... OK
Starting kernel ...
data abort
pc : [<30008010>] lr : [<33f94754>]
sp : 33f4faa0 ip : 30008000 fp : 00000002
r10: 00000000 r9 : 33e7fe2c r8 : 33f4ffdc
r7 : 33f9e278 r6 : 33f9e278 r5 : 30008000 r4 : 00000000
r3 : 30008000 r2 : 30000100 r1 : 000000c1 r0 : 33f4fce8
Flags: nZCv IRQs off FIQs off Mode SVC_32
Resetting CPU ...
也就是总是重启CPU,上网一查,发现原来是制作uImage时出现的错误:
有位网友是这么说的:因为uImage是压缩的,需要解压,解压的地址是30008000,而这个地址又放了你的uImage本身,这样一解压就把自己覆盖了,于是不断的重启CPU。我想了想,在制作uImage是在zImage基础上加上6464byte的头部,因此uImage的载入地址是0x30008000,在真正的内核的入口地址应该是0x30008000+64byte。因此,内核的真正入口地址应该是0x30008040(0x40=64)所以-e的参数是0x30008040。
(4)重新制作uImage
linux-q4mf:/home/fangdong/linux-2.6.30.10/arch/arm/boot # ./mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -n linux-2.6.30.10 -d zImage uImage(对比以前改了-e 0x30008040)
问题解决。
fangdong2410 # tftp 0x30008000 uImage
NE2000 - eeprom ESA: 08:08:08:12:34:56
TFTP from server 10.103.0.154; our IP address is 10.103.0.153
Filename 'uImage'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
############################################################
done
Bytes transferred = 1966616 (1e0218 hex)
fangdong2410 # nand erase 0x00080000 0x00200000
fangdong2410 # nand write 0x30008000 0x00080000 0x1e0218
重启
NAND read: device 0 offset 524288, size 1966616 ...
1966616 bytes read: OK
## Booting image at 30008000 ...
Image Name: linux-2.6.30.10
Created: 2010-04-27 1:40:03 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1966552 Bytes = 1.9 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
Starting kernel ...
Uncompressing Linux............................................................................................................................... done, booting the kernel.
Linux version 2.6.30.10 (root@linux-q4mf) (gcc version 3.4.4) #1 Sun Apr 25 17:59:00 CST 2010
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2410
Warning: bad configuration page, trying to continue
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping off. Total pages: 4064
Kernel command line: root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200
.....