[U-Boot] why u-boot relocate it self to RAM from flash?

tejas patel tvpatel12 at gmail.com
Tue Dec 3 05:08:20 CET 2013


Thank you very much for explanation both graeme and FengHua.

I think i have got best answer from you Graeme from entire web.

Thanks
Tejas


On Tue, Dec 3, 2013 at 4:03 AM, Graeme Russ <graeme.russ at gmail.com> wrote:

> Hi,
>
> On Tue, Dec 3, 2013 at 1:18 AM, FengHua <fenghua at phytium.com.cn> wrote:
>
>>
>> > Hi,
>> >
>> > I can not understand why u-boot relocate it self to RAM from flash? Why
>> is
>> > it not executing from flash?
>> > Can anybody explain.
>> >
>>
>> First, flash is slow.
>> Second, there are many data structures or variables which should be
>> writable.
>> So, we should copy u-boot to RAM and relocate it.
>>
>
> I'll expand a bit...
>
> In theory the writeable could be relocated into RAM, but this would
> require the relocation address to be hard-coded. Optimally, U-Boot places
> itself in a memory location to provide the maximum contiguous memory space
> to load the operating system kernel and supporting data (RAM disks, FDTs,
> etc).
>
> On most systems now, relocation is done by calculating the delta between
> the ROM address (TEXT_BASE) and the relocated address in RAM. The
> relocation code first copies the entire U-Boot image to RAM (apart from a
> few structures that are used only during the relocation calculation). It
> then scans the relocation entries (*.rel sections) to find where in the
> U-Boot executable all the references into the data sections. At each
> reference point in the executable, the relocation code modifies the
> reference by the relocation offset. None of this can happen if the U-Boot
> executable is in Flash.
>
> The other advantage of relocating U-Boot to RAM is that it makes it
> possible to flash a new U-Boot image from U-Boot. If you try to do this
> while U-Boot is running from flash, it will crash as you are overwriting
> the executable code while it's executing.
>
>  Regards,
>
> Graeme
>



-- 

Thanks and Regards
Tejas Patel


More information about the U-Boot mailing list