diff mbox

[U-Boot,1/2] arm: Make reset position-independent

Message ID 1409779954-14542-1-git-send-email-benoit.thebaudeau.dev@gmail.com
State Accepted
Delegated to: Albert ARIBAUD
Headers show

Commit Message

Benoît Thébaudeau Sept. 3, 2014, 9:32 p.m. UTC
Some boards, like mx31pdk and tx25, require the beginning of the SPL
code to be position-independent. For these two boards, this is because
they use the i.MX external NAND boot, which starts by executing the
first NAND Flash page from the NFC page buffer. The SPL then needs to
copy itself to its actual link address in order to free the NFC page
buffer and use it to load the non-SPL image from Flash before running
it. This means that the SPL runtime address differs from its link
address between the reset and the initial copy performed by
board_init_f(), so this part of the SPL binary must be
position-independent.

This requirement was broken by commit 41623c9 'arm: move exception
handling out of start.S files', which used an absolute address to branch
to the reset routine. This new commit restores the original behavior,
which just performed a relative branch. This fixes the boot of mx31pdk
and tx25.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
Reported-by: Helmut Raiger <helmut.raiger@hale.at>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Magnus Lilja <lilja.magnus@gmail.com>
Cc: John Rigby <jcrigby@gmail.com>
---
 arch/arm/lib/vectors.S |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Benoît Thébaudeau Sept. 3, 2014, 9:52 p.m. UTC | #1
On Wed, Sep 3, 2014 at 11:32 PM, Benoît Thébaudeau
<benoit.thebaudeau.dev@gmail.com> wrote:
> Some boards, like mx31pdk and tx25, require the beginning of the SPL
> code to be position-independent. For these two boards, this is because
> they use the i.MX external NAND boot, which starts by executing the
> first NAND Flash page from the NFC page buffer. The SPL then needs to
> copy itself to its actual link address in order to free the NFC page
> buffer and use it to load the non-SPL image from Flash before running
> it. This means that the SPL runtime address differs from its link
> address between the reset and the initial copy performed by
> board_init_f(), so this part of the SPL binary must be
> position-independent.
>
> This requirement was broken by commit 41623c9 'arm: move exception
> handling out of start.S files', which used an absolute address to branch
> to the reset routine. This new commit restores the original behavior,
> which just performed a relative branch. This fixes the boot of mx31pdk
> and tx25.
>
> Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
> Reported-by: Helmut Raiger <helmut.raiger@hale.at>
> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
> Cc: Magnus Lilja <lilja.magnus@gmail.com>
> Cc: John Rigby <jcrigby@gmail.com>
> ---
>  arch/arm/lib/vectors.S |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/arm/lib/vectors.S b/arch/arm/lib/vectors.S
> index 493f337..843b18f 100644
> --- a/arch/arm/lib/vectors.S
> +++ b/arch/arm/lib/vectors.S
> @@ -50,7 +50,7 @@
>  #endif
>
>  _start:
> -       ldr     pc, _reset
> +       b       reset
>         ldr     pc, _undefined_instruction
>         ldr     pc, _software_interrupt
>         ldr     pc, _prefetch_abort
> @@ -77,7 +77,6 @@ _start:
>         .globl  _irq
>         .globl  _fiq
>
> -_reset:                        .word reset
>  _undefined_instruction:        .word undefined_instruction
>  _software_interrupt:   .word software_interrupt
>  _prefetch_abort:       .word prefetch_abort
> --
> 1.7.10.4
>

Magnus, can I have your 'Tested-by' for mx31pdk since you said you
have tested this?

Tom, Albert, can you build-test all ARM boards with this patch (that
would take eons on my ultra slow machine)? It would also be nice if
someone could runtime-test an ARM board other than mx31pdk and tx25
with this patch.

Thanks in advance.

Best regards,
Benoît
Benoît Thébaudeau Sept. 3, 2014, 9:55 p.m. UTC | #2
On Wed, Sep 3, 2014 at 11:32 PM, Benoît Thébaudeau
<benoit.thebaudeau.dev@gmail.com> wrote:
> Some boards, like mx31pdk and tx25, require the beginning of the SPL
> code to be position-independent. For these two boards, this is because
> they use the i.MX external NAND boot, which starts by executing the
> first NAND Flash page from the NFC page buffer. The SPL then needs to
> copy itself to its actual link address in order to free the NFC page
> buffer and use it to load the non-SPL image from Flash before running
> it. This means that the SPL runtime address differs from its link
> address between the reset and the initial copy performed by
> board_init_f(), so this part of the SPL binary must be
> position-independent.
>
> This requirement was broken by commit 41623c9 'arm: move exception
> handling out of start.S files', which used an absolute address to branch
> to the reset routine. This new commit restores the original behavior,
> which just performed a relative branch. This fixes the boot of mx31pdk
> and tx25.
>
> Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
> Reported-by: Helmut Raiger <helmut.raiger@hale.at>
> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
> Cc: Magnus Lilja <lilja.magnus@gmail.com>
> Cc: John Rigby <jcrigby@gmail.com>
> ---
>  arch/arm/lib/vectors.S |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/arm/lib/vectors.S b/arch/arm/lib/vectors.S
> index 493f337..843b18f 100644
> --- a/arch/arm/lib/vectors.S
> +++ b/arch/arm/lib/vectors.S
> @@ -50,7 +50,7 @@
>  #endif
>
>  _start:
> -       ldr     pc, _reset
> +       b       reset
>         ldr     pc, _undefined_instruction
>         ldr     pc, _software_interrupt
>         ldr     pc, _prefetch_abort
> @@ -77,7 +77,6 @@ _start:
>         .globl  _irq
>         .globl  _fiq
>
> -_reset:                        .word reset
>  _undefined_instruction:        .word undefined_instruction
>  _software_interrupt:   .word software_interrupt
>  _prefetch_abort:       .word prefetch_abort
> --
> 1.7.10.4
>

Adding Helmut to Cc.

Benoît
Magnus Lilja Sept. 5, 2014, 6:41 p.m. UTC | #3
Hi

On 3 September 2014 23:32, Benoît Thébaudeau
<benoit.thebaudeau.dev@gmail.com> wrote:
> Some boards, like mx31pdk and tx25, require the beginning of the SPL
> code to be position-independent. For these two boards, this is because
> they use the i.MX external NAND boot, which starts by executing the
> first NAND Flash page from the NFC page buffer. The SPL then needs to
> copy itself to its actual link address in order to free the NFC page
> buffer and use it to load the non-SPL image from Flash before running
> it. This means that the SPL runtime address differs from its link
> address between the reset and the initial copy performed by
> board_init_f(), so this part of the SPL binary must be
> position-independent.
>
> This requirement was broken by commit 41623c9 'arm: move exception
> handling out of start.S files', which used an absolute address to branch
> to the reset routine. This new commit restores the original behavior,
> which just performed a relative branch. This fixes the boot of mx31pdk
> and tx25.
>
> Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
> Reported-by: Helmut Raiger <helmut.raiger@hale.at>
> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
> Cc: Magnus Lilja <lilja.magnus@gmail.com>
> Cc: John Rigby <jcrigby@gmail.com>
> ---

Tested-by: Magnus Lilja <lilja.magnus@gmail.com>
Fabio Estevam Sept. 9, 2014, 8:24 p.m. UTC | #4
Hi Albert,

On Fri, Sep 5, 2014 at 3:41 PM, Magnus Lilja <lilja.magnus@gmail.com> wrote:
> Hi
>
> On 3 September 2014 23:32, Benoît Thébaudeau
> <benoit.thebaudeau.dev@gmail.com> wrote:
>> Some boards, like mx31pdk and tx25, require the beginning of the SPL
>> code to be position-independent. For these two boards, this is because
>> they use the i.MX external NAND boot, which starts by executing the
>> first NAND Flash page from the NFC page buffer. The SPL then needs to
>> copy itself to its actual link address in order to free the NFC page
>> buffer and use it to load the non-SPL image from Flash before running
>> it. This means that the SPL runtime address differs from its link
>> address between the reset and the initial copy performed by
>> board_init_f(), so this part of the SPL binary must be
>> position-independent.
>>
>> This requirement was broken by commit 41623c9 'arm: move exception
>> handling out of start.S files', which used an absolute address to branch
>> to the reset routine. This new commit restores the original behavior,
>> which just performed a relative branch. This fixes the boot of mx31pdk
>> and tx25.
>>
>> Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
>> Reported-by: Helmut Raiger <helmut.raiger@hale.at>
>> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
>> Cc: Magnus Lilja <lilja.magnus@gmail.com>
>> Cc: John Rigby <jcrigby@gmail.com>
>> ---
>
> Tested-by: Magnus Lilja <lilja.magnus@gmail.com>

Should this one go through your tree?
Albert ARIBAUD Sept. 12, 2014, 5:51 a.m. UTC | #5
Hi Benoît,

On Wed,  3 Sep 2014 23:32:33 +0200, Benoît Thébaudeau
<benoit.thebaudeau.dev@gmail.com> wrote:

> Some boards, like mx31pdk and tx25, require the beginning of the SPL
> code to be position-independent. For these two boards, this is because
> they use the i.MX external NAND boot, which starts by executing the
> first NAND Flash page from the NFC page buffer. The SPL then needs to
> copy itself to its actual link address in order to free the NFC page
> buffer and use it to load the non-SPL image from Flash before running
> it. This means that the SPL runtime address differs from its link
> address between the reset and the initial copy performed by
> board_init_f(), so this part of the SPL binary must be
> position-independent.
> 
> This requirement was broken by commit 41623c9 'arm: move exception
> handling out of start.S files', which used an absolute address to branch
> to the reset routine. This new commit restores the original behavior,
> which just performed a relative branch. This fixes the boot of mx31pdk
> and tx25.
> 
> Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
> Reported-by: Helmut Raiger <helmut.raiger@hale.at>
> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
> Cc: Magnus Lilja <lilja.magnus@gmail.com>
> Cc: John Rigby <jcrigby@gmail.com>
> ---
>  arch/arm/lib/vectors.S |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/arm/lib/vectors.S b/arch/arm/lib/vectors.S
> index 493f337..843b18f 100644
> --- a/arch/arm/lib/vectors.S
> +++ b/arch/arm/lib/vectors.S
> @@ -50,7 +50,7 @@
>  #endif
>  
>  _start:
> -	ldr	pc, _reset
> +	b	reset
>  	ldr	pc, _undefined_instruction
>  	ldr	pc, _software_interrupt
>  	ldr	pc, _prefetch_abort
> @@ -77,7 +77,6 @@ _start:
>  	.globl	_irq
>  	.globl	_fiq
>  
> -_reset:			.word reset
>  _undefined_instruction:	.word undefined_instruction
>  _software_interrupt:	.word software_interrupt
>  _prefetch_abort:	.word prefetch_abort

Applied (as a bug fix) to u-boot-arm/master, thanks!

Amicalement,
diff mbox

Patch

diff --git a/arch/arm/lib/vectors.S b/arch/arm/lib/vectors.S
index 493f337..843b18f 100644
--- a/arch/arm/lib/vectors.S
+++ b/arch/arm/lib/vectors.S
@@ -50,7 +50,7 @@ 
 #endif
 
 _start:
-	ldr	pc, _reset
+	b	reset
 	ldr	pc, _undefined_instruction
 	ldr	pc, _software_interrupt
 	ldr	pc, _prefetch_abort
@@ -77,7 +77,6 @@  _start:
 	.globl	_irq
 	.globl	_fiq
 
-_reset:			.word reset
 _undefined_instruction:	.word undefined_instruction
 _software_interrupt:	.word software_interrupt
 _prefetch_abort:	.word prefetch_abort