[PATCH v1 3/3] common: Allow relocations on the top of the last bank

Ilias Apalodimas ilias.apalodimas at linaro.org
Thu Mar 26 12:51:09 CET 2026


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
DMA).

Add a Kconfig option and allow the common code to relocate U-Boot
to the top of the last discovered bank.

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"
+	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 gd->ram_top;
 }
 
-- 
2.51.0



More information about the U-Boot mailing list