二、-a参数与-e参数和内核引导的关系
- -a参数后是内核的运行地址,-e参数后是入口地址。
- 如果我们没用mkimage对内核进行处理的话,那直接把内核下载到0x30008000再运行就行,内核会自解压运行(不过内核运行需要一个tag来传递参数,而这个tag建议是由BootLoader提供的,在U-Boot下默认是由bootm命令建立的)。
- 如果使用mkimage生成内核镜像文件的话,会在内核的前头加上了64byte的信息,供建立tag之用。bootm命令会首先判断bootm xxxx 这个指定的地址xxxx是否与-a指定的加载地址相同。如果不同的话会从这个地址开始提取出这个64byte的头部,对其进行分析,然后把去掉头部的内核复制到-a指定的load地址中去运行之。如果相同的话那就让其原封不同的放在那,但-e指定的入口地址会推后64byte,以跳过这64byte的头部。
三、实例测试
3.1 -a参数与-e参数相同,可以将内核下载到SDRAM的任何地址,然后从这启动
zImage.img的制作
*****************
root@www.linuxidc.com:~/桌面# ./mkimage -n 'linux-2.6.30' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage zImage.img
Image Name: linux-2.6.30
Created: Sat Mar 3 23:41:49 2012
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1862.73 kB = 1.82 MB
Load Address: 0x30008000
Entry Point: 0x30008000
root@www.linuxidc.com:~/桌面#
Linux引导时的输出
*******************
czu2440 # tftp 0x30000000 zImage.img
TFTP from server 192.168.1.1; our IP address is 192.168.1.5
Filename 'zImage.img'.
Load address: 0x30000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
done
Bytes transferred = 1907504 (1d1b30 hex)
czu2440 # bootm 0x30000000
## Booting image at 30000000 ...
Image Name: linux-2.6.30
Created: 2012-03-03 15:41:49 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1.8 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
OK
Starting kernel ...
Uncompressing Linux.............................................................
............................................................. done, booting the
kernel.
*****************
root@www.linuxidc.com:~/桌面# ./mkimage -n 'linux-2.6.30' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage zImage.img
Image Name: linux-2.6.30
Created: Sat Mar 3 23:41:49 2012
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1862.73 kB = 1.82 MB
Load Address: 0x30008000
Entry Point: 0x30008000
root@www.linuxidc.com:~/桌面#
Linux引导时的输出
*******************
czu2440 # tftp 0x30000000 zImage.img
TFTP from server 192.168.1.1; our IP address is 192.168.1.5
Filename 'zImage.img'.
Load address: 0x30000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
done
Bytes transferred = 1907504 (1d1b30 hex)
czu2440 # bootm 0x30000000
## Booting image at 30000000 ...
Image Name: linux-2.6.30
Created: 2012-03-03 15:41:49 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1.8 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
OK
Starting kernel ...
Uncompressing Linux.............................................................
............................................................. done, booting the
kernel.
注意:“Starting kernel ...”是U-Boot在引导内核前输出的信息,后面输出的信息就和U-Boot的没有关系了。
3.2 -a参数与-e参数不同,只能将内核下载到-a参数后面的地址,然后从这启动;否则无法引导内核
zImage.img的制作
*****************
*****************
root@www.linuxidc.com:~/桌面# ./mkimage -n 'linux-2.6.30' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage zImage.img
Image Name: linux-2.6.30
Created: Sun Mar 4 00:18:05 2012
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1862.73 kB = 1.82 MB
Load Address: 0x30008000
Entry Point: 0x30008040
root@www.linuxidc.com:~/桌面#
Linux引导时的输出
*******************
czu2440 # tftp 0x30008000 zImage.img
TFTP from server 192.168.1.1; our IP address is 192.168.1.5
Filename 'zImage.img'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
done
Bytes transferred = 1907504 (1d1b30 hex)
czu2440 # bootm 0x30008000
## Booting image at 30008000 ...
Image Name: linux-2.6.30
Created: 2012-03-03 16:18:05 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1.8 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
Starting kernel ...
Uncompressing Linux.............................................................
............................................................. done, booting the
kernel.
Image Name: linux-2.6.30
Created: Sun Mar 4 00:18:05 2012
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1862.73 kB = 1.82 MB
Load Address: 0x30008000
Entry Point: 0x30008040
root@www.linuxidc.com:~/桌面#
Linux引导时的输出
*******************
czu2440 # tftp 0x30008000 zImage.img
TFTP from server 192.168.1.1; our IP address is 192.168.1.5
Filename 'zImage.img'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
done
Bytes transferred = 1907504 (1d1b30 hex)
czu2440 # bootm 0x30008000
## Booting image at 30008000 ...
Image Name: linux-2.6.30
Created: 2012-03-03 16:18:05 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1.8 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
Starting kernel ...
Uncompressing Linux.............................................................
............................................................. done, booting the
kernel.
3.3 -a参数与-e参数不同,下载地址和-a参数后面的地址不同(无法引导)
czu2440 # tftp 0x30009000 zImage.img
TFTP from server 192.168.1.1; our IP address is 192.168.1.5
Filename 'zImage.img'.
Load address: 0x30009000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
done
Bytes transferred = 1907504 (1d1b30 hex)
czu2440 # bootm 0x30009000
## Booting image at 0x30009000 ...
Image Name: linux-2.6.30
Created: 2012-03-03 16:18:05 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1.8 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
OK
Starting kernel ...
=============================================================
TFTP from server 192.168.1.1; our IP address is 192.168.1.5
Filename 'zImage.img'.
Load address: 0x30000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
done
Bytes transferred = 1907504 (1d1b30 hex)
czu2440 # bootm 0x30000000
## Booting image at 30000000 ...
Image Name: linux-2.6.30
Created: 2012-03-03 16:18:05 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1.8 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
OK
Starting kernel ...
TFTP from server 192.168.1.1; our IP address is 192.168.1.5
Filename 'zImage.img'.
Load address: 0x30009000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
done
Bytes transferred = 1907504 (1d1b30 hex)
czu2440 # bootm 0x30009000
## Booting image at 0x30009000 ...
Image Name: linux-2.6.30
Created: 2012-03-03 16:18:05 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1.8 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
OK
Starting kernel ...
=============================================================
3.4 覆盖了U-Boot传给内核的参数,会导致这样情形(无法引导)
czu2440 # tftp 0x30000000 zImage.imgTFTP from server 192.168.1.1; our IP address is 192.168.1.5
Filename 'zImage.img'.
Load address: 0x30000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################
done
Bytes transferred = 1907504 (1d1b30 hex)
czu2440 # bootm 0x30000000
## Booting image at 30000000 ...
Image Name: linux-2.6.30
Created: 2012-03-03 16:18:05 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1907440 Bytes = 1.8 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
OK
Starting kernel ...
