AM335x uboot spl分析.doc

上传人:博****1 文档编号:560306373 上传时间:2023-04-09 格式:DOC 页数:5 大小:53KB
返回 下载 相关 举报
AM335x uboot spl分析.doc_第1页
第1页 / 共5页
AM335x uboot spl分析.doc_第2页
第2页 / 共5页
AM335x uboot spl分析.doc_第3页
第3页 / 共5页
AM335x uboot spl分析.doc_第4页
第4页 / 共5页
AM335x uboot spl分析.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《AM335x uboot spl分析.doc》由会员分享,可在线阅读,更多相关《AM335x uboot spl分析.doc(5页珍藏版)》请在金锄头文库上搜索。

1、AM335x uboot spl分析芯片到uboot启动流程ROM SPL uboot.img简介在335x 中ROM code是第一级的bootlader。mpu上电后将会自动执行这里的代码,完成部分初始化和引导第二级的bootlader,第二级的bootlader引导第三级bootader,在ti官方上对于第二级和第三级的bootlader由uboot提供。SPLTo unify all existing implementations for a secondary program loader (SPL) and to allow simply adding of new implem

2、entations 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 initialization2 UART console initialization3 Clocks and DPLL locking (minimal) 4 SDRAM initialization5 Mux

3、(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/armv7u-boo

4、t-2011.09-psp04.06.00.03/arch/arm/libu-boot-2011.09-psp04.06.00.03/drivers LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds这个为链接脚本二、u-boot-spl.ldsSram 0x402F0400Sdram 0x80000000.bss.TEXT (arch/arm/cpu/armv7/start.o).rodata.data_start 为程序开始_image_copy_end_end三、代码解析_start 为程序开始 (arch/arm/cpu/arm

5、v7/start.S).globl _start 这是在定义u-boot的启动定义入口点,汇编程序的缺省入口是 start标号,用户也可以在连接脚本文件中用ENTRY标志指明其它入口点。.global是GNU ARM汇编的一个伪操作,声明一个符号可被其他文档引用,相当于声明了一个全局变量,.globl和.global相同。该部分为处理器的异常处理向量表。地址范围为0x0000 0000 0x0000 0020,刚好8条指令。为什么是8条指令呢?这里来算一算。首先,一条arm指令为32bit(位),0x0000 0020换算成十进制为25=32B(字节),而32(B) = 4 * 8(B) =

6、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 的值的一个偏移量;而不

7、是一个绝对地址。它的值由汇编器来计算,它是 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执行下面代码_undefine

8、d_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_instruc

9、tion_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 , 作用:插入一个32-bit的数据队列。(与armasm中的DCD功能相同)

10、.balignl 16,0xdeadbeef.align伪操作用于表示对齐方式:通过添加填充字节使当前位置满足一定的对齐方式。接下来是对各个段代码的定义略Rest: (arch/arm/cpu/armv7/start.S)blsave_boot_paramssave_boot_params: (arch/arm/cpu/armv7/ti81xx/lowlevel_init.S)#ifdef CONFIG_SPL_BUILDldrr4, =ti81xx_boot_device /ti81xx_boot_device = BOOT_DEVICE_NAND/启动方式ldrr5, r0, #BOOT_

11、DEVICE_OFFSETandr5, r5, #BOOT_DEVICE_MASKstrr5, r4#endifbxlr回到reset:(arch/arm/cpu/armv7/start.S)/设置cpu的工作模式 设置CPU的状态类型为SVC特权模式mrsr0, cpsrbicr0, r0, #0x1forrr0, r0, #0xd3msrcpsr,r0cpu_init_crit: (arch/arm/cpu/armv7/start.S)movr0, #0 set up for MCRmcrp15, 0, r0, c8, c7, 0 invalidate TLBsmcrp15, 0, r0,

12、 c7, c5, 0 invalidate icachemcrp15, 0, r0, c7, c5, 6 invalidate BP arraymcr p15, 0, r0, c7, c10, 4 DSBmcr p15, 0, r0, c7, c5, 4 ISB/关闭mmu 缓存mrcp15, 0, r0, c1, c0, 0bicr0, r0, #0x00002000 clear bits 13 (-V-)bicr0, r0, #0x00000007 clear bits 2:0 (-CAM)orrr0, r0, #0x00000002 set bit 1 (-A-) Alignorrr0,

13、 r0, #0x00000800 set bit 11 (Z-) BTB#ifdef CONFIG_SYS_ICACHE_OFFbicr0, r0, #0x00001000 clear bit 12 (I) I-cache#elseorrr0, r0, #0x00001000 set bit 12 (I) I-cache#endifmcrp15, 0, r0, c1, c0, 0/调用初始化 函数movip, lr persevere link reg across callbllowlevel_init go setup pll,mux,memorylowlevel_init:(arch/a

14、rm/cpu/armv7/ti81xx/lowlevel.S)/* The link register is saved in ip by start.S */mov r6, ip/* check if we are already running from RAM */ldr r2, _lowlevel_init_TEXT_BASE:.wordCONFIG_SYS_TEXT_BASE/* Load address (RAM) */#define CONFIG_SYS_TEXT_BASE0x80800000SDRAM的前8MB作为spl的bss段然后前64bytes做为u-boot.img的头ldr r3, _TEXT_BASEsub r4, r2, r3sub r0, pc, r4/设置堆栈指针/* require dummy instr or subtract pc by 4 instead im doing stack init */ldr sp, SRAM_STACKmark1:ldr r5, _mark1sub r5, r5, r2 /* bytes between mark1

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号