您的位置:首页 > 其它

[IMX6Q]为什么定义了CONFIG_SKIP_RELOCATE_UBOOT

2016-01-06 09:26 369 查看
u-boot版本: v2009.08

u-boot启动一般的流程是cpu会将u-boot的前面4k代码copy到内部ram执行,

然后u-boot运行起来后将自己copy到ddr中,这个动作是在

uboot-imx/cpu/arm_cortexa8/start.S中:

#ifndef CONFIG_SKIP_RELOCATE_UBOOT
relocate:				@ relocate U-Boot to RAM
adr	r0, _start		@ r0 <- current position of code
ldr	r1, _TEXT_BASE		@ test if we run from flash or RAM
cmp	r0, r1			@ don't reloc during debug
beq	stack_setup

ldr	r2, _armboot_start
ldr	r3, _bss_start
sub	r2, r3, r2		@ r2 <- size of armboot
add	r2, r0, r2		@ r2 <- source end address

copy_loop:				@ copy 32 bytes at a time
ldmia	r0!, {r3 - r10}		@ copy from source address [r0]
stmia	r1!, {r3 - r10}		@ copy to   target address [r1]
cmp	r0, r2			@ until source end addreee [r2]
ble	copy_loop
#endif	/* CONFIG_SKIP_RELOCATE_UBOOT */


uboot-imx/include/configs/mx6q_sabresd.h 有如下定义:

#define CONFIG_SKIP_RELOCATE_UBOOT


说明u-boot自身搬移代码功能没起作用。

看下u-boot对CONFIG_SKIP_RELOCATE_UBOOT的说明:

- CONFIG_SKIP_LOWLEVEL_INIT
- CONFIG_SKIP_RELOCATE_UBOOT

[ARM only] If these variables are defined, then
certain low level initializations (like setting up
the memory controller) are omitted and/or U-Boot does
not relocate itself into RAM.
Normally these variables MUST NOT be defined. The
only exception is when U-Boot is loaded (to RAM) by
some other boot loader or by a debugger which
performs these initializations itself.


也就是说此宏一般是用在调试时,例如想直接把u-boot.bin download到sdram中而不是存储到flash上,

这种情况下就不用搬移了,但是此时运行的地址也就是download的ram地址和链接地址也就是编译

出来的地址要一致,否则会运行异常。

还有一种情况就是其他的boot loader帮忙搬运好了。

flash_header.S中的Program Image有这么一段(Program Image描述可参考flash_header.s分析):

uboot-imx/board/freescale/mx6q_sabresd/flash_header.S

boot_data_ptr:    .word boot_data


boot_data:        .word TEXT_BASE


uboot-imx/board/freescale/mx6q_sabresd/config.mk

ifndef TEXT_BASE
TEXT_BASE = 0x27800000
endif


所以boot_data_ptr是保存了u-boot.bin的链接起始地址,然后一开机的时候内部Rom程序会读取它,

虽然不能百分百肯定它的原理,但是至少能推断ROM应该是根据此值来做copy的。

我也有将TEXT_BASE作了改动,结果照样能正常开机。

另外文档上有这么一段:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: