load_uboot: ldr r0, =INF_REG_BASE ldr r1, [r0, #INF_REG3_OFFSET] //read_om将判断结果放在寄存器INF_REG3_OFFSET cmp r1, #BOOT_MMCSD beq mmcsd_boot cmp r1, #BOOT_EMMC beq emmc_boot cmp r1, #BOOT_EMMC_4_4 beq emmc_boot_4_4 cmp r1, #BOOT_SEC_DEV beq mmcsd_boot
load_uboot函数根据前面read_om获取到的启动信息判断从哪个设备启动,我的板子设为OM[5:1]=10100,第0位接地,所以为0x28=BOOT_EMMC_4_4,从EMMC启动
emmc_boot_4_4: /* read TCBCNT to get Transferred CIU card byte count */ ldr r0, =0x1255005c ldr r1, [r0] ldr r2, =0x6000 cmp r1, r2 //4412所谓的第二启动项应该是根据这里来判断的,r1<r2则代码地址为1,跳转到mmcsd_boot /* store second boot information in DRAM */ ldr r0, =CONFIG_PHY_UBOOT_BASE //_TEXT_BASE sub r0, r0, #8 mov r3, #0 movlo r3, #1 str r3, [r0] /* if transferred CIU card byte count >= 0x6000 (24 KB) */ /* BL1 and BL2 are loaded from emmc 4.4 */ /* Otherwise BL1 and BL2 are loaded from sdmmc ch2. */ blo mmcsd_boot //这里的blo和上面的movlo都是根据cpm r1,r2的结果来确定的,r1<r2则进行相应操作 /* mmc ch4 devider value change */ bl mmc_ch4_devider_change mov r0, #EMMC_4_4 str r0, _boot_device bl load_uboot_image b cold_boot b after_copy进入emmc_boot_4_4后,还要根据TCBCNT寄存器的值判断是执行第一还是第二启动项,如果寄存器的值小于0x6000,则执行第二启动项,从sd卡启动,这里我们选择从emmc启动。确定启动项后,_boot_device作为参数传入到c函数load_uboot_image和cold_boot中(smc.c),据网上的大神说这两个函数将uboot从emmc拷贝到SDRAM,但我跟进去怎么看都理解不了是怎么实现的,如果有知道的希望能指点一二 ???拷贝uboot进入after_copy函数
after_copy: bl uart_asm_init /* set up C2C */ ldr r0, =S5PV310_SYSREG_BASE ldr r2, =GENERAL_CTRL_C2C_OFFSET ldr r1, [r0, r2] ldr r3, =0x4000 orr r1, r1, r3 str r1, [r0, r2] #ifdef CONFIG_ENABLE_MMU bl enable_mmu #endif /* store second boot information in u-boot C level variable */ ldr r0, =CONFIG_PHY_UBOOT_BASE sub r0, r0, #8 ldr r1, [r0] //将CONFIG_PHY_UBOOT_BASE-8处的数据保存到r1 ldr r0, _second_boot_info //将_second_boot_info的值,即second_boot_info地址给r0 str r1, [r0] //将CONFIG_PHY_UBOOT_BASE-8处的数据保存到内存second_boot_info处 /* Print 'K' */ ldr r0, =S5PV310_UART_CONSOLE_BASE ldr r1, =0x4b4b4b4b str r1, [r0, #UTXH_OFFSET] ldr r0, _board_init_f mov pc, r0 //执行board.c中board_init_f函数after_copy初始化串口,设置C2C最终进入board_init_f执行板级初始化。