dtc: Add Kconfig option to pad device tree blob

This will allow arch(s) that use device tree blobs to pad the end of the
device tree so they can be modified by board files at run time. This will
help prevent errors such as FDT_ERR_NOSPACE from occurring.

Signed-off-by: Eric Schikschneit <eric.schikschneit@novatechautomation.com>
[trini: Change default order so that X86 && EFI_APP works correctly]
This commit is contained in:
Eric Schikschneit
2025-06-03 12:06:24 -05:00
committed by Tom Rini
parent 0c6c8065a2
commit 5ba5cbf5a2
13 changed files with 26 additions and 14 deletions

View File

@@ -63,6 +63,13 @@ config SYS_CACHELINE_SIZE
default 64 if RISCV
default 32 if MIPS
config SYS_DTC_PAD_BYTES
int "Size in bytes to pad device tree blob"
default 32768 if X86 && EFI_APP
default 4096 if ARC || ARM64 || M68K || MICROBLAZE || NIOS2 \
|| RISCV || SANDBOX || X86
default 0
config LINKER_LIST_ALIGN
int
default 32 if SANDBOX

View File

@@ -11,4 +11,4 @@ dtb-$(CONFIG_TARGET_IOT_DEVKIT) += iot_devkit.dtb
include $(srctree)/scripts/Makefile.dts
# Add any required device tree compiler flags here
DTC_FLAGS += -R 4 -p 0x1000
DTC_FLAGS += -R 4

View File

@@ -21,4 +21,4 @@ dtb-$(CONFIG_TARGET_STMARK2) += stmark2.dtb
include $(srctree)/scripts/Makefile.dts
# Add any required device tree compiler flags here
DTC_FLAGS += -R 4 -p 0x1000
DTC_FLAGS += -R 4

View File

@@ -5,4 +5,4 @@ dtb-y += $(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)).dtb
include $(srctree)/scripts/Makefile.dts
# Add any required device tree compiler flags here
DTC_FLAGS += -R 4 -p 0x1000
DTC_FLAGS += -R 4

View File

@@ -5,4 +5,4 @@ dtb-y += $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%).dtb
include $(srctree)/scripts/Makefile.dts
# Add any required device tree compiler flags here
DTC_FLAGS += -R 4 -p 0x1000
DTC_FLAGS += -R 4

View File

@@ -19,4 +19,4 @@ dtb-$(CONFIG_TARGET_ASPEED_AST2700_IBEX) += ast2700-ibex.dtb
include $(srctree)/scripts/Makefile.dts
# Add any required device tree compiler flags here
DTC_FLAGS += -R 4 -p 0x1000
DTC_FLAGS += -R 4

View File

@@ -11,4 +11,4 @@ dtb-$(CONFIG_CMD_EXTENSION) += overlay0.dtbo overlay1.dtbo
include $(srctree)/scripts/Makefile.dts
# Add any required device tree compiler flags here
DTC_FLAGS += -R 4 -p 0x1000
DTC_FLAGS += -R 4

View File

@@ -24,4 +24,4 @@ dtb-y += bayleybay.dtb \
include $(srctree)/scripts/Makefile.dts
DTC_FLAGS += -R 4 -p $(if $(CONFIG_EFI_APP),0x8000,0x1000)
DTC_FLAGS += -R 4

View File

@@ -149,10 +149,8 @@ and with a generic ARMv7 root file system.
* to the Linux source tree as a .dts file.
*
* To support modifications to the device tree
* in-place in U-Boot, add to Linux's
* arch/arm/boot/dts/Makefile:
*
* DTC_FLAGS ?= -p 4096
* in-place in U-Boot, set the config variable
* CONFIG_SYS_DTC_PAD_BYTES as needed.
*
* This will leave some padding in the DTB and
* thus reserve room for node additions.

View File

@@ -1430,10 +1430,13 @@ When kbuild executes, the following steps are followed (roughly):
A central rule exists to create `$(obj)/%.dtb` from `$(src)/%.dts`;
architecture Makefiles do no need to explicitly write out that rule.
The device tree can now be padded by the specified number of bytes
by setting CONFIG_SYS_DTC_PAD_BYTES instead of explicitly setting
DTC_FLAGS with the -p option.
Example::
targets += $(dtb-y)
DTC_FLAGS ?= -p 1024
7.9 Preprocessing linker scripts
--------------------------------

View File

@@ -6,5 +6,5 @@ include $(srctree)/scripts/Makefile.dts
DTC_FLAGS += -a 0x8
ifdef CONFIG_RCAR_64
DTC_FLAGS += -R 4 -p 0x1000
DTC_FLAGS += -R 4
endif

View File

@@ -2,5 +2,5 @@
include $(srctree)/scripts/Makefile.dts
DTC_FLAGS += -R 4 -p 0x1000
DTC_FLAGS += -R 4

View File

@@ -16,6 +16,10 @@ dtb-y += $(subst $(dt_dir)/,,$(dtb-vendor_dts))
endif
ifneq ($(CONFIG_SYS_DTC_PAD_BYTES),0)
DTC_FLAGS += -p $(CONFIG_SYS_DTC_PAD_BYTES)
endif
targets += $(dtb-y)
PHONY += dtbs