[PATCH v2] fdt: Allow expanding the devicetree during relocation
Simon Glass
sjg at chromium.org
Fri May 16 16:12:56 CEST 2025
Some boards set fdt_high to -1 which means that the FDT is not relocated
in boot_relocate_fdt().
A comment in that function says that we assume there is space after the
existing fdt to use for padding, with the padding size set to
CONFIG_SYS_FDT_PAD
However, there is no guarantee that this space is available. If using
the control FDT, then global_data is immediately above it, so expanding
the FDT and adding FDT properties will cause U-Boot to fail.
Use the CONFIG_SYS_FDT_PAD option to expand the devicetree during
relocation.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Use the SYS_FDT_PAD option instead of creating a new one
common/board_f.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c
index bff465d9cb2..5b7370b62bd 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -583,8 +583,10 @@ static int reserve_fdt(void)
* section, then it will be relocated with other data.
*/
if (gd->fdt_blob) {
- gd->boardf->fdt_size =
- ALIGN(fdt_totalsize(gd->fdt_blob), 32);
+ int size = fdt_totalsize(gd->fdt_blob);
+
+ gd->boardf->fdt_size = ALIGN(size + CONFIG_SYS_FDT_PAD,
+ 32);
gd->start_addr_sp = reserve_stack_aligned(
gd->boardf->fdt_size);
--
2.43.0
base-commit: 4c26de2eea6bcf5f27b13da0372d27d767cd38e3
branch: fdtb2
More information about the U-Boot
mailing list