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

2013-12-02 Thread Wolfgang Denk
Dear tejas patel,

In message  
you wrote:
>
> I can not understand why u-boot relocate it self to RAM from flash? Why is
> it not executing from flash?
> Can anybody explain.

There is a ton of reasons.  One is that you cannot erase or program
the flash device and execute code from it at the same time, so we
would not be able to write a Linux kernel image - at least not without
special flash drivers that execute from RAM.  And we would not be able
to update the U-Boot image in flash. etc. etc.

In the end it is much easier to run from RAM.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
The average woman would rather have beauty than brains,  because  the
average man can see better than he can think.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2013-12-02 Thread tejas patel
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  wrote:

> Hi,
>
> On Tue, Dec 3, 2013 at 1:18 AM, FengHua  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
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2013-12-02 Thread Graeme Russ
Hi,

On Tue, Dec 3, 2013 at 1:18 AM, FengHua  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
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2013-12-02 Thread FengHua

> 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.

Regards





___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2013-12-01 Thread tejas patel
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.

-- 

Thanks and Regards
Tejas Patel
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot