[PATCH v2] fdt: Allow expanding the devicetree during relocation
Quentin Schulz
quentin.schulz at cherry.de
Mon May 19 10:41:27 CEST 2025
Hi Simon,
On 5/16/25 4:12 PM, Simon Glass wrote:
> 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);
> +
Maybe use unsigned long here considering that gd->boardf->fdt_size is of
that type?
Or if you want to spare a variable you can simply reuse
gd->boardf->fdt_size?
Cheers,
Quentin
More information about the U-Boot
mailing list