s5pv210启动流程简析

来源:互联网 发布:unity3d粒子系统教程 编辑:程序博客网 时间:2024/05/01 14:46
手册上关于iROM/iRAM及Bootloader描述如下:
  • The iROM code is placed in internal 64KB ROM. It initializes basic system functions such as clock, stack, and heap.
  • The iROM loads the first boot loader image from a specific booting device to internal 96KB SRAM. The booting device is selected by Operating Mode (OM) pins. According to the secure boot key values, the iROM code may do an integrity check on the first boot loader image.
  • The first boot loader loads the second boot loader then may check the integrity of the second boot loader according the secure boot key values.
  • The second boot loader initializes system clock, UART, and DRAM controller. After initializing DRAM controller, it loads OS image from the booting device to DRAM. According to the secure boot key values, the second boot loader can do an integrity check on the OS image.
  • After the booting completes, the second boot loader jumps to the operating system.

按照芯片手册上的启动分析图及上面的描述,总结启动流程为:
S5PV210上电将iROM(interal ROM)处执行固化的启动代码,它对系统时钟进行初始化,对启动设备进行判断,并从启动设备中复制BL1(最大16KB)到iRAM(0xd002_0000处,其中0xd002_0010之前的16个字节存储的的有BL1的校验信息和BL1尺寸)中,并对BL1进行校验,检验OK转入BL1进行执行;BL1执行完成后,开始执行BL2,BL2加载内核,把OS在SDRAM中运行起来。
BL0,BL1,BL2:
(1)BL0:是指S5PV210的iROM中固化的启动代码
作用:初始化系统时钟,设置看门狗,初始化堆和栈,加载BL1
(2)BL1:是批在iRAM自动从外扩存储器(nand/sd/usb)中拷贝的uboot.bin二进制文件的头最大16K代码
作用:初始化RAM,关闭Cache,设置栈,加载BL2
(3)BL2:是指在代码重定向后在内存中执行的uboot的完整代码
作用:初始化其它外设,加载OS内核
(4)三者之间的关系:(Interal ROM固化代码)BL0将BL1(bootloader的前16KB--BL1)加载到iRAM;BL1然后在iRAM中运行将BL2(剩下的bootloader)加载到SDRAM;BL2加载内核,把OS在SDRAM中运行起来,最终OS是运行在SDRAM(内存)中的。

在这个过程中,u-boot其实严格来说有三段,因为第一段是在iROM中,由三星公司给我们写好了,所以,通常,将片内的bootloader称为BL0,而片外Bootloader,也就是在NAND FLASH中的bootloader,我们称为BL1,BL2。我们片外的u-boot是被分为了两个阶段:
1.第一阶段代码
arch/arm/cpu/armv7/start.S
1).设置异常向量地址
2).设置SVC32模式(ARM七种工作模式)
3).cpu_init_crit
清TLB(页面缓存)、关MMU及Cache等
4).转入低级初始化lowlevel_init
主要是对时钟、片外内存(DDR2)、串口、nand(这里初始化nand主要是为第二阶段搬内核到内存而准备的)等进行初始化
5).判断启动开关进行自搬移
6).跳转到C入口board_init_f( ) 

2.第二阶段代码
1).board_init_f( )
A.gd_t数据结构空间分配
B.回调一组初始化函数
C.对gd_t数据结构进行初始化
D.relocate_code(U-boot重定义代码,即自搬移)
2).board_init_r( )
A.使能Cache
B.板子初始化
C.串口初始化
D.外存初始化
E.环境变量初始化
F.控制台初始化
G.中断使能
H.以太网初始化
I. 进入main_loop(),等待命令或自动加载内核