uboot启动成功,下一步就是启动内核,使用官方提供的内核镜像进行启动。4.2.7.4
首先了解可引导启动的内核类型镜像有两种,uImage和zImage,这两种镜像是由可直接运行的镜像文件压缩而来的
zImage | Image(可直接运行的镜像) -----压缩----->zImage |
uImage | zImage -----uboot工具mkimage加工----->uImage |
当前使用的uboot同时支持启动这两种镜像。
uboot命令行下输入printenv打印环境变量,其中一条是
bootcmd=movi read kernel 30008000; movi read rootfs 30B00000 300000; bootm 30008000 30B00000
mtdpart=80000 400000 3000000
作用是复制内核、rootfs到DDR中,然后启动。
第一步、复制内核
movi read kernel 30008000,这条命令具体是如何实现的,他是如何找到kernel是在emmc还是在sd呢?查看代码cmd_movi.c。
if (strcmp(argv[2], "kernel") == 0) {
if (movi_emmc == 1) { /* eMMC_4.3 */
printf("eMMC Reading kernel from sector %d (%d sectors).. ", ofsinfo.kernel, EMMC_KERNEL_BLKCNT);
emmc_read((uint) addr, ofsinfo.kernel, EMMC_KERNEL_BLKCNT);
} else {
printf("Reading kernel from sector %d (%d sectors).. ", ofsinfo.kernel, MOVI_ZIMAGE_BLKCNT);
movi_read((uint) addr, ofsinfo.kernel, MOVI_ZIMAGE_BLKCNT);
}
可看出当要读取的内容是kernel时,会判断movi_emmc的值,那么查看这个值的源头
//没查到值的定义,只在board.c中有对movi_emmc的赋值
if (INF_REG3_REG == 1) { /* eMMC_4.3 */
puts("eMMC: ");
movi_ch = 1;
movi_emmc = 1;
movi_init();
movi_set_ofs(0);
}
#define INF_REG3_REG __REG(INF_REG_BASE+INF_REG3_OFFSET)
#define INF_REG_BASE 0xE010F000
#define INF_REG3_OFFSET 0x0c
查找手册此地址对应的含义
0xE010F00C查找手册此地址对应的含义如下图, 是用户自由定义的寄存器
最后在start.s中找到
ldr r0, =INF_REG_BASE
str r3, [r0, #INF_REG3_OFFSET] //r3的值被存到了寄存器中
那么r3的值是什么呢?
是由硬件拨码开关决定的,5位的拨码开关值赋给了r2的bit1-bit5,r2其余位被清零。然后通过对比r2的值为r3赋值
ldr r0, =PRO_ID_BASE
ldr r1, [r0,#OMR_OFFSET]
bic r2, r1, #0xffffffc1
/* NAND BOOT */
cmp r2, #0x0 @ 512B 4-cycle
moveq r3, #BOOT_NAND @0x2
cmp r2, #0x2 @ 2KB 5-cycle
moveq r3, #BOOT_NAND
cmp r2, #0x4 @ 4KB 5-cycle 8-bit ECC
moveq r3, #BOOT_NAND
cmp r2, #0x6 @ 4KB 5-cycle 16-bit ECC
moveq r3, #BOOT_NAND
cmp r2, #0x8 @ OneNAND Mux
moveq r3, #BOOT_ONENAND @//0x1
/* SD/MMC BOOT */
cmp r2, #0xc
moveq r3, #BOOT_MMCSD @//0x3
/* NOR BOOT */
cmp r2, #0x14
moveq r3, #BOOT_NOR
设置OM[5:0] = 001101,则r2值为0xc,r3被赋值0x3,从IROM、SD/MMC启动。
启动信息
OK
U-Boot 1.3.4 (Aug 7 2013 - 14:53:08) for x210
CPU: S5PV210@1000MHz(OK)
APLL = 1000MHz, HclkMsys = 200MHz, PclkMsys = 100MHz
MPLL = 667MHz, EPLL = 96MHz
HclkDsys = 166MHz, PclkDsys = 83MHz
HclkPsys = 133MHz, PclkPsys = 66MHz
SCLKA2M = 200MHz
Serial = CLKUART
Board: X210
DRAM: 512 MB
Flash: 8 MB
SD/MMC: 3800MB
In: serial
Out: serial
Err: serial
[LEFT UP] boot mode
checking mode for fastboot ...
Hit any key to stop autoboot: 0
reading kernel.. 1073, 8192
MMC read: dev # 0, block # 1073, count 8192 ...8192 blocks read: OK
completed
reading RFS.. 9265, 6144
MMC read: dev # 0, block # 9265, count 6144 ...6144 blocks read: OK
completed
Boot with zImage
get_format
-------- 0 --------
Wrong Ramdisk Image Format
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 2.6.35.7+ (lqm@9tripod-server) (gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #38 PREEMPT Wed Aug 14 09:25:49 CST 2013
[ 0.000000] CPU: ARMv7 Processor [412fc082] revision 2 (ARMv7), cr=10c53c7f
[ 0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[ 0.000000] Machine: SMDKV210