[PATCH v1 3/3] common: Allow relocations on the top of the last bank
Marek Vasut
marek.vasut at mailbox.org
Thu Mar 26 13:58:35 CET 2026
On 3/26/26 12:51 PM, Ilias Apalodimas wrote:
> Right now we only relocate u-boot to the top of the first
> memory bank unless the board specific code overwrites it.
> This is problematic when loading big binaries as it
> fragments the contiguous memory space for no apparent reason.
>
> It's worth noting that there are cases where we must not relocate
> above the 4GB boundary (e.g 64bit hardware with 32bit only capable
GiB , non-SI unit .
> DMA).
>
> Add a Kconfig option and allow the common code to relocate U-Boot
> to the top of the last discovered bank.
The commit message should really clarify the current pitfalls of
enabling this symbol, including the part where ethernet transfers above
4 GiB used to work because of the packet buffer built into U-Boot, and
they will break because the buffer is now relocated above 4 GiB too.
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> ---
> Changes since RFC:
> - new patch
> Kconfig | 7 +++++++
> common/board_f.c | 2 ++
> 2 files changed, 9 insertions(+)
>
> diff --git a/Kconfig b/Kconfig
> index ce25ea24a60f..b9144878ce0b 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -474,6 +474,13 @@ config SKIP_RELOCATE
> Skips relocation of U-Boot allowing for systems that have extremely
> limited RAM to run U-Boot.
>
> +config RELOCATE_LAST_BANK
> + bool "Relocate U-Boot to the top of the last memory bank"
You may want to call this "Relocate to the topmost memory address" or
something along those lines, since "last bank" is a bit opaque.
> + help
> + When U-Boot relocates, it chooses the end of the first memory bank.
> + Enable this if you have multiple banks and want U-Boot to relocate
> + to the top of the last available bank.
> +
> endif # EXPERT
>
> config PHYS_64BIT
> diff --git a/common/board_f.c b/common/board_f.c
> index df2b0dc899bf..7c3fbeab17ec 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -321,6 +321,8 @@ __weak phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
> */
> return 0;
> #endif
> + if (IS_ENABLED(CONFIG_RELOCATE_LAST_BANK))
> + fdtdec_setup_mem_ram_top();
Return value may need checking ?
More information about the U-Boot
mailing list