Skip to content

Commit 5ba5cbf

Browse files
Eric Schikschneittrini
authored andcommitted
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]
1 parent 0c6c806 commit 5ba5cbf

13 files changed

Lines changed: 26 additions & 14 deletions

File tree

arch/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ config SYS_CACHELINE_SIZE
6363
default 64 if RISCV
6464
default 32 if MIPS
6565

66+
config SYS_DTC_PAD_BYTES
67+
int "Size in bytes to pad device tree blob"
68+
default 32768 if X86 && EFI_APP
69+
default 4096 if ARC || ARM64 || M68K || MICROBLAZE || NIOS2 \
70+
|| RISCV || SANDBOX || X86
71+
default 0
72+
6673
config LINKER_LIST_ALIGN
6774
int
6875
default 32 if SANDBOX

arch/arc/dts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ dtb-$(CONFIG_TARGET_IOT_DEVKIT) += iot_devkit.dtb
1111
include $(srctree)/scripts/Makefile.dts
1212

1313
# Add any required device tree compiler flags here
14-
DTC_FLAGS += -R 4 -p 0x1000
14+
DTC_FLAGS += -R 4

arch/m68k/dts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ dtb-$(CONFIG_TARGET_STMARK2) += stmark2.dtb
2121
include $(srctree)/scripts/Makefile.dts
2222

2323
# Add any required device tree compiler flags here
24-
DTC_FLAGS += -R 4 -p 0x1000
24+
DTC_FLAGS += -R 4

arch/microblaze/dts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ dtb-y += $(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)).dtb
55
include $(srctree)/scripts/Makefile.dts
66

77
# Add any required device tree compiler flags here
8-
DTC_FLAGS += -R 4 -p 0x1000
8+
DTC_FLAGS += -R 4

arch/nios2/dts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ dtb-y += $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%).dtb
55
include $(srctree)/scripts/Makefile.dts
66

77
# Add any required device tree compiler flags here
8-
DTC_FLAGS += -R 4 -p 0x1000
8+
DTC_FLAGS += -R 4

arch/riscv/dts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ dtb-$(CONFIG_TARGET_ASPEED_AST2700_IBEX) += ast2700-ibex.dtb
1919
include $(srctree)/scripts/Makefile.dts
2020

2121
# Add any required device tree compiler flags here
22-
DTC_FLAGS += -R 4 -p 0x1000
22+
DTC_FLAGS += -R 4

arch/sandbox/dts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ dtb-$(CONFIG_CMD_EXTENSION) += overlay0.dtbo overlay1.dtbo
1111
include $(srctree)/scripts/Makefile.dts
1212

1313
# Add any required device tree compiler flags here
14-
DTC_FLAGS += -R 4 -p 0x1000
14+
DTC_FLAGS += -R 4

arch/x86/dts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ dtb-y += bayleybay.dtb \
2424

2525
include $(srctree)/scripts/Makefile.dts
2626

27-
DTC_FLAGS += -R 4 -p $(if $(CONFIG_EFI_APP),0x8000,0x1000)
27+
DTC_FLAGS += -R 4

doc/board/broadcom/bcm7xxx.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,8 @@ and with a generic ARMv7 root file system.
149149
* to the Linux source tree as a .dts file.
150150
*
151151
* To support modifications to the device tree
152-
* in-place in U-Boot, add to Linux's
153-
* arch/arm/boot/dts/Makefile:
154-
*
155-
* DTC_FLAGS ?= -p 4096
152+
* in-place in U-Boot, set the config variable
153+
* CONFIG_SYS_DTC_PAD_BYTES as needed.
156154
*
157155
* This will leave some padding in the DTB and
158156
* thus reserve room for node additions.

doc/develop/makefiles.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,10 +1430,13 @@ When kbuild executes, the following steps are followed (roughly):
14301430
A central rule exists to create `$(obj)/%.dtb` from `$(src)/%.dts`;
14311431
architecture Makefiles do no need to explicitly write out that rule.
14321432

1433+
The device tree can now be padded by the specified number of bytes
1434+
by setting CONFIG_SYS_DTC_PAD_BYTES instead of explicitly setting
1435+
DTC_FLAGS with the -p option.
1436+
14331437
Example::
14341438

14351439
targets += $(dtb-y)
1436-
DTC_FLAGS ?= -p 1024
14371440

14381441
7.9 Preprocessing linker scripts
14391442
--------------------------------

0 commit comments

Comments
 (0)