[PATCH] rpi: limit size of the RAM to the multiple of the MMU_SECTION_SIZE

Marek Szyprowski m.szyprowski at samsung.com
Mon Feb 1 12:16:33 CET 2021


When RPi4 is booted from USB Mass Storage, the firmware reports 947MiB of
the ARM memory (948 in case of the standard SD-card boot). This value is
not MMU_SECTION_SIZE aligned, so the dram_bank_mmu_setup() skips mapping
of the last 1MiB. This later causes u-boot in ARM 32bit mode to freeze,
because it relocated itself into that unmapped memory and fails to
execute.

Fix this by limiting the size of the first bank to the multiple of
MMU_SECTION_SIZE.

Signed-off-by: Marek Szyprowski <m.szyprowski at samsung.com>
---
 board/raspberrypi/rpi/rpi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 6b1fa5fc14..83ccd3e3fc 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -268,6 +268,13 @@ int dram_init(void)
 
 	gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
 
+	/*
+	 * In some configurations the memory size returned by VideoCore
+	 * is not aligned to the section size, what is mandatory for
+	 * the u-boot's memory setup.
+	 */
+	gd->ram_size &= ~MMU_SECTION_SIZE;
+
 	return 0;
 }
 
-- 
2.17.1



More information about the U-Boot mailing list