[U-Boot] [PATCH v2 01/11] ARM: fix relocation on ARM926EJS

Christian Riesch
2012-09-17T09:03:31Z

Hi,

On Mon, Sep 17, 2012 at 10:34 AM, Jos? Miguel Gon?alves
<jose.goncalves@inov.pt> wrote:
> On 09/17/2012 07:28 AM, Christian Riesch wrote:
>>
>> Hi,
>>
>> On Sun, Sep 16, 2012 at 5:36 PM, Marek Vasut <marex@denx.de> wrote:
>>>
>>> Dear Jos? Miguel Gon?alves,
>>>
>>>> On 09/16/2012 11:06 AM, Marek Vasut wrote:
>>>>>
>>>>> Dear Jos? Miguel Gon?alves,
>>>>>
>>>>>> On 09/15/2012 07:03 PM, Marek Vasut wrote:
>>>>>>>
>>>>>>> Dear Jos? Miguel Gon?alves,
>>>>>>>
>>>>>>>> Jumping to board_init_r is not performed due to a bug on address
>>>>>>>> computation.
>>>>>>>
>>>>>>> Is your CONFIG_SYS_TEXT_BASE configured correctly? I don't detect any
>>>>>>> misbehavior on my arm926 boards.
>>>>>>
>>>>>> Maybe because you are not using it to build an SPL?
>>>>>
>>>>> I do ... and I use CONFIG_SPL_TEXT_BASE properly .
>>>>>>
>>>>>> Please check the same chunk of code in other start.S for arm1176 and
>>>>>> armv7. They have the same code that I put for arm926ejs.
>>>>>
>>>>> Please wait and please first explain what is the issue.
>>>>
>>>> The issue is what I've explained in the patch comments.
>>>
>>> "Jumping to board_init_r is not performed due to a bug on address
>>> computation."
>>>
>>> Ok, I don't know how to replicate the bug from this comment or what
>>> effects it
>>> causes or ... well, anything. So please, try to be more elaborate in your
>>> patch
>>> description next time. Anyway ..
>>
>> Same for me - I have no idea what you are trying to fix here. In my
>> SPL configuration, _TEXT_BASE and _start point to the same location,
>> so please explain why they are different on your board.
>
>
> They are different because of how start.S is implemented in arm926ejs.
>
> In my SPL map file I see:
>
> .text 0x0000000000000000 0xc24
> arch/arm/cpu/arm926ejs/start.o(.text)
> .text 0x0000000000000000 0x120 arch/arm/cpu/arm926ejs/start.o
> 0x0000000000000000 _start
> 0x0000000000000040 _TEXT_BASE
> 0x0000000000000044 _bss_start_ofs
> 0x0000000000000048 _bss_end_ofs
> 0x000000000000004c _end_ofs
> 0x0000000000000050 IRQ_STACK_START_IN
> 0x0000000000000074 relocate_code

So _start is 0x00000000, and in your
config/include/include/configs/mini2416.h you have

#define CONFIG_SPL_TEXT_BASE 0x00000000

and in arch/arm/cpu/arm926ejs/start.S we have

.globl _TEXT_BASE
_TEXT_BASE:
#ifdef CONFIG_NAND_SPL /* deprecated, use instead CONFIG_SPL_BUILD */
.word CONFIG_SYS_TEXT_BASE
#else
#ifdef CONFIG_SPL_BUILD
.word CONFIG_SPL_TEXT_BASE
#else
.word CONFIG_SYS_TEXT_BASE
#endif
#endif

So

ldr r1, _TEXT_BASE

should be the same as

adr r1, _start

However, if you do not load your SPL to 0x00000000 but to another
address and execute it from there, it will be different, since adr
uses relative adressing, right? Are you sure you are loading it to
0x00000000?

Regards, Christian

>
>
>
>>>> Without this
>>>> change the code never reaches board_init_r in the SPL and I think I have
>>>> all the configurations correctly set.
>>>
>>> I wonder why you'd ever want to reach board_init_r in the SPL. SPL is
>>> there only
>>> to load the real U-Boot from whatever media, so you usually use either
>>> NAND SPL
>>> or something like that.
>>>
>> Marek, going into board_init_r is fine for SPL, for example the
>> davinci SPL does some hw initialization in board_init_f and then loads
>> u-boot in board_init_r.
>> Regards, Christian
>>
>>> What do you boot the rest from ?
>>>
>>>> If the bug is not from here please
>>>> suggest me what I need to change in the configuration in order to
>>>> correctly boot my board.
>>>>
>>>>>>>> Relocation offsets are not needed when building SPL.
>>>>>>>
>>>>>>> Do they cause any trouble?
>>>>>>
>>>>>> No! Just not needed.
>>>>>>
>>>>>>>> Signed-off-by: Jos? Miguel Gon?alves <jose.goncalves@inov.pt>
>>>>>>>> ---
>>>>>>>>
>>>>>>>> Changes for v2:
>>>>>>>> - None
>>>>>>>>
>>>>>>>> ---
>>>>>>>>
>>>>>>>> arch/arm/cpu/arm926ejs/start.S | 4 +++-
>>>>>>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/arch/arm/cpu/arm926ejs/start.S
>>>>>>>> b/arch/arm/cpu/arm926ejs/start.S index 6f05f1a..2da5342 100644
>>>>>>>> --- a/arch/arm/cpu/arm926ejs/start.S
>>>>>>>> +++ b/arch/arm/cpu/arm926ejs/start.S
>>>>>>>>
>>>>>>>> @@ -325,7 +325,7 @@ _nand_boot_ofs:
>>>>>>>> .word nand_boot
>>>>>>>>
>>>>>>>> #else
>>>>>>>>
>>>>>>>> ldr r0, _board_init_r_ofs
>>>>>>>>
>>>>>>>> - ldr r1, _TEXT_BASE
>>>>>>>> + adr r1, _start
>>>>>>>>
>>>>>>>> add lr, r0, r1
>>>>>>>> add lr, lr, r9
>>>>>>>> /* setup parameters for board_init_r */
>>>>>>>>
>>>>>>>> @@ -338,12 +338,14 @@ _board_init_r_ofs:
>>>>>>>> .word board_init_r - _start
>>>>>>>>
>>>>>>>> #endif
>>>>>>>>
>>>>>>>> +#ifndef CONFIG_SPL_BUILD
>>>>>>>>
>>>>>>>> _rel_dyn_start_ofs:
>>>>>>>> .word __rel_dyn_start - _start
>>>>>>>>
>>>>>>>> _rel_dyn_end_ofs:
>>>>>>>> .word __rel_dyn_end - _start
>>>>>>>>
>>>>>>>> _dynsym_start_ofs:
>>>>>>>> .word __dynsym_start - _start
>>>>>>>>
>>>>>>>> +#endif
>>>>>>>>
>>>>>>>> /*
>>>>>>>>
>>>>>>>>
>>>>>>>> ******************************************************************
>>>>>>>> *** ****
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Marek Vasut
>>>>>>
>>>>>> Best regards,
>>>>>> Jos? Gon?alves
>>>>>
>>>>> Best regards,
>>>>> Marek Vasut
>>>>
>>>> Best regards,
>>>> Jos? Gon?alves
>
>
> Best regards,
> Jos? Gon?alves
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot