public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] sunxi: Use Thumb2 and move stack to gain more SRAM space in FEL mode
Date: Sat, 19 Jul 2014 13:19:09 +0200	[thread overview]
Message-ID: <53CA542D.8050807@redhat.com> (raw)
In-Reply-To: <1405703385-14580-2-git-send-email-siarhei.siamashka@gmail.com>

Hi,

On 07/18/2014 07:09 PM, Siarhei Siamashka wrote:
> The Allwinner SoCs support a special FEL boot mode, which can be activated
> by users via a button press (or other means). In the FEL mode, the BROM
> implements a custom FEL protocol over USB, which allows to upload code to
> the device and run it. This protocol had been reverse engineered and
> documented by Henrik Nordstr?m:
>
>      http://lists.phcomp.co.uk/pipermail/arm-netbook/2012-June/004341.html
>
> Because the BROM code is using some parts of the SRAM for itself, only a
> few areas are available for use in u-boot. Currently the SPL is loaded
> into the "0x2000-0x5cff Free for program use" area and the stack pointer
> is at the end of this area. This is barely enough to fit just the current
> SPL and leaves almost no headroom for the future code.
>
> This patch enables the use of a more compact Thumb2 mode for compiling the
> FEL SPL binary. And also relocates the stack to another "0x8000-0xbfff Free
> for program use" area. Additionally, the BSS segment is cleared.
>
> Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

Looks good:

Acked-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans

> ---
>   arch/arm/cpu/armv7/sunxi/Makefile           |  1 +
>   arch/arm/cpu/armv7/sunxi/start_fel.S        | 42 +++++++++++++++++++++++++++++
>   arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds |  4 +--
>   include/configs/sunxi-common.h              |  2 --
>   4 files changed, 45 insertions(+), 4 deletions(-)
>   create mode 100644 arch/arm/cpu/armv7/sunxi/start_fel.S
>
> diff --git a/arch/arm/cpu/armv7/sunxi/Makefile b/arch/arm/cpu/armv7/sunxi/Makefile
> index a64bfa1..b3eff98 100644
> --- a/arch/arm/cpu/armv7/sunxi/Makefile
> +++ b/arch/arm/cpu/armv7/sunxi/Makefile
> @@ -21,5 +21,6 @@ ifdef CONFIG_SPL_BUILD
>   obj-$(CONFIG_SUN7I)	+= dram.o
>   ifdef CONFIG_SPL_FEL
>   obj-y	+= start.o
> +extra-y += start_fel.o
>   endif
>   endif
> diff --git a/arch/arm/cpu/armv7/sunxi/start_fel.S b/arch/arm/cpu/armv7/sunxi/start_fel.S
> new file mode 100644
> index 0000000..2789fd9
> --- /dev/null
> +++ b/arch/arm/cpu/armv7/sunxi/start_fel.S
> @@ -0,0 +1,42 @@
> +/*
> + * Copyright (c) 2014 Siarhei Siamashka <siarhei.siamashka@gmail.com>
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +.syntax unified
> +.text
> +.arm
> +.arch armv7a
> +.p2align 2
> +
> +.globl _start_fel
> +.globl s_init
> +.globl __bss_start
> +.globl __bss_end
> +
> +_start_fel:
> +	/* Relocate stack to the 0x8000-0xBFFF area */
> +	mov	r0, #0xC000
> +	str	sp, [r0, #-4]!
> +	str	lr, [r0, #-4]!
> +	adr	lr, _exit_fel /* Return back to '_exit_fel' */
> +	mov	sp, r0
> +
> +	/* Erase the BSS segment */
> +	ldr	r0, =__bss_start
> +	ldr	r1, =__bss_end
> +	mov	r2, #0
> +0:	cmp	r0, r1
> +	strbne	r2, [r0], #1
> +	bne	0b
> +
> +	/* Pass control to the 's_init()' function */
> +	b	s_init
> +
> +_exit_fel:
> +	/* Relocate stack back and return */
> +	mov	r0, #0xC000
> +	ldr	sp, [r0, #-4]!
> +	ldr	lr, [r0, #-4]!
> +	bx	lr
> diff --git a/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds b/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
> index 364e35c..418c2fc 100644
> --- a/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
> +++ b/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
> @@ -6,7 +6,7 @@
>    */
>   OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
>   OUTPUT_ARCH(arm)
> -ENTRY(s_init)
> +ENTRY(_start_fel)
>   SECTIONS
>   {
>   	. = 0x00002000;
> @@ -14,7 +14,7 @@ SECTIONS
>   	. = ALIGN(4);
>   	.text :
>   	{
> -		*(.text.s_init)
> +		arch/arm/cpu/armv7/sunxi/start_fel.o	(.text)
>   		*(.text*)
>   	}
>
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 5d72d62..4b980e9 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -18,10 +18,8 @@
>    */
>   #define CONFIG_SUNXI		/* sunxi family */
>   #ifdef CONFIG_SPL_BUILD
> -#ifndef CONFIG_SPL_FEL
>   #define CONFIG_SYS_THUMB_BUILD	/* Thumbs mode to save space in SPL */
>   #endif
> -#endif
>
>   #include <asm/arch/cpu.h>	/* get chip and board defs */
>
>

  reply	other threads:[~2014-07-19 11:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 17:09 [U-Boot] [PATCH 0/2] sunxi: FEL boot mode improvements Siarhei Siamashka
2014-07-18 17:09 ` [U-Boot] [PATCH 1/2] sunxi: Use Thumb2 and move stack to gain more SRAM space in FEL mode Siarhei Siamashka
2014-07-19 11:19   ` Hans de Goede [this message]
2014-07-21 18:31   ` Ian Campbell
2014-07-25  1:01     ` Siarhei Siamashka
2014-07-25  1:03       ` [U-Boot] [linux-sunxi] " Julian Calaby
2014-07-25  4:11         ` Julian Calaby
2014-07-25  6:56       ` [U-Boot] " Ian Campbell
2014-07-25  1:14   ` Siarhei Siamashka
2014-07-18 17:09 ` [U-Boot] [PATCH 2/2] sunxi: Set the AUXCR L2EN bit for sun4i/sun5i in FEL boot mode Siarhei Siamashka
2014-07-18 18:47   ` Jeroen Hofstee
2014-07-21 20:07     ` Ian Campbell
2014-07-21 20:39       ` Jeroen Hofstee
2014-07-21 20:59         ` Ian Campbell
2014-07-25  0:21           ` Siarhei Siamashka
2014-07-25  6:55             ` Ian Campbell
2014-07-19 11:20   ` Hans de Goede
2014-07-21 18:39     ` Ian Campbell
2014-07-21 20:34       ` Ian Campbell

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=53CA542D.8050807@redhat.com \
    --to=hdegoede@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox