网上看了后,做了个记录,主要是一个流程,具体代码没有分析,有空再细看。
cpu在上电之后,它们会干些什么?
答:检查电压大小,确定启动模式等。
简单的检查之后呢?
答:一般从固化在cpu内部的rom里面执行一小段code。这一小段code具体做了些什么呢?各个cpu厂商会不同,具体我也不知道。
但是我们应该知道,这小段code必须完成确认启动模式,并初始化启动设备,搬移烧录在启动设备里面的代码到ddr里面。
ok,搬移了代码后,cpu如何识别代码?将doc,txt文件烧进去行么?
答:当然不行,烧录的文件也是有格式要求的。
格式在哪里定呢?稍等,先要知道生成的uboot.bin文件需要有个指导文件,就是uboot.lds,它的作用是在编译过程中,决定各个可执行程序段的位置。
其代码如下:
1 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 2 OUTPUT_ARCH(arm) 3 ENTRY(_start) 4 SECTIONS 5 { 6 . = 0x00000000; 7 8 . = ALIGN(4); 9 .text : 10 { 11 /* WARNING - the following is hand-optimized to fit within */ 12 /* the sector layout of our flash chips! XXX FIXME XXX */ 13 board/freescale/mx6q_sabreauto/flash_header.o (.text.flasheader) 14 cpu/arm_cortexa8/start.o 15 board/freescale/mx6q_sabreauto/libmx6q_sabreauto.a (.text) 16 lib_arm/libarm.a (.text) 17 net/libnet.a (.text) 18 drivers/mtd/libmtd.a (.text) 19 drivers/mmc/libmmc.a (.text) 20 21 . = DEFINED(env_offset) ? env_offset : .; 22 common/env_embedded.o(.text) 23 24 *(.text) 25 } 26 27 . = ALIGN(4); 28 .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } 29 30 . = ALIGN(4); 31 .data : { *(.data) } 32 33 . = ALIGN(4); 34 .got : { *(.got) } 35 36 . = .; 37 __u_boot_cmd_start = .; 38 .u_boot_cmd : { *(.u_boot_cmd) } 39 __u_boot_cmd_end = .; 40 41 . = ALIGN(4); 42 _end_of_copy = .; /* end_of ROM copy code here */ 43 __bss_start = .; 44 .bss : { *(.bss) } 45 _end = .; 46 }