]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
dtc: Add Kconfig option to pad device tree blob
authorEric Schikschneit <eric.schikschneit@novatechautomation.com>
Tue, 3 Jun 2025 17:06:24 +0000 (12:06 -0500)
committerTom Rini <trini@konsulko.com>
Fri, 20 Jun 2025 01:00:09 +0000 (19:00 -0600)
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]

13 files changed:
arch/Kconfig
arch/arc/dts/Makefile
arch/m68k/dts/Makefile
arch/microblaze/dts/Makefile
arch/nios2/dts/Makefile
arch/riscv/dts/Makefile
arch/sandbox/dts/Makefile
arch/x86/dts/Makefile
doc/board/broadcom/bcm7xxx.rst
doc/develop/makefiles.rst
dts/upstream/src/arm64/Makefile
dts/upstream/src/riscv/Makefile
scripts/Makefile.dts

index ea33d07c086bf577e171e9ae5ade21141ffe788f..597b40ffd60f785d04f5f954d80f3b7188781fde 100644 (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
index fe6ad7b849aa4abe0326a0ae05d25e12683923d1..87c627c01c8eddcf02102d599921292ff3bca990 100644 (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
index 8b354b9c570c9eb2aa610b735ee5552daa8103a8..0f06109aa06c4030b7202d3480048ce0973fd3af 100644 (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
index 9be902d3bb1380365779e0d1767d17dce9de67b0..0f3a7472a673c3d9c544b75da16baa21d2ffaecd 100644 (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
index d77db9762a1d20373009b8f825a0d3839468b0a6..75951164978f52676adff6e055071ce51b198b6d 100644 (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
index cf1872f3fdc397e6c1ccf533ebfea8421dd967d1..2b10c2d6c019a254278692b545aa91a6a2de399d 100644 (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
index 1c9fb4a45669fecd356acc7d48c3ba931c400154..0d7b0b80e21ecfa640411dbe2edcb09410d4cfc1 100644 (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
index 9a46726e0266bfaf44ddef498dfae6d40ab576da..725991e2629d0a1bd28469a70a6465254ac67deb 100644 (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
index f1994d9f975dba7910f7dbacc3258ba3d3550f08..f559d5c290a5e6a8250db8e60f5e0927795ebcc5 100644 (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.
index 37a7deaca925d42c05f747fdf24404463db29b2d..593556f4dd5d08e99b3ae97ecfde912809ddb175 100644 (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
 --------------------------------
index b6db0dc6b26ec2d7064e8880574c268bce01382c..01a5265114ecb68607690fc0b78e05f29654d7b4 100644 (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
index 980617e6de331aba237af5c42f0c297ae494148e..43351f801dbb2d58cba85a46164ea0f71eb2dfc4 100644 (file)
@@ -2,5 +2,5 @@
 
 include $(srctree)/scripts/Makefile.dts
 
-DTC_FLAGS += -R 4 -p 0x1000
+DTC_FLAGS += -R 4
 
index 685e3371bc67d791142887e9cbff751c163380e7..3871a4ad4123c4520aca3c9141be730fdfcfd30d 100644 (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