From: Aneesh V <aneesh@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Skipping relocation RAM to RAM, esp. on i.MX6?
Date: Mon, 06 Feb 2012 19:49:51 +0530 [thread overview]
Message-ID: <4F2FE187.7040505@ti.com> (raw)
In-Reply-To: <CAPnjgZ0HHm5siRzw0Ha-QzoA0+35wActQgmWMsQAK2nW=9zE6w@mail.gmail.com>
On Sunday 05 February 2012 11:49 AM, Simon Glass wrote:
> Hi,
>
> On Sat, Feb 4, 2012 at 1:15 AM, Aneesh V<aneesh@ti.com> wrote:
>> Hi Dirk,
>>
>>
>> On Friday 03 February 2012 12:55 PM, Dirk Behme wrote:
>>>
>>> Hi,
>>>
>>> on i.MX6 devices, e.g. ARM2 or SabreLite, the ROM boot loader copies the
>>> U-Boot image from the boot device, e.g. the SD card, to the main memory.
>>> This does mean that U-Boot is started in RAM.
>>>
>>> With this, one might wonder why any relocation RAM -> RAM is done anyway
>>> and if this could be skipped?
>>>
>>> Looking into the details shows that board_init_f() in
>>> arch/arm/lib/board.c and relocate_code() in arch/arm/cpu/armv7/start.S
>>> [1] are involved in this.
>>>
>>> In board_init_f() the relocation destination address 'addr' is
>>> calculated. This is basically at the end of the available RAM (- some
>>> space for various stuff like TLB tables etc.). At SabreLite this results
>>> in 0x4FF8D000.
>>>
>>> By the boot loader, the U-Boot is loaded to
>>>
>>> CONFIG_SYS_TEXT_BASE 0x17800000
>>>
>>> This results in relocate_code() copying U-Boot from RAM 0x17800000 to
>>> RAM 0x4FF8D000.
>>>
>>> Setting CONFIG_SYS_TEXT_BASE to the relocation destination address
>>> 0x4FF8D000 does avoid the (unnecessary?) copy by
>>>
>>> cmp r0, r6
>>> moveq r9, #0 /* no relocation. relocation offset(r9) = 0 */
>>> beq clear_bss /* skip relocation */
>>>
>>> in relocate_code().
>>>
>>> But:
>>>
>>> 1) The resulting image still runs without the relocation
>>> (CONFIG_SYS_TEXT_BASE 0x4FF8D000). But e.g. the U-Boot command line
>>> doesn't work properly any more. Most probably this is because not only
>>> the copy is skipped by the 'beq clear_bss', but the whole 'fix .rel.dyn
>>> relocations' is skipped too.
>>>
>>> 2) It's hard to set CONFIG_SYS_TEXT_BASE at compile time to the
>>> relocation address calculated at runtime in board_init_f() due to the
>>> amount of #ifdef and runtime calculation done there. So finding a
>>> generic approach which could easily defined in the config files to avoid
>>> the relocation seems difficult.
>>
>>
>> I haven't really completely read your mail. But here is an
>> implementation I had provided long time back for ARM. But Wolfgang
>> didn't want to take it. You can see the patch and the following
>> discussion in this thread:
>>
>> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/96352
>
> From your patch Aneesh I evolved something that I still use - it deals
> with the case where malloc cannot fit below the text area.
>
> I find any sort of messing with the ICE startup a pain - although I
> have often been able to script it. But for me I need to attach the
> device tree to the binary and a few other things so I might as well
> disable relocation at the same time. It also allows me to debug
> seamlessly in board_init_f() as well as afterwards.
>
> I will send a patch.
Great!
>
> It would be good to get something in mainline despite the
> protestations, if only to avoid all the work that people have to do to
> figure out this problem.
I am always in favor of that:)
best regards,
Aneesh
prev parent reply other threads:[~2012-02-06 14:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-03 7:25 [U-Boot] Skipping relocation RAM to RAM, esp. on i.MX6? Dirk Behme
2012-02-03 8:51 ` Stefano Babic
2012-02-03 10:18 ` Dirk Behme
2012-02-03 11:00 ` Stefano Babic
2012-02-03 11:19 ` Mike Frysinger
2012-02-04 8:38 ` [U-Boot] i.MX5/6 U-Boot: Cache enabling (was: Re: Skipping relocation RAM to RAM, esp. on i.MX6?) Dirk Behme
2012-02-04 9:18 ` [U-Boot] i.MX5/6 U-Boot: Cache enabling Aneesh V
2012-02-04 10:18 ` [U-Boot] i.MX5/6 U-Boot: Cache enabling (was: Re: Skipping relocation RAM to RAM, esp. on i.MX6?) Marek Vasut
2012-02-08 13:37 ` [U-Boot] i.MX5/6 U-Boot: Cache enabling Dirk Behme
2012-02-09 7:06 ` Marek Vasut
2012-02-04 9:15 ` [U-Boot] Skipping relocation RAM to RAM, esp. on i.MX6? Aneesh V
2012-02-04 11:00 ` Albert ARIBAUD
2012-02-04 11:14 ` Aneesh V
2012-02-04 11:37 ` Albert ARIBAUD
2012-02-06 14:34 ` Tom Rini
2012-02-06 21:21 ` Albert ARIBAUD
2012-02-06 22:27 ` Wolfgang Denk
2012-02-06 22:41 ` Graeme Russ
2012-02-07 7:19 ` Aneesh V
2012-02-07 23:26 ` Wolfgang Denk
2012-02-08 6:43 ` Aneesh V
2012-02-08 13:58 ` Wolfgang Denk
2012-02-08 14:48 ` Aneesh V
2012-02-08 16:23 ` Wolfgang Denk
2012-02-09 6:01 ` Aneesh V
2012-02-09 11:44 ` Wolfgang Denk
2012-02-09 13:43 ` Aneesh V
2012-02-05 6:19 ` Simon Glass
2012-02-06 14:19 ` Aneesh V [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F2FE187.7040505@ti.com \
--to=aneesh@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.