From 0270806ffea732bd0835c14892740a9b82703788 Mon Sep 17 00:00:00 2001 From: Bruno Leite Date: Tue, 15 Apr 2025 10:30:14 +0200 Subject: [PATCH 1/5] rpi: copy over uart clock-frequency in DT rpi5 firmware sets uart_clk clock-frequency in the firmware and patches it to the DT, copy it over when loading a new DT. Signed-off-by: Bruno Leite Reviewed-by: Peter Robinson Tested-by: Peter Robinson --- board/raspberrypi/rpi/rpi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 6ecd3eb120f..049904b93fb 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -602,6 +602,9 @@ void update_fdt_from_fw(void *fdt, void *fw_fdt) /* Bluetooth device address as provided by the firmware */ copy_property(fdt, fw_fdt, "/soc/serial@7e201000/bluetooth", "local-bd-address"); + + /* copy uart clk as provided by the firmware */ + copy_property(fdt, fw_fdt, "/clocks/clk-uart", "clock-frequency"); } int ft_board_setup(void *blob, struct bd_info *bd) From 564d99d0723e338792df6897dc7407df2cf6196d Mon Sep 17 00:00:00 2001 From: Mauro Salvini Date: Wed, 12 May 2021 14:39:45 +0200 Subject: [PATCH 2/5] rpi: always set fdt_addr with firmware-provided FDT address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Raspberry firmware prepares the FDT blob in memory at an address that depends on both the memory size and the blob size [1]. After commit ade243a211d6 ("rpi: passthrough of the firmware provided FDT blob") this FDT is passed to kernel through fdt_addr environment variable, handled in set_fdt_addr() function in board file. When u-boot environment is persistently saved, if a change happens in loaded FDT (e.g. for a new overlay applied), firmware produces a FDT address different from the saved one, but u-boot still use the saved one because set_fdt_addr() function does not overwrite the fdt_addr variable. So, for example, if there is a script that uses fdt commands for e.g. manipulate the bootargs, boot hangs with error libfdt fdt_check_header(): FDT_ERR_BADMAGIC Removing the fdt_addr variable in saved environment allows to boot. With this patch set_fdt_addr() function always overwrite fdt_addr value. [1] https://www.raspberrypi.org/forums//viewtopic.php?f=107&t=134018 Signed-off-by: Mauro Salvini Cc: Cédric Schieli Cc: Matthias Brugger --- board/raspberrypi/rpi/rpi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 049904b93fb..1b0b664fa2b 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -359,9 +359,6 @@ static void set_fdtfile(void) */ static void set_fdt_addr(void) { - if (env_get("fdt_addr")) - return; - if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) return; From e072ebec0556dcbf63f8dc8a3aad739929ef93dd Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 19 Dec 2024 17:34:44 -0700 Subject: [PATCH 3/5] rpi: Set bootm_size to 512MB Set this option so that all boot images stay within the bottom 512MB of memory. This should allow us to drop the fdt_high and initrd_high options. Signed-off-by: Simon Glass Reviewed-by: Tom Rini Suggested-by: Tom Rini Reviewed-by: Christopher Obbard Tested-by: Christopher Obbard # CM4 1G --- board/raspberrypi/rpi/rpi.env | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/board/raspberrypi/rpi/rpi.env b/board/raspberrypi/rpi/rpi.env index 30228285edd..a327fccc77f 100644 --- a/board/raspberrypi/rpi/rpi.env +++ b/board/raspberrypi/rpi/rpi.env @@ -60,7 +60,12 @@ dfu_alt_info+=zImage fat 0 1 * Even with the smallest possible CPU-GPU memory split of the CPU getting * only 64M, the remaining 25M starting at 0x02700000 should allow quite * large initrds before they start colliding with U-Boot. + * + * Limit bootm_size to 512MB so that all boot images stay within the bottom + * 512MB of memory */ +bootm_size=0x20000000 + #ifdef CONFIG_ARM64 fdt_high=ffffffffffffffff initrd_high=ffffffffffffffff From 23bb009351190e7bf9969ea007f500ae92f7bf45 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 19 Dec 2024 17:34:45 -0700 Subject: [PATCH 4/5] rpi: Drop fdt_high and initrd_high These are not needed now since there is a bootm_size setting to keep things within the lower part of memory. Drop them. Signed-off-by: Simon Glass Reviewed-by: Tom Rini Suggested-by: Tom Rini Reviewed-by: Christopher Obbard Tested-by: Christopher Obbard # CM4 1G Reviewed-by: Christopher Obbard Tested-by: Christopher Obbard # CM4 1G --- board/raspberrypi/rpi/rpi.env | 7 ------- 1 file changed, 7 deletions(-) diff --git a/board/raspberrypi/rpi/rpi.env b/board/raspberrypi/rpi/rpi.env index a327fccc77f..9b9fad82828 100644 --- a/board/raspberrypi/rpi/rpi.env +++ b/board/raspberrypi/rpi/rpi.env @@ -66,13 +66,6 @@ dfu_alt_info+=zImage fat 0 1 */ bootm_size=0x20000000 -#ifdef CONFIG_ARM64 -fdt_high=ffffffffffffffff -initrd_high=ffffffffffffffff -#else -fdt_high=ffffffff -initrd_high=ffffffff -#endif kernel_addr_r=0x00080000 scriptaddr=0x02400000 pxefile_addr_r=0x02500000 From 5f9cff14beb7b16ba799c8f43a7cca11c821929a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 19 Dec 2024 17:34:46 -0700 Subject: [PATCH 5/5] rpi: Update environment to support booti and large initrd The existing values don't provide for decompressing an arm64 boot-image. Add those values and move things apart a bit so that a 50MB kernel can be accommodated. Signed-off-by: Simon Glass Reviewed-by: Christopher Obbard Tested-by: Christopher Obbard # CM4 1G Reviewed-by: Christopher Obbard Tested-by: Christopher Obbard # CM4 1G --- board/raspberrypi/rpi/rpi.env | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/board/raspberrypi/rpi/rpi.env b/board/raspberrypi/rpi/rpi.env index 9b9fad82828..9ac9d6768ca 100644 --- a/board/raspberrypi/rpi/rpi.env +++ b/board/raspberrypi/rpi/rpi.env @@ -48,28 +48,33 @@ dfu_alt_info+=zImage fat 0 1 * * scriptaddr and pxefile_addr_r can be pretty much anywhere that doesn't * conflict with something else. Reserving 1M for each of them at - * 0x02400000-0x02500000 and 0x02500000-0x02600000 should be plenty. + * 0x05400000-0x05500000 and 0x05500000-0x05600000 should be plenty. * * On ARM, both the DTB and any possible initrd must be loaded such that they * fit inside the lowmem mapping in Linux. In practice, this usually means not * more than ~700M away from the start of the kernel image but this number can * be larger OR smaller depending on e.g. the 'vmalloc=xxxM' command line * parameter given to the kernel. So reserving memory from low to high - * satisfies this constraint again. Reserving 1M at 0x02600000-0x02700000 for - * the DTB leaves rest of the free RAM to the initrd starting at 0x02700000. - * Even with the smallest possible CPU-GPU memory split of the CPU getting - * only 64M, the remaining 25M starting at 0x02700000 should allow quite - * large initrds before they start colliding with U-Boot. + * satisfies this constraint again. Reserving 1M at 0x05600000-0x05700000 for + * the DTB leaves rest of the free RAM to the initrd starting at 0x05700000. + * This means that the board must have at least 128MB of RAM available to + * U-Boot, more if the initrd is large. * - * Limit bootm_size to 512MB so that all boot images stay within the bottom + * For compressed kernels, the maximum size is just under 32MB, with an area for + * decompression at 0x02000000 with space for 52MB, which is plenty for current + * kernels. + * + * limit bootm_size to 512MB so that all boot images stay within the bottom * 512MB of memory */ bootm_size=0x20000000 kernel_addr_r=0x00080000 -scriptaddr=0x02400000 -pxefile_addr_r=0x02500000 -fdt_addr_r=0x02600000 -ramdisk_addr_r=0x02700000 +kernel_comp_addr_r=0x02000000 +kernel_comp_size=0x03400000 +scriptaddr=0x05400000 +pxefile_addr_r=0x05500000 +fdt_addr_r=0x05600000 +ramdisk_addr_r=0x05700000 boot_targets=mmc usb pxe dhcp