Chinaunix首页 | 论坛 | 博客
  • 博客访问: 931937
  • 博文数量: 104
  • 博客积分: 1919
  • 博客等级: 上尉
  • 技术积分: 1910
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-21 16:33
文章分类
文章存档

2016年(4)

2015年(1)

2014年(6)

2013年(16)

2012年(27)

2011年(49)

2010年(1)

分类: LINUX

2013-10-14 23:08:24

uboot版本:uboot 1.3.1(st已做过修改)

st平台的内存首地址是0x80000000,此地址不是固定的,不同类型的芯片是不同的,比如samsung的arm920t是0x30000000。uboot提供两种工作模式:一是启动加载模式(start loading),一是下载模式(downloading)。工作在启动加载模式时,uboot会自动执行bootcmd命令,比如:bootcmd=“nand read 0x100000 0x80000000 0x300000; bootm 0x80000000”

1、uboot首先把内核镜像拷贝到内存地址为0x80000000的地方,然后执行bootm 0x80000000命令

bootm命令来自 common/cmd_bootm.c文件,完成的功能有

》CRC校验image head struct的64个字节的正确性

》根据镜像头中指定的压缩类型(比如gzip),把kernel解压到指定的位置hdr->ih_load(0x80800000)

》调用来自lib_sh/sh_linux.c中的函数do_bootm_linux( . . . ),启动内核

 

2、接下来,分析do_bootm_linux函数的执行流程

传给kernel的命令行参数地址是宏定义 #define COMMAND_LINE ((char *)(param+0x100))

do_bootm_linux

{

》从参数去中获取环境变量bootargs的值

char *commandline = getenv("bootargs");

》从image head struct中获取kernel的入口地址

void (*theKernel)(void); // 函数指针

theKernel = (void (*) (void)) ntohl (hdr->ih_ep);

》从image head struct中获取kernel的指定存储参数的地址

ulong param;

param = ntohl (hdr->ih_load);

》把commandline拷贝到约定好的COMMAND_LINE地址

strcpy (COMMAND_LINE, commandline);

 

》最后,执行kernel的入口函数,把控制权交给kernel

/* now, finally, we pass control to the kernel  itself ... */

theKernel();

}

 

3、uboot加载kernel后内存使用情况



转自:http://blog.chinaunix.net/uid-25581264-id-3452445.html

阅读(3456) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~