[U-Boot] [RFC PATCH] arm: provide a CONFIG flag for disabling relocation

Aneesh V aneesh at ti.com
Fri Mar 25 14:27:04 CET 2011


Forgot to mention that this patch depends on my previous series for MMC
spl:
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/96352

This one was anyway intended to initiate the discussion. If approved,
I shall create a cleaner patch.

On Friday 25 March 2011 06:42 PM, Aneesh V wrote:
> Relocation may not be needed and desirable in many cases:
>   * For many boards the amount of SDRAM is fixed.
>     So relocation is not needed.
>   * Relocation adds un-necessary additional overhead when
>     it's not needed. This delay is singificant on slower
>     platforms such as FPGA
>   * Many boards have ample memory. So reserving enough memory
>     for Linux in the first half is not a challenge even without
>     relocation
>
> Add a CONFIG option to disable relocation on platforms that
> do not need it. When this flag is enabled allocate memory
> for stack heap etc at the end of memory as usual, but U-Boot
> itself is not moved from TEXT_BASE.
>
> Additionally, -pie is removed from the final link step because
> it was causing the absolute value of all symbols coming from
> the linker script to be 0. This affects find_cmd()
>
> Tested on OMAP4430 SDP
>
> Cc: Albert Aribaud<albert.aribaud at free.fr>
> Cc: Wolfgang Denk<wd at denx.de>
>
> Signed-off-by: Aneesh V<aneesh at ti.com>
> ---
>   arch/arm/config.mk              |    2 ++
>   arch/arm/lib/board.c            |    5 +++++
>   board/ti/sdp4430/config.mk      |    9 +++++++--
>   include/configs/omap4_sdp4430.h |    2 ++
>   4 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/config.mk b/arch/arm/config.mk
> index 1785e73..2315bcb 100644
> --- a/arch/arm/config.mk
> +++ b/arch/arm/config.mk
> @@ -71,5 +71,7 @@ LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds
>
>   # needed for relocation
>   ifndef CONFIG_NAND_SPL
> +ifndef CONFIG_SYS_SKIP_ARM_RELOCATION
>   LDFLAGS_u-boot += -pie
>   endif
> +endif
> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 72ee108..ed3898f 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c
> @@ -361,6 +361,7 @@ void board_init_f (ulong bootflag)
>   	gd->fb_base = addr;
>   #endif /* CONFIG_LCD */
>
> +#ifndef CONFIG_SYS_SKIP_ARM_RELOCATION
>   	/*
>   	 * reserve memory for U-Boot code, data&  bss
>   	 * round down to next 4 kB limit
> @@ -369,6 +370,7 @@ void board_init_f (ulong bootflag)
>   	addr&= ~(4096 - 1);
>
>   	debug ("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len>>  10, addr);
> +#endif
>
>   #ifndef CONFIG_PRELOADER
>   	/*
> @@ -420,6 +422,9 @@ void board_init_f (ulong bootflag)
>   	dram_init_banksize();
>   	display_dram_config();	/* and display it */
>
> +#ifdef CONFIG_SYS_SKIP_ARM_RELOCATION
> +	addr = _TEXT_BASE;
> +#endif
>   	gd->relocaddr = addr;
>   	gd->start_addr_sp = addr_sp;
>   	gd->reloc_off = addr - _TEXT_BASE;
> diff --git a/board/ti/sdp4430/config.mk b/board/ti/sdp4430/config.mk
> index c62965d..8846732 100644
> --- a/board/ti/sdp4430/config.mk
> +++ b/board/ti/sdp4430/config.mk
> @@ -28,5 +28,10 @@
>   # Linux-Kernel is expected to be at 8000'8000, entry 8000'8000
>   # (mem base + reserved)
>
> -# 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM
> -CONFIG_SYS_TEXT_BASE = 0x80100000
> +# 64MB into the SDRAM
> +# Assuming a minimum of 128 MB on the board:
> +# - 64MB before U-Boot is more than enough for Linux when relocation is
> +#   disabled
> +# - ~63MB after the U-Boot is more than enough for U-Boot to relocate
> +#   itself without stepping on itself
> +CONFIG_SYS_TEXT_BASE = 0x84000000
> diff --git a/include/configs/omap4_sdp4430.h b/include/configs/omap4_sdp4430.h
> index fff67d8..e9f76d3 100644
> --- a/include/configs/omap4_sdp4430.h
> +++ b/include/configs/omap4_sdp4430.h
> @@ -278,4 +278,6 @@
>   #define CONFIG_SYS_SPL_BSS_MAX_SIZE		0x80000		/* 512 KB */
>
>   #define CONFIG_SYS_THUMB_BUILD
> +
> +#define CONFIG_SYS_SKIP_ARM_RELOCATION
>   #endif /* __CONFIG_H */


More information about the U-Boot mailing list