u-boot : Relocation

前端 未结 3 1921
独厮守ぢ
独厮守ぢ 2021-02-04 06:00

This one is a basic question related to u-boot.

Why does the u-boot code relocate itself ?

Ok, it makes sense if u-boot is executing from NOR-flash or boot ROM s

3条回答
  •  [愿得一人]
    2021-02-04 06:36

    This question comes up frequently. Good answers sometimes too.

    I agree it is handy to load the build to SDRAM during development. That works for me, I do it all the time. I have some special boot code in flash which does not enable MMU/cache. For my u-boot builds I switch CONFIG_SYS_TEXT_BASE between flash and ram builds. I run my development builds that way routinely.

    As a practical matter, handling re-initialization of MMU/cache would be a nontrivial matter. And U-Boot benefits IMO from simplicity, as result of leaving out things like that.

    The tech lead at Denx has expressed his opinion. IIRC his other posts are more strongly worded than that one. I get the impression that he does not like to repeat himself.

    update: why relocate. Memory access is faster from RAM than from ROM, this will matter particularly if target has no instruction cache. Executing from RAM allows flash reprogramming; also (more minor) it allows software breakpoints with "trap" instructions; also it is more like the target's normal mode of operation, so if e.g. burst reads from RAM are iffy the failure will be seen at early boot.

提交回复
热议问题