u-boot for s5pv210

所需积分/C币:19 2015-08-29 14:33:20 1008KB PDF
收藏 收藏
举报

uboot 移植步骤详解,基于s5pv210
程序流程分析 程序从 Start.s开始运行 dlobl reset reset bI save boot params ENTRY(Save boot params) bx Ir a back to my caller eNdPROC(save boot params) wcak save boot params save boot params是以weak属性定义的, save boot params没有另外定义,那么这里的定义 有效,但是什么都没做,这是预留修改的。 继续走 #ifndef CONFIG SKIP LOWLEVEL INIT bI cpu init cp15 bI cpu init 计 cdif nain cpu mt crIt其实是调用 low level init,该函数有2个地方:变量 lowlevel init. S(arch\arm cpularmvT) lowlevel init. s (board\sam sungsm dkc100) 到底运行哪个呢?看对应日录下的 makefile: arch\arm\cpu\armv7下的 makefile S(CONFIG AM43XX)S( CONFIG AM33XX)S(CONFIG OMAP44XX)S(CONFIG OMAP54 XX)S(CONFIG TEGRAJS(CONFIG MX6)S(CONFIG TI81XX)S(CONFIG AT91F AMILYSCC ONFIG SUNXD),) ifneq(S(CONFIG SKIP LOWLEVEL INIT), y) low level init. o if ndif 明显,我们没有定义那一堆变量中的任意一个,所以这个不会被编译。 boardisamsungismdkc100中的 makefile low level init. o 实际编译后确实这这个文什夹下出现了 low level init.o,就是它。 看 low level init: movr9. Ir /*r5 has alw ays zero * moⅴr5,#0 ldr r8.=S5PC100 GPIO BASE / Disable Watchdog Idr rO=S5PC100 WATCHDOG BASE OxFA200000 orr rOrO.#OxO str r /*setting SRAM$/ Idr rO=S5PC100 SROMC BASE Idr rl=0x9 str rl, [ro / S5PC100 has 3 groups of interrupt sources*/ ldr rO=S5PC100 VICO BASE 0xF4000000 Idr rl=S5PC100 VICI BASE (aOxE4000000 Idr r2=S5PC100 VIC2 BASE 0xE400000 /* Disable all interrupts(ⅥC0,Ⅵ Cl andⅥC2)* mvnr3.#0x0 strr3,[r0,#(0x14 aINTENCLEAR strr3,[r1,#0x14 OINTENCLEAR strr3,[r2,#(0x14 aINTENCLEAR /* Set all interrupts as IRQ/ str r5,rO, #Oxc CINTSELECT str r5,[rl, #Oxc aINTSELECT str r5,r2, #Oxc INTSELECT / Pending interrupt Clear s srr5,[r0,#0x00 aINTADDRESS str r5, [rl, #Oxfoo aINTADDRESS str r5, r2, #Oxton CaINTAddrEsS /* for uart * bl uart asm init /* Tor tzpc a bl tzpc asm init moy Ir. ro mov pc, Ir 这都是初始化, uart asm nit, tzpc asm nit,之后返回 start. S执行 bI main main位于 archarmlibcrto.s中,crto.s是C运行环境的启动代码,其实就是设置栈指针而。 crto-C-runtime startup Codc for ARM U-Boot ENTRY( main) Set up initial C runtime environment and call board init f(O) fif defined( CONFIG SPL builD)&& defined(CONFIG SPL STACK) ldr sp, =(CONFIG SPL STACK) 开else ldr sp,=(CONFIG SYS INIT SP ADDR) 并 cdif bic sp, sp, #7/*8-byte alignment for ABI compliance sub sp, sp, HGD SIZE /*allocate one GD above SP s/ bic sp, sp, #7/*8-byte algnment for ABl compliance movr9, sp * GD is above SP*这个全局变量 movr0.#0 board init t fif defined(CONFIG SPL BUILD) Set up intermediate environment (new sp and gd)and call relocate code(addr moni). Trick here is that we'll return 米'here' but relocated ldr sp, [r9, #GD START ADDR SP]/*sp=gd->s Lart addr sp bic sp, sp, 7/ 8-byte alignment for abi compliance * ldr r9, [r9, #GD BD /r9=gd->bd*/ sub r9.r9. #GD SIZE / new gd is below bd =/ adr Ir. here ldr ro, [r9, #GD RELOC OFF /ro=gd->reloc off*/ add Ir. Ir. rO ldr rO, [r9, #GD relOCAddr /*r0-gd->relocaddr */ b relocate code ere /* Set up final (full)environment * bl c runtime cpu setup / we still call old routine here * ldr rO= bss start / this is auto-rclocatcd! k bss end s this is auto-relocated! */ mowr2、#0x00000000 prepare zero to clear BSS * clbss L: cmp rO, rl / while not at end of bss */ stro r2, [ro /* clear 32-bit bss word *e/ ddlo rOrO.#4 /R move to next * blo clbs bI coloured led init bl red led on /*call board nit r(gd t*id, ulong dest addr ) mov ldr rl, r9, #GD RELOCADDR/dest addr */ k call board init r * ldr pC, =board init r /*this is auto-relocated! * /* we should not return here. Wendi ENDPROC( main 因为定义了 CONFIG SPL BUILD所以不会4! delined( CONFIG SPL BUILD)后面的代码 不会被编译 代码中调用了 board init,有3个位置,分别是: Board.c( archarm\lib), Board f.c( common), Spl. c(arch\arm lib 根据 makefile我们可以判断 board init f应该位于Splc( arch lib)中 s In the context of SPl, board init f must ensure that any clocks/etc for DDR are enabled, ensure that the stack pointer is valid, clear the BSs and call board init f. We provide this version by default but mark it as weak to allow for platforms to do this in their own way if needed void weak board init f(ulong dummy) / Clear the bss. memset( bss start, 0, bss end- bss starL); , Set global data pointer. gd=&gdata board init r(NULL, 0) *这段蓝色文字搞错了,分析的是 board. c的 board init f函数,不用看,* 开头定义了两个结构体变量:bdt*bd Bdt类型存储板子信息,gdt即 global data结构体类型,在 include\asm-generic中定义。 以下宏没有定义,所以相应位置的代码不会执行 CONFIG PRAM CONFIG OF EMBED、 CONFIG OF SEPARATE、 CONFIG OF CONTROL、 CONFIG SYS MEM TOP HIDE、 CONFIG LOGBUFFER、 CONFIG ALT LB ADDR CONFIG SYS ICACHE OFF、 CONFIG SYS DCACHE OFF、 CONFIG LCD、 CONFIG FB ADDR CONFIG MACH TYPE、 CONFIG USE IRO、 CONFIG POST board init f主要作用就是配置bd和i,因为 CONFIG SPL BUILI已经定义,故后面的代 码不会执行了,man函数已经跑完,返回。 这里执行gd=& gdata就是把 gdata的指针地址赋给gd。 id在哪里定义呢?百度后可知gd是由 DECLARE GLOBAL DATA PTR定义的。搜索 DECLARE GLOBAL DATA PTR,找到 Global data. h( archarm inc lude\asm)文件,其中有 如下定义: #define DEClarE GLOBaL DATA Ptr register volatile gd t gd asm(r9) 在 Smoke100c( board samsung smdkc100中,有 DECLARE GLOBAL DATA PTR定义 DECLARE GLOBAL._ DATA PTR的含义:声明结构体gdt类型的指针变量gd,该指针变 量的地址存储在寄存器r8中 接下来执行 board init r(nul0)。 board init r board in it r的意思是ram中初始化,因为我们已绎设置好了栈指针,所以可以运行C代码 board init r位于Splc( common\spl中。先把Splc( common\ sp)的人部分代码贴出来 void board init r(gd t *dummy l, ulong dummy 2 u132 boot device debug(">>spl board init rOin); #indef CONFIG SYS SPL MALLOC STaRt mem malloc init(CONFIG SYS SPL MALLOC StaRt, CONFIG SYS SPL MALLOC SIZE fendi #inder CoNFIg PPC timer init( does not exist on PPC systems. The timer is initialized w and enabled (decrementer) in interrupt initO here timer init(; Hendel #ifdef CONFIG SPL BOARD INIT spl board inito 开 endif boot devicc=spl boot dcvicco debug("boot device-%d\n", boot device switch(boot device)& #ifdef CONFIG SPL RAM DEVICE case boot dEVIce ram spl ram load imago Wendi #ifdef CONFIG SPL MMC SUPPORT case boot deVice mmcl case boot device mmc2 case boot dEVice mmc2 2 spl mmc load image Wendi #ifdef CONFIG SPL NAND SUPPORT case Boot dEVice nand: spI nand load image; break. Wendi #ifdef CONFIG SPL ONENAND SUPPORT case boot DEVICE onenand spl onenand load image break. #endif #ifdef CONFIG SPL NOR SUPPORT case boot DEVIcE nor spl nor load imago break #endif #ifdef CONFIG SPL YMODEM SUPPORT case boot DEVICE uart spl ymodem load imago) break. 开 cdif #ifdef CONFIG SPL SPI SUPPOrt case boot deVice spl spl spi load imagc(; 计 cdif #ifdef CONFIG SPL ETH SUPPORT case boot deVice cPgmac: #ifdef CONFIG SPL ETH DEVICE spl net load image( CONFIG SPL ETH DE VICE); 并clsc spl net load image(NULL) #endif break. #endif #ifdcf CONFIG SPL USBETH SUPPORT case bOot DEVIce usbeth. spl net load image(usb ether); break #endif #ifdef CONFIG SPL USB SUPPORT case boot device usB spl usb load image break Wendi #ifdef CONFIG SPL SATA SUPpORt case BooT DEVICE sata spl sata load image break. Wendi default debug(SPL: Un-Supported Boot Device\n") hango switch(spl image. os)i case Ih os u boot debug(Jumping to U-Boot n) break #ifdef CONFIg SPL OS boot case Ih os linux. debug("jumping to Linux n") spl board prepare for linux jump to image linux((void *)CONFIG SYS SPL ARGS ADDR); 开 cdif debug("Unsupported os image. Jumping nevertheless. \ n") jump lo image no args(&spl image) s This requires UArT clocks to be enabled. In order for this to work the caller must ensure that the gd pointer is valid void preloader console init( void) gd->bd=&bdata gd- >baudrate= CONFIG BAUDRATE g serial init(; /serial communications setup gd->have console=1 puts("nU-Boot SPL"PLAIN VERSION " ("U BOOT DATE U BOOT TIME )n"); #ifdef CONFIG SPL DISPLAY PRINT spl display printo Wendi 以下宏我们没有定义,对应代码可以忽略: CONFIG SYS SPL MALLOC START CONFIG PPC CONFIG SPL BOARD INIT 这里执行 boot device= spl boot device(), spl boot device(需要我们自己实现,其实只需要 返回启动设备的类型,从SD卡启动 Uboot,则直接改为 boot device BOOT DEVICE MMCI 接下来就执行 spl xXX load image→ Jump to Image no args(& cspl image),加载Ubot,跳 转到DDR中启动 Uboot 小技巧: 其实SPL编译了哪些文件,可以先执行 makc spl-bot- spl. bin命令编译spl,将 uboot下的 spl文件夹(编译后才有哦)拷贝到 windows系统中,执行 tree -F命令,即可得知。 smdkc I00-spl bin u-boot-spI

...展开详情
试读 34P u-boot for s5pv210
立即下载 低至0.43元/次 身份认证VIP会员低至7折
抢沙发
一个资源只可评论一次,评论内容不能少于5个字
  • 分享宗师

    成功上传21个资源即可获取
关注 私信 TA的资源
上传资源赚积分or赚钱
最新推荐
u-boot for s5pv210 19积分/C币 立即下载
1/34
u-boot for s5pv210第1页
u-boot for s5pv210第2页
u-boot for s5pv210第3页
u-boot for s5pv210第4页
u-boot for s5pv210第5页
u-boot for s5pv210第6页
u-boot for s5pv210第7页

试读结束, 可继续读4页

19积分/C币 立即下载 >