
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.
Add a new Kconfig option to provide the required space, enabling it by default.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/board_f.c | 6 ++++-- dts/Kconfig | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/common/board_f.c b/common/board_f.c index 8baaa2341a3..ed30aeeab23 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -553,8 +553,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_OF_EXPAND, + 32);
gd->start_addr_sp = reserve_stack_aligned( gd->boardf->fdt_size); diff --git a/dts/Kconfig b/dts/Kconfig index 41a758e83a6..360611edd01 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -219,6 +219,17 @@ config OF_OMIT_DTB This is used for boards which normally provide a devicetree via a runtime mechanism (such as OF_BOARD), to avoid confusion.
+config OF_EXPAND + hex # "Amount to allow the control FDT to expand" + default SYS_FDT_PAD if OF_LIBFDT + default 0 + help + Some boards make use of the control FDT to boot an OS, thus when + image_setup_libfdt() adds extra things to the end of the FDT, there + needs to be enough space. + + Set this to the number of bytes of extra space required for the FDT. + config DEFAULT_DEVICE_TREE string "Default Device Tree for DT control" depends on OF_CONTROL