Skip to contentSkip to conversation

Relocation

U-Boot mahsmak 4 participants 6 messages Mar 14, 2014 – Mar 17, 2014

lore
Share & tools
lore

mahsmak

author
#0 lore raw

Hi,

Can anyone please explain how relocation address is calculated in uboot ?

Also, I want to know whether relocation will happen or not when uboot is running from RAM already? If yes, then can it be disabled ?

Thank you,

--
View this message in context: http://u-boot.10912.n7.nabble.com/Relocation-tp175974.html
Sent from the U-Boot mailing list archive at Nabble.com.

#1 lore raw

Hi mahsmak,

Quoted 3 lines · mahsmak

Hi,

Can anyone please explain how relocation address is calculated in uboot ?

U-Boot tries to relocate itself as high in RAM as possible so that the lower area is available to e.g. the Linux kernel it will chainload.

Therefore, the usual process is that U-Boot first reserves whatever amount of memory it needs at end of RAM, then relocates itself just below that.

Quoted 2 lines

Also, I want to know whether relocation will happen or not when uboot is running from RAM already? If yes, then can it be disabled ?

Relocation will always happen, and there is no provision for avoiding it.

Quoted 1 line

Thank you,

Amicalement,

Signature · 1 line
Albert.
#2 lore raw

Hi, Albert:

Quoted 2 lines

Relocation will always happen, and there is no provision for avoiding it.

I have ever tried to del these code in crt0.S :

	ldr	sp, [r8, #GD_START_ADDR_SP]	/* r8 =
gd->start_addr_sp */
	bic	sp, sp, #7	/* 8-byte alignment for ABI compliance
*/
	ldr	r8, [r8, #GD_BD]		/* r8 = gd->bd */
	sub	r8, r8, #GD_SIZE		/* new GD is below bd */

	/// tricky code : insure to return here after running
relocate_code.
	adr	lr, here
	ldr	r0, [r8, #GD_RELOC_OFF]		/* lr =
gd->start_addr_sp */
	add	lr, lr, r0
	ldr	r0, [r8, #GD_RELOCADDR]		/* r0 = gd->relocaddr */
	/// start.S implement this function.
	b	relocate_code

Then no relocation, it seemed OK.

Best wishes,

#3 lore raw

Dear TigerLiu at via-alliance.com,

Quoted 3 lines · In message <[email protected]>…
Quoted 3 lines

Relocation will always happen, and there is no provision for avoiding it.

...

Quoted 1 line

Then no relocation, it seemed OK.

You used the correct phrase: it seemed. Except that you broke a number of really important things. If you do not understand what rlocation is needed for, then please gop back and read it in the archives. This has been discussed many times before.

Best regards,

Wolfgang Denk

Signature · 5 lines
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: wd at denx.de
Houston, Tranquillity Base here.  The Eagle has landed.
                                                    -- Neil Armstrong
#4 lore raw

Hi, Denk:

Quoted 4 lines

You used the correct phrase: it seemed. Except that you broke a number of really important things. If you do not understand what rlocation is needed for, then please gop back and read it in the archives. This has been discussed many times before.

For example:
Most ARM SOC platform has BL1 code(Boot Stage 1) before U-boot. So, usually BL1 code could load U-boot.bin to DRAM's dedicated location. So, U-boot need not be relocated again in this case.

Best wishes,

#5 lore raw

Dear TigerLiu at via-alliance.com,

Quoted 9 lines · In message <[email protected]>…
Quoted 5 lines

You used the correct phrase: it seemed. Except that you broke a number of really important things. If you do not understand what rlocation is needed for, then please gop back and read it in the archives. This has been discussed many times before.

For example:
Most ARM SOC platform has BL1 code(Boot Stage 1) before U-boot. So, usually BL1 code could load U-boot.bin to DRAM's dedicated location.

No, it cannot, as the target address depends on a lot of things, including (depending on your config options) contents of some environment variables which may even change from one boot to the next, so the target address is not know in advance.

Quoted 1 line

So, U-boot need not be relocated again in this case.

Yes, it does. All this has been explained again and again in the past, and I really would like to ask you to read this in the archives instead of trying to reanimate this dead horse for the N+1th time.

Thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
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: wd at denx.de
The past is not dead. In fact, it's not even past.  - William Faulkner