Am335x u-boot 程式碼大概流程(轉) Am335x u-boot 程式碼大概流程
阿新 • • 發佈:2018-12-26
Am335x u-boot 程式碼大概流程
在_面之前的流程和u-boot-spl一樣,區別在於_main中。
對於u-boot 2016.03來說
ENTRY(_main) /* * Set up initial C runtime environment and call board_init_f(0). */ ldr sp, =(CONFIG_SYS_INIT_SP_ADDR) bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ #endif mov r0, sp bl board_init_f_alloc_reserve mov sp, r0 /* set up gd here, outside any C code */ mov r9, r0 bl board_init_f_init_reserve mov r0, #0 bl board_init_f ldr sp, [r9, #GD_START_ADDR_SP] /* sp = gd->start_addr_sp */ bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ #endif ldr r9, [r9, #GD_BD] /* r9 = gd->bd */ sub r9, r9, #GD_SIZE /* new GD is below bd */ adr lr, here ldr r0, [r9, #GD_RELOC_OFF] /* r0 = gd->reloc_off */ add lr, lr, r0 ldr r0, [r9, #GD_RELOCADDR] /* r0 = gd->relocaddr */ b relocate_code here: /* * now relocate vectors */ bl relocate_vectors /* Set up final (full) environment */ bl c_runtime_cpu_setup /* we still call old routine here */ ldr r0, =__bss_start /* this is auto-relocated! */ ldr r3, =__bss_end /* this is auto-relocated! */ mov r1, #0x00000000 /* prepare zero to clear BSS */ subs r2, r3, r0 /* r2 = memset len */ bl memset /* call board_init_r(gd_t *id, ulong dest_addr) */ mov r0, r9 /* gd_t */ ldr r1, [r9, #GD_RELOCADDR] /* dest_addr */ /* call board_init_r */ ldr pc, =board_init_r /* this is auto-relocated! */ /* we should not return here. */ #endif ENDPROC(_main)
對於函式board_init_f (u-boot-2016.03/common/board_f.c)
1 、計算u-boot映象的長度 2、記憶體池的設定 3、控制檯log快取 4、CPU的特殊初始化 5、初始化定時器 ..../arch/arm/cpu/armv7/omap-common/timer.c 6、環境變數初始化 7、a、波特路初始化 b、串列埠初始化 .../driver/serival/serival-unclass.c c、控制檯初始化 // 可放在板級初始化board_init_f(spl)內,方便除錯用 8、列印相關選擇項 9、列印CPU資訊---speed 10、 a、說明要初始化的dram ../arch/arm/cpu/armv7/am33xx/emif4.c b、對relcoate 區域規劃 c、relcoate 之後 gd成員設定 11、define選擇,如果定義了硬體 I2C、SPI,對其進行初始化 u-boot-2016.03/common/board_f.c
對於函式board_init_f (u-boot-2016.03/common/board_r.c)
具體參看此博文
http://www.cnblogs.com/leaven/p/6296428.html
在_面之前的流程和u-boot-spl一樣,區別在於_main中。
對於u-boot 2016.03來說
ENTRY(_main) /* * Set up initial C runtime environment and call board_init_f(0). */ ldr sp, =(CONFIG_SYS_INIT_SP_ADDR) bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ #endif mov r0, sp bl board_init_f_alloc_reserve mov sp, r0 /* set up gd here, outside any C code */ mov r9, r0 bl board_init_f_init_reserve mov r0, #0 bl board_init_f ldr sp, [r9, #GD_START_ADDR_SP] /* sp = gd->start_addr_sp */ bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ #endif ldr r9, [r9, #GD_BD] /* r9 = gd->bd */ sub r9, r9, #GD_SIZE /* new GD is below bd */ adr lr, here ldr r0, [r9, #GD_RELOC_OFF] /* r0 = gd->reloc_off */ add lr, lr, r0 ldr r0, [r9, #GD_RELOCADDR] /* r0 = gd->relocaddr */ b relocate_code here: /* * now relocate vectors */ bl relocate_vectors /* Set up final (full) environment */ bl c_runtime_cpu_setup /* we still call old routine here */ ldr r0, =__bss_start /* this is auto-relocated! */ ldr r3, =__bss_end /* this is auto-relocated! */ mov r1, #0x00000000 /* prepare zero to clear BSS */ subs r2, r3, r0 /* r2 = memset len */ bl memset /* call board_init_r(gd_t *id, ulong dest_addr) */ mov r0, r9 /* gd_t */ ldr r1, [r9, #GD_RELOCADDR] /* dest_addr */ /* call board_init_r */ ldr pc, =board_init_r /* this is auto-relocated! */ /* we should not return here. */ #endif ENDPROC(_main)
對於函式board_init_f (u-boot-2016.03/common/board_f.c)
1 、計算u-boot映象的長度 2、記憶體池的設定 3、控制檯log快取 4、CPU的特殊初始化 5、初始化定時器 ..../arch/arm/cpu/armv7/omap-common/timer.c 6、環境變數初始化 7、a、波特路初始化 b、串列埠初始化 .../driver/serival/serival-unclass.c c、控制檯初始化 // 可放在板級初始化board_init_f(spl)內,方便除錯用 8、列印相關選擇項 9、列印CPU資訊---speed 10、 a、說明要初始化的dram ../arch/arm/cpu/armv7/am33xx/emif4.c b、對relcoate 區域規劃 c、relcoate 之後 gd成員設定 11、define選擇,如果定義了硬體 I2C、SPI,對其進行初始化 u-boot-2016.03/common/board_f.c
對於函式board_init_f (u-boot-2016.03/common/board_r.c)
具體參看此博文