No.64097 作者:nideth 邮件:137728220@qq.com ID:131205 登陆:7次 文章数:7篇 最后登陆IP:125.69.9.179 最后登陆:2014/8/14 13:28:58 注册:2012/7/16 21:51:57 财富:125 发帖时间:2012/9/5 22:23:49 发贴者IP:123.138.42.197 标题:nideth:AM335x uboot spl分析 摘要:No.64097AM335x uboot spl分析 AM335x uboot spl分析 芯片到uboot启动流程 ROM → SPL→ uboot.img 简介 在335x 中ROM code是第一级的bootlader。mpu上电后将会自动执行这里的代码,完成部分初始化和引导第二级的bootlader,第二级的bootlader引导第三级bootader,在ti官方上对于第二级和第三级的bootlader由uboot提供。 SPL To unify all existing implementations for a secondary program loader (SPL) and to allow simply adding of new implementations this generic SPL framework has been created. With this framework almost all source files for a board can be reused. No code duplication or symlinking is necessary anymore. 1> Basic ARM initialization 2> UART console initialization 3> Clocks and DPLL locking (minimal) 4> SDRAM initialization 5> Mux (minimal) 6> BootDevice initialization(based on where we are booting from.MMC1/MMC2/Nand/Onenand) 7> Bootloading real u-boot from the BootDevice and passing control to it. uboot spl源代码分析 一、makefile分析 打开spl文件夹只有一个makefile 可见spl都是复用uboot原先的代码。 主要涉及的代码文件为u-boot-2011.09-psp04.06.00.03/arch/arm/cpu/armv7 u-boot-2011.09-psp04.06.00.03/arch/arm/lib u-boot-2011.09-psp04.06.00.03/drivers LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds 这个为链接脚本 二、u-boot-spl.lds Sram 0x402F0400 Sdram 0x80000000 .bss .TEXT (arch/arm/cpu/armv7/start.o) .rodata .data __start 为程序开始 __image_copy_end _end 三、代码解析 __start 为程序开始 (arch/arm/cpu/armv7/start.S) .globl _start 这是在定义u-boot的启动定义入口点,汇编程序的缺省入口是 start标号,用户也可以在连接脚本文件中用ENTRY标志指明其它入口点。 .global是GNU ARM汇编的一个伪操作,声明一个符号可被其他文档引用,相当于声明了一个全局变量,.globl和.global相同。该部分为处理器的异常处理向量表。地址范围为0x0000 0000 ~ 0x0000 0020,刚好8条指令。 为什么是8条指令呢?这里来算一算。首先,一条arm指令为32bit(位),0x0000 0020换算成十进制为2^5=32B(字节),而32(B) = 4 * 8(B) = 4 * 8 * 8( bit),所以刚好8条指令(一个字节Byte包含8个位bit)。 下面是在汇编程序种经常会遇到的异常向量表。Arm处理器一般包括复位、未定义指令、SWI、预取终止、数据终止、IRQ、FIQ等异常,其中U-Boot中关于异常向量的定义如下: _start: b reset _start 标号表明 oot程序从这里开始执行。 b是不带返回的跳转(bl是带返回的跳转),意思是无条件直接跳转到reset标号出执行程序。b是最简单的分支,一旦遇到一个 b 指令,ARM 处理器将立即跳转到给定的地址,从那里继续执行。注意存储在分支指令中的实际的值是相对当前的 R15 的值的一个偏移量;而不是一个绝对地址。它的值由汇编器来计算,它是 24 位有符号数,左移两位后有符号扩展为 32 位,表示的有效偏移为 26 位。 ldr pc, _undefined_instr tion //未定义指令 ldr pc, _software_interrupt //软中断SWI ldr pc, _prefetch_abort //预取终止 ldr pc, _data_abort //数访问终止 ldr pc, _not_used ldr pc, _irq //中断请求IRQ ldr pc, _fiq //快速中断FIQ #ifdef CONFIG_SPL_BUILD //该阶段为spl执行下面代码 _undefined_instruction: .word _undefined_instruction _software_interrupt: .word _software_interrupt _prefetch_abort: .word _prefetch_abort _data_abort: .word _data_abort _not_used: .word _not_used _irq: .word _irq _fiq: .word _fiq _pad: .word 0x12345678 /* now 16*4=64 */ #else _undefined_instruction: .word undefined_instruction _software_interrupt: .word software_interrupt _prefetch_abort: .word prefetch_abort _data_abort: .word data_abort _not_used: .word not_used _irq: .word irq _fiq: .word fiq _pad: .word 0x12345678 /* now 16*4=64 */ #endif /* CONFIG_SPL_BUILD */ .word为ARM汇编特有的伪操作符,语法如下: .word <word1> {, <word2> } … 作用:插入一个32-bit的数据队列。(与armasm中的DCD功能相同) .balignl 16,0xdeadbeef .align伪操作用于表示对齐方式:通过添加填充字节使当前位置满足一定的对齐方式。 接下来是对各个段代码的定义 略 Rest: (arch/arm/cpu/armv7/start.S) bl save_boot_params save_boot_params: (arch/arm/cpu/armv7/ti81xx/lowlevel_init.S) #ifdef CONFIG_SPL_BUILD ldr r4, =ti81xx_boot_device ......
>>返回讨论的主题
|