红联Linux门户
Linux帮助

Linux内核启动出错can't get kernel image

发布时间:2017-05-16 11:30:01来源:linux网站作者:zhengqijun_
主机环境:RHEL6.5
编译器:arm-Linux-gcc 4.3.2
开发板:mini2440
u-boot:2010.03
内核:Linux
 
1、下载uImage到0x30008000
[u-boot@MINI2440]# tftp 30008000 uImage  
dm9000 i/o: 0x20000300, id: 0x90000a46   
DM9000: running in 16 bit mode  
MAC: 08:08:11:18:12:27  
operating at 100M full duplex mode  
Using dm9000 device  
TFTP from server 192.168.1.121; our IP address is 192.168.1.230  
Filename 'uImage'.  
Load address: 0x30008000  
Loading: T ##########################################
done  
Bytes transferred = 2352280 (23e498 hex)
 
2、使用md命令查看内存数据
使用uboot 中的md 命令查看内存数据
[u-boot@MINI2440]# md 0x30008000  
30008000: 56190527 df76f429 50e71659 58e42300    '..V).v.Y..P.#.X  
30008010: 00800030 40800030 44288445 00020205    0...0..@E.(D....  
30008020: 756e694c 2e322d78 32332e36 462d322e    Linux-2.6.32.2-F  
30008030: 6e656972 41796c64 00004d52 00000000    riendlyARM......  
30008040: e1a00000 e1a00000 e1a00000 e1a00000    ................  
30008050: e1a00000 e1a00000 e1a00000 e1a00000    ................  
30008060: ea000002 016f2818 00000000 0023e458    .....(o.....X.#.  
30008070: e1a07001 e1a08002 e10f2000 e3120003    .p....... ......  
30008080: 1a000001 e3a00017 ef123456 e10f2000    ........V4... ..  
30008090: e38220c0 e121f002 00000000 00000000    . ....!.........  
300080a0: e28f00d4 e890307e e0500001 0a00000a    ....~0....P.....  
300080b0: e0855000 e0866000 e08cc000 e0822000    .P...`....... ..  
300080c0: e0833000 e08dd000 e5961000 e0811000    .0..............  
300080d0: e4861004 e156000c 3afffffa e3a00000    ......V....:....  
300080e0: e4820004 e4820004 e4820004 e4820004    ................  
300080f0: e1520003 3afffff9 eb000028 e1a0100d    ..R....:(.......
 
3、直接从flash的0x30008000处启动
bootm 0x30008000
启动信息如下所示:
[u-boot@MINI2440]# bootm 0x30008000  
## Booting kernel from Legacy Image at 30008000 ...  
Image Name:   Linux-2.6.32.2-FriendlyARM  
Created:      2017-05-13  11:00:32 UTC  
Image Type:   ARM Linux Kernel Image (uncompressed)  
Data Size:    2352216 Bytes =  2.2 MB  
Load Address: 30008000  
Entry Point:  30008040  
Verifying Checksum ... OK  
XIP Kernel Image ... OK  
OK  
Starting kernel ...  
Uncompressing Linux.....................  
.................................... done, booting the kernel.  
Please press Enter to activate this console.
说明Linux内核直接从flash启动是没有问题的!(Linux内核的中间启动信息省略。)
 
4、关机重启
从nand启动出错,出错信息为
NAND read: device 0 offset 0x60000, size 0x400000  
4194304 bytes read: OK  
Wrong Image Format for bootm command  
ERROR: can't get kernel image!
NAND明明读取成功,却找不到kernel image。那下面来看看是不是读取的数据有问题。
 
5、使用md命令查看0x30008000处的数据
使用uboot 中的md 命令查看内存数据
[u-boot@MINI2440]# md 0x30008000                          
30008000: be56bfb3 746f6f62 73677261 696f6e3d    ..V.bootargs=noi  
30008010: 7274696e 6f722064 2f3d746f 2f766564    nitrd root=/dev/  
30008020: 2073666e 6e207772 6f727366 313d746f    nfs rw nfsroot=1  
30008030: 312e3239 312e3836 3132312e 666e2f3a    92.168.1.121:/nf  
30008040: 6f722f73 7366746f 3d706920 2e323931    s/rootfs ip=192.  
30008050: 2e383631 33322e31 39313a30 36312e32    168.1.230:192.16  
30008060: 2e312e38 3a313231 2e323931 2e383631    8.1.121:192.168.  
30008070: 3a312e31 2e353532 2e353532 2e353532    1.1:255.255.255.  
30008080: 6f632030 6c6f736e 74743d65 43415379    0 console=ttySAC  
30008090: 31312c30 30303235 696e6920 6c2f3d74    0,115200 init=/l  
300080a0: 78756e69 6d206372 363d6d65 62004d34    inuxrc mem=64M.b  
300080b0: 63746f6f 6e3d646d 20646e61 64616572    ootcmd=nand read  
300080c0: 33783020 38303030 20303030 30367830     0x30008000 0x60  
300080d0: 20303030 30303034 203b3030 746f6f62    000 400000; boot  
300080e0: 3033206d 30383030 62003030 64746f6f    m 30008000.bootd  
300080f0: 79616c65 6200333d 72647561 3d657461    elay=3.baudrate=
发现保存的是uboot 的环境变量,所以导致Linux 内核启动出错!
发现在0x30008000处的flash 果然不是正确的内核启动数据,所以uboot 才会提示找不到内核!
我首先猜想是不是nand write/read 命令有问题,没有将内核数据写入到NAND中。
 
6、下面我使用uboot 的mw 命令来进行验证
a、先将flash从0x30008000处开始写入0x1000个1。
[u-boot@MINI2440]# mw 30008000 1 1000    
[u-boot@MINI2440]# md 30008000   
30008000: 00000001 00000001 00000001 00000001    ................  
30008010: 00000001 00000001 00000001 00000001    ................  
30008020: 00000001 00000001 00000001 00000001    ................  
30008030: 00000001 00000001 00000001 00000001    ................  
30008040: 00000001 00000001 00000001 00000001    ................  
30008050: 00000001 00000001 00000001 00000001    ................  
30008060: 00000001 00000001 00000001 00000001    ................  
30008070: 00000001 00000001 00000001 00000001    ................  
30008080: 00000001 00000001 00000001 00000001    ................  
30008090: 00000001 00000001 00000001 00000001    ................  
300080a0: 00000001 00000001 00000001 00000001    ................  
300080b0: 00000001 00000001 00000001 00000001    ................  
300080c0: 00000001 00000001 00000001 00000001    ................  
300080d0: 00000001 00000001 00000001 00000001    ................  
300080e0: 00000001 00000001 00000001 00000001    ................  
300080f0: 00000001 00000001 00000001 00000001    ................
b、写入NAND中。
先进行擦除nand
[u-boot@MINI2440]# nand erase 60000 1000  
NAND erase: device 0 offset 0x60000, size 0x1000  
Warning: Erase size 0x00001000 smaller than one erase block 0x00020000  
Erasing 0x00020000 instead  
Erasing at 0x6000000000002 --   0% complete.  
OK
然后写入nand
[u-boot@MINI2440]# nand write 0x30008000 60000 1000  
NAND write: device 0 offset 0x60000, size 0x1000  
Writing at 0x6000000020000 -- 100% is complete. 4096 bytes written: OK
c、将0x30008000处的数据清0
[u-boot@MINI2440]# mw 0x30008000 0 1000  
[u-boot@MINI2440]# md 30008000                       
30008000: 00000000 00000000 00000000 00000000    ................  
30008010: 00000000 00000000 00000000 00000000    ................  
30008020: 00000000 00000000 00000000 00000000    ................  
30008030: 00000000 00000000 00000000 00000000    ................  
30008040: 00000000 00000000 00000000 00000000    ................  
30008050: 00000000 00000000 00000000 00000000    ................  
30008060: 00000000 00000000 00000000 00000000    ................  
30008070: 00000000 00000000 00000000 00000000    ................  
30008080: 00000000 00000000 00000000 00000000    ................  
30008090: 00000000 00000000 00000000 00000000    ................  
300080a0: 00000000 00000000 00000000 00000000    ................  
300080b0: 00000000 00000000 00000000 00000000    ................  
300080c0: 00000000 00000000 00000000 00000000    ................  
300080d0: 00000000 00000000 00000000 00000000    ................  
300080e0: 00000000 00000000 00000000 00000000    ................  
300080f0: 00000000 00000000 00000000 00000000    ................
d、读取NAND处的数据到flash中进行验证
[u-boot@MINI2440]# nand read 0x30008000 0x60000 1000  
NAND read: device 0 offset 0x60000, size 0x1000  
4096 bytes read: OK  
[u-boot@MINI2440]# md 30008000                        
30008000: 00000001 00000001 00000001 00000001    ................  
30008010: 00000001 00000001 00000001 00000001    ................  
30008020: 00000001 00000001 00000001 00000001    ................  
30008030: 00000001 00000001 00000001 00000001    ................  
30008040: 00000001 00000001 00000001 00000001    ................  
30008050: 00000001 00000001 00000001 00000001    ................  
30008060: 00000001 00000001 00000001 00000001    ................  
30008070: 00000001 00000001 00000001 00000001    ................  
30008080: 00000001 00000001 00000001 00000001    ................  
30008090: 00000001 00000001 00000001 00000001    ................  
300080a0: 00000001 00000001 00000001 00000001    ................  
300080b0: 00000001 00000001 00000001 00000001    ................  
300080c0: 00000001 00000001 00000001 00000001    ................  
300080d0: 00000001 00000001 00000001 00000001    ................  
300080e0: 00000001 00000001 00000001 00000001    ................  
300080f0: 00000001 00000001 00000001 00000001    ................
写入的数据和读取的数据一致,说明nand write/read命令的功能正常!
仔细查看刚启动的0x30008000处的数据,发现保存的是uboot 的环境变量,所以猜测主要原因可能在于uboot 环境变量的保存位置不对。
注意:这里Linux内核启动失败是因为环境变量覆盖内核数据,导致内核无法正确启动!
uboot 环境变量的保存配置文件在uboot 的include/configs/mini2440.h 文件中。
#define CONFIG_ENV_OFFSET 0X60000    // 决定uboot环境变量的保存位置。
因为0x60000是Linux内核的分区位置,所以每次加载Linux内核的时候,就会出现找不到Kernel image!
 
7、解决方法
将#define CONFIG_ENV_OFFSET 0X60000 改为#define CONFIG_ENV_OFFSET 0X40000后,在重新下载到开发板中运行即可。
 
8、重新下载Linux内核镜像后,写入nand进行重启。
tftp 0x30008000 uImage  
nand erase 0x00060000 0x00500000  
nand write 0x30008000 0x00060000 400000
然后重启开发板出现的Linux 打印的启动信息如下所示:
UBoot 2010.03 (5月 13 2017 - 20:25:21)  
modified by tekkamanninja (tekkamanninja@163.com)  
Love Linux forever!!  
I2C:   ready  
DRAM:  64 MB  
Flash:  2 MB  
NAND:  256 MiB  
In:    serial  
Out:   serial  
Err:   serial  
USB slave is enable!  
Net:   dm9000  
Hit any key to stop autoboot:  0   
NAND read: device 0 offset 0x60000, size 0x400000  
4194304 bytes read: OK  
## Booting kernel from Legacy Image at 30008000 ...  
Image Name:   Linux-2.6.32.2-FriendlyARM  
Created:      2017-05-13  11:00:32 UTC  
Image Type:   ARM Linux Kernel Image (uncompressed)  
Data Size:    2352216 Bytes =  2.2 MB  
Load Address: 30008000  
Entry Point:  30008040  
Verifying Checksum ... OK  
XIP Kernel Image ... OK  
OK  
Starting kernel ...  
Uncompressing Linux.................................  
............................... done, booting the kernel.  
[    0.000000] Linux version 2.6.32.2-FriendlyARM (root@codeMonkey) (gcc version 4.3.2) #4 Sat May 13 19:00:29 CST 2017  
[    0.000000] CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177  
[    0.000000] CPU: VIVT data cache, VIVT instruction cache  
[    0.000000] Machine: FriendlyARM Mini2440 development board  
[    0.000000] Memory policy: ECC disabled, Data cache writeback  
[    0.000000] CPU S3C2440A (id 0x32440001)  
[    0.000000] S3C24XX Clocks, (c) 2004 Simtec Electronics  
[    0.000000] S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz  
Please press Enter to activate this console.
(Linux内核中间启动过程信息省略!)
 
本文永久更新地址:http://www.linuxdiyf.com/linux/30818.html