All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dtc: Add Kconfig option to pad device tree blob
@ 2025-05-20 18:23 Eric Schikschneit
  2025-06-02 22:31 ` Tom Rini
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schikschneit @ 2025-05-20 18:23 UTC (permalink / raw)
  To: u-boot; +Cc: Eric Schikschneit

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 occuring.

Signed-off-by: Eric Schikschneit <eric.schikschneit@novatechautomation.com>
---
 arch/Kconfig                   | 7 +++++++
 arch/arc/dts/Makefile          | 2 +-
 arch/m68k/dts/Makefile         | 2 +-
 arch/microblaze/dts/Makefile   | 2 +-
 arch/nios2/dts/Makefile        | 2 +-
 arch/riscv/dts/Makefile        | 2 +-
 arch/sandbox/dts/Makefile      | 2 +-
 arch/x86/dts/Makefile          | 2 +-
 doc/board/broadcom/bcm7xxx.rst | 6 ++----
 doc/develop/makefiles.rst      | 5 ++++-
 scripts/Makefile.dts           | 4 ++++
 11 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index ea33d07c086..a683af3d591 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -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 4096 if ARC || ARM || M68K || MICROBLAZE || NIOS2 \
+		|| RISCV || SANDBOX || X86
+	default 32768 if X86 && EFI_APP
+	default 0
+
 config LINKER_LIST_ALIGN
 	int
 	default 32 if SANDBOX
diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile
index fe6ad7b849a..87c627c01c8 100644
--- a/arch/arc/dts/Makefile
+++ b/arch/arc/dts/Makefile
@@ -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
diff --git a/arch/m68k/dts/Makefile b/arch/m68k/dts/Makefile
index 8b354b9c570..0f06109aa06 100644
--- a/arch/m68k/dts/Makefile
+++ b/arch/m68k/dts/Makefile
@@ -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
diff --git a/arch/microblaze/dts/Makefile b/arch/microblaze/dts/Makefile
index 9be902d3bb1..0f3a7472a67 100644
--- a/arch/microblaze/dts/Makefile
+++ b/arch/microblaze/dts/Makefile
@@ -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
diff --git a/arch/nios2/dts/Makefile b/arch/nios2/dts/Makefile
index d77db9762a1..75951164978 100644
--- a/arch/nios2/dts/Makefile
+++ b/arch/nios2/dts/Makefile
@@ -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
diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
index cf1872f3fdc..2b10c2d6c01 100644
--- a/arch/riscv/dts/Makefile
+++ b/arch/riscv/dts/Makefile
@@ -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
diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile
index 1c9fb4a4566..0d7b0b80e21 100644
--- a/arch/sandbox/dts/Makefile
+++ b/arch/sandbox/dts/Makefile
@@ -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
diff --git a/arch/x86/dts/Makefile b/arch/x86/dts/Makefile
index 9a46726e026..725991e2629 100644
--- a/arch/x86/dts/Makefile
+++ b/arch/x86/dts/Makefile
@@ -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
diff --git a/doc/board/broadcom/bcm7xxx.rst b/doc/board/broadcom/bcm7xxx.rst
index f1994d9f975..f559d5c290a 100644
--- a/doc/board/broadcom/bcm7xxx.rst
+++ b/doc/board/broadcom/bcm7xxx.rst
@@ -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.
diff --git a/doc/develop/makefiles.rst b/doc/develop/makefiles.rst
index 37a7deaca92..593556f4dd5 100644
--- a/doc/develop/makefiles.rst
+++ b/doc/develop/makefiles.rst
@@ -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
 --------------------------------
diff --git a/scripts/Makefile.dts b/scripts/Makefile.dts
index 685e3371bc6..3871a4ad412 100644
--- a/scripts/Makefile.dts
+++ b/scripts/Makefile.dts
@@ -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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] dtc: Add Kconfig option to pad device tree blob
  2025-05-20 18:23 Eric Schikschneit
@ 2025-06-02 22:31 ` Tom Rini
  2025-06-03 13:57   ` Eric Schikschneit
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Rini @ 2025-06-02 22:31 UTC (permalink / raw)
  To: Eric Schikschneit; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 1963 bytes --]

On Tue, May 20, 2025 at 01:23:05PM -0500, Eric Schikschneit wrote:

> 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 occuring.
> 
> Signed-off-by: Eric Schikschneit <eric.schikschneit@novatechautomation.com>

I was testing merging this and I found a few problems, sorry.

> ---
>  arch/Kconfig                   | 7 +++++++
>  arch/arc/dts/Makefile          | 2 +-
>  arch/m68k/dts/Makefile         | 2 +-
>  arch/microblaze/dts/Makefile   | 2 +-
>  arch/nios2/dts/Makefile        | 2 +-
>  arch/riscv/dts/Makefile        | 2 +-
>  arch/sandbox/dts/Makefile      | 2 +-
>  arch/x86/dts/Makefile          | 2 +-
>  doc/board/broadcom/bcm7xxx.rst | 6 ++----
>  doc/develop/makefiles.rst      | 5 ++++-
>  scripts/Makefile.dts           | 4 ++++
>  11 files changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/Kconfig b/arch/Kconfig
> index ea33d07c086..a683af3d591 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -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 4096 if ARC || ARM || M68K || MICROBLAZE || NIOS2 \
> +		|| RISCV || SANDBOX || X86
> +	default 32768 if X86 && EFI_APP
> +	default 0

I believe this is the logic I suggested and so the problem is on me. For
ARM && ARM64, this is right. But for 32bit ARM, we should be 0 and let
individual boards set this as needed (none today but your board does
need it). This leads to size growth and then failure on a few platforms
is how I noticed this.

The second problem is that the Makefiles in dts/upstream are confusingly
not 100% upstream things and so also need to have -p 0x1000 taken out of
them as they'll get the value this way instead.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] dtc: Add Kconfig option to pad device tree blob
  2025-06-02 22:31 ` Tom Rini
@ 2025-06-03 13:57   ` Eric Schikschneit
  2025-06-03 16:01     ` Tom Rini
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schikschneit @ 2025-06-03 13:57 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot@lists.denx.de

Tom,

I think I understand the problems you stated. Obviously, we do not want to cause any regressions,
and I am happy to modify my patch as you suggest. I am unsure what to do about your dts/upstream
Issue though being that portion gets synced from the linux kernel source tree, correct? As far as the
ARM / ARM64 issue I could change the default lines to something similar to:

default  4096 if ARC || ARM64 || M68K.....
default 32768 if X86 && EFI_APP
default 0

That should allow 64-bit ARM platforms to be 4096, but 32-bit ARM platforms to still default to 0.


Eric Schikschneit

Senior Embedded Linux Engineer III  ​



NovaTech, LLC

13555 W. 107th Street | Lenexa, KS 66215​

O: 913.451.1880​

  ​

novatechautomation.com<http://www.novatechautomation.com/> | NovaTechLinkedIn<https://www.linkedin.com/company/565017>

Receipt of this email implies compliance with our terms and conditions<https://www.novatechautomation.com/email-terms-conditions>.


________________________________
From: Tom Rini
Sent: Monday, June 2, 2025 5:31 PM
To: Eric Schikschneit
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH] dtc: Add Kconfig option to pad device tree blob

On Tue, May 20, 2025 at 01:23:05PM -0500, Eric Schikschneit wrote:

> 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 occuring.
>
> Signed-off-by: Eric Schikschneit <eric.schikschneit@novatechautomation.com>

I was testing merging this and I found a few problems, sorry.

> ---
>  arch/Kconfig                   | 7 +++++++
>  arch/arc/dts/Makefile          | 2 +-
>  arch/m68k/dts/Makefile         | 2 +-
>  arch/microblaze/dts/Makefile   | 2 +-
>  arch/nios2/dts/Makefile        | 2 +-
>  arch/riscv/dts/Makefile        | 2 +-
>  arch/sandbox/dts/Makefile      | 2 +-
>  arch/x86/dts/Makefile          | 2 +-
>  doc/board/broadcom/bcm7xxx.rst | 6 ++----
>  doc/develop/makefiles.rst      | 5 ++++-
>  scripts/Makefile.dts           | 4 ++++
>  11 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index ea33d07c086..a683af3d591 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -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 4096 if ARC || ARM || M68K || MICROBLAZE || NIOS2 \
> +             || RISCV || SANDBOX || X86
> +     default 32768 if X86 && EFI_APP
> +     default 0

I believe this is the logic I suggested and so the problem is on me. For
ARM && ARM64, this is right. But for 32bit ARM, we should be 0 and let
individual boards set this as needed (none today but your board does
need it). This leads to size growth and then failure on a few platforms
is how I noticed this.

The second problem is that the Makefiles in dts/upstream are confusingly
not 100% upstream things and so also need to have -p 0x1000 taken out of
them as they'll get the value this way instead.

--
Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] dtc: Add Kconfig option to pad device tree blob
  2025-06-03 13:57   ` Eric Schikschneit
@ 2025-06-03 16:01     ` Tom Rini
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2025-06-03 16:01 UTC (permalink / raw)
  To: Eric Schikschneit; +Cc: u-boot@lists.denx.de

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

On Tue, Jun 03, 2025 at 01:57:14PM +0000, Eric Schikschneit wrote:

> Tom,
> 
> I think I understand the problems you stated. Obviously, we do not want to cause any regressions,
> and I am happy to modify my patch as you suggest. I am unsure what to do about your dts/upstream
> Issue though being that portion gets synced from the linux kernel source tree, correct? As far as the
> ARM / ARM64 issue I could change the default lines to something similar to:
> 
> default  4096 if ARC || ARM64 || M68K.....
> default 32768 if X86 && EFI_APP
> default 0
> 
> That should allow 64-bit ARM platforms to be 4096, but 32-bit ARM platforms to still default to 0.

The Kconfig fragment looks fine, yes. What I mean about
dts/upstream/.../Makefile is that you should modify those too as they're
the small part of the infrastructure there that's what we modified.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] dtc: Add Kconfig option to pad device tree blob
@ 2025-06-03 17:06 Eric Schikschneit
  2025-06-09  8:26 ` Anshul Dalal
  2025-06-20 13:58 ` Tom Rini
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Schikschneit @ 2025-06-03 17:06 UTC (permalink / raw)
  To: u-boot, trini; +Cc: Eric Schikschneit

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 occuring.

Signed-off-by: Eric Schikschneit <eric.schikschneit@novatechautomation.com>
---
 arch/Kconfig                    | 7 +++++++
 arch/arc/dts/Makefile           | 2 +-
 arch/m68k/dts/Makefile          | 2 +-
 arch/microblaze/dts/Makefile    | 2 +-
 arch/nios2/dts/Makefile         | 2 +-
 arch/riscv/dts/Makefile         | 2 +-
 arch/sandbox/dts/Makefile       | 2 +-
 arch/x86/dts/Makefile           | 2 +-
 doc/board/broadcom/bcm7xxx.rst  | 6 ++----
 doc/develop/makefiles.rst       | 5 ++++-
 dts/upstream/src/arm64/Makefile | 2 +-
 dts/upstream/src/riscv/Makefile | 2 +-
 scripts/Makefile.dts            | 4 ++++
 13 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index ea33d07c086..bf4c2c80891 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -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 4096 if ARC || ARM64 || M68K || MICROBLAZE || NIOS2 \
+		|| RISCV || SANDBOX || X86
+	default 32768 if X86 && EFI_APP
+	default 0
+
 config LINKER_LIST_ALIGN
 	int
 	default 32 if SANDBOX
diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile
index fe6ad7b849a..87c627c01c8 100644
--- a/arch/arc/dts/Makefile
+++ b/arch/arc/dts/Makefile
@@ -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
diff --git a/arch/m68k/dts/Makefile b/arch/m68k/dts/Makefile
index 8b354b9c570..0f06109aa06 100644
--- a/arch/m68k/dts/Makefile
+++ b/arch/m68k/dts/Makefile
@@ -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
diff --git a/arch/microblaze/dts/Makefile b/arch/microblaze/dts/Makefile
index 9be902d3bb1..0f3a7472a67 100644
--- a/arch/microblaze/dts/Makefile
+++ b/arch/microblaze/dts/Makefile
@@ -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
diff --git a/arch/nios2/dts/Makefile b/arch/nios2/dts/Makefile
index d77db9762a1..75951164978 100644
--- a/arch/nios2/dts/Makefile
+++ b/arch/nios2/dts/Makefile
@@ -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
diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
index cf1872f3fdc..2b10c2d6c01 100644
--- a/arch/riscv/dts/Makefile
+++ b/arch/riscv/dts/Makefile
@@ -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
diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile
index 1c9fb4a4566..0d7b0b80e21 100644
--- a/arch/sandbox/dts/Makefile
+++ b/arch/sandbox/dts/Makefile
@@ -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
diff --git a/arch/x86/dts/Makefile b/arch/x86/dts/Makefile
index 9a46726e026..725991e2629 100644
--- a/arch/x86/dts/Makefile
+++ b/arch/x86/dts/Makefile
@@ -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
diff --git a/doc/board/broadcom/bcm7xxx.rst b/doc/board/broadcom/bcm7xxx.rst
index f1994d9f975..f559d5c290a 100644
--- a/doc/board/broadcom/bcm7xxx.rst
+++ b/doc/board/broadcom/bcm7xxx.rst
@@ -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.
diff --git a/doc/develop/makefiles.rst b/doc/develop/makefiles.rst
index 37a7deaca92..593556f4dd5 100644
--- a/doc/develop/makefiles.rst
+++ b/doc/develop/makefiles.rst
@@ -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
 --------------------------------
diff --git a/dts/upstream/src/arm64/Makefile b/dts/upstream/src/arm64/Makefile
index b6db0dc6b26..01a5265114e 100644
--- a/dts/upstream/src/arm64/Makefile
+++ b/dts/upstream/src/arm64/Makefile
@@ -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
diff --git a/dts/upstream/src/riscv/Makefile b/dts/upstream/src/riscv/Makefile
index 980617e6de3..43351f801db 100644
--- a/dts/upstream/src/riscv/Makefile
+++ b/dts/upstream/src/riscv/Makefile
@@ -2,5 +2,5 @@
 
 include $(srctree)/scripts/Makefile.dts
 
-DTC_FLAGS += -R 4 -p 0x1000
+DTC_FLAGS += -R 4
 
diff --git a/scripts/Makefile.dts b/scripts/Makefile.dts
index 685e3371bc6..3871a4ad412 100644
--- a/scripts/Makefile.dts
+++ b/scripts/Makefile.dts
@@ -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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] dtc: Add Kconfig option to pad device tree blob
  2025-06-03 17:06 [PATCH] dtc: Add Kconfig option to pad device tree blob Eric Schikschneit
@ 2025-06-09  8:26 ` Anshul Dalal
  2025-06-09 14:56   ` Tom Rini
  2025-06-20 13:58 ` Tom Rini
  1 sibling, 1 reply; 8+ messages in thread
From: Anshul Dalal @ 2025-06-09  8:26 UTC (permalink / raw)
  To: Eric Schikschneit, u-boot, trini

On Tue Jun 3, 2025 at 10:36 PM IST, Eric Schikschneit wrote:
> 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 occuring.
>
> Signed-off-by: Eric Schikschneit <eric.schikschneit@novatechautomation.com>
> ---
>  arch/Kconfig                    | 7 +++++++
>  arch/arc/dts/Makefile           | 2 +-
>  arch/m68k/dts/Makefile          | 2 +-
>  arch/microblaze/dts/Makefile    | 2 +-
>  arch/nios2/dts/Makefile         | 2 +-
>  arch/riscv/dts/Makefile         | 2 +-
>  arch/sandbox/dts/Makefile       | 2 +-
>  arch/x86/dts/Makefile           | 2 +-
>  doc/board/broadcom/bcm7xxx.rst  | 6 ++----
>  doc/develop/makefiles.rst       | 5 ++++-
>  dts/upstream/src/arm64/Makefile | 2 +-
>  dts/upstream/src/riscv/Makefile | 2 +-
>  scripts/Makefile.dts            | 4 ++++
>  13 files changed, 26 insertions(+), 14 deletions(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index ea33d07c086..bf4c2c80891 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -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 4096 if ARC || ARM64 || M68K || MICROBLAZE || NIOS2 \
> +		|| RISCV || SANDBOX || X86
> +	default 32768 if X86 && EFI_APP
> +	default 0
> +
>  config LINKER_LIST_ALIGN
>  	int
>  	default 32 if SANDBOX
> diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile
> index fe6ad7b849a..87c627c01c8 100644
> --- a/arch/arc/dts/Makefile
> +++ b/arch/arc/dts/Makefile
> @@ -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

Thanks for the patch Eric, the changes to padding size look good to me
although I wonder if we should expose the -R flag for configuring the
number of /reserved-memory to user under Kconfig as well.

We have it hardcoded to 4 everywhere now, might be useful to expose it
as CONFIG_SYS_DTC_RSVD or similar for users looking to create compact
DTBs (-R 0) or where more reserved regions need to be added at runtime.

Regards,
Anshul

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] dtc: Add Kconfig option to pad device tree blob
  2025-06-09  8:26 ` Anshul Dalal
@ 2025-06-09 14:56   ` Tom Rini
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Rini @ 2025-06-09 14:56 UTC (permalink / raw)
  To: Anshul Dalal; +Cc: Eric Schikschneit, u-boot

[-- Attachment #1: Type: text/plain, Size: 2591 bytes --]

On Mon, Jun 09, 2025 at 01:56:26PM +0530, Anshul Dalal wrote:
> On Tue Jun 3, 2025 at 10:36 PM IST, Eric Schikschneit wrote:
> > 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 occuring.
> >
> > Signed-off-by: Eric Schikschneit <eric.schikschneit@novatechautomation.com>
> > ---
> >  arch/Kconfig                    | 7 +++++++
> >  arch/arc/dts/Makefile           | 2 +-
> >  arch/m68k/dts/Makefile          | 2 +-
> >  arch/microblaze/dts/Makefile    | 2 +-
> >  arch/nios2/dts/Makefile         | 2 +-
> >  arch/riscv/dts/Makefile         | 2 +-
> >  arch/sandbox/dts/Makefile       | 2 +-
> >  arch/x86/dts/Makefile           | 2 +-
> >  doc/board/broadcom/bcm7xxx.rst  | 6 ++----
> >  doc/develop/makefiles.rst       | 5 ++++-
> >  dts/upstream/src/arm64/Makefile | 2 +-
> >  dts/upstream/src/riscv/Makefile | 2 +-
> >  scripts/Makefile.dts            | 4 ++++
> >  13 files changed, 26 insertions(+), 14 deletions(-)
> >
> > diff --git a/arch/Kconfig b/arch/Kconfig
> > index ea33d07c086..bf4c2c80891 100644
> > --- a/arch/Kconfig
> > +++ b/arch/Kconfig
> > @@ -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 4096 if ARC || ARM64 || M68K || MICROBLAZE || NIOS2 \
> > +		|| RISCV || SANDBOX || X86
> > +	default 32768 if X86 && EFI_APP
> > +	default 0
> > +
> >  config LINKER_LIST_ALIGN
> >  	int
> >  	default 32 if SANDBOX
> > diff --git a/arch/arc/dts/Makefile b/arch/arc/dts/Makefile
> > index fe6ad7b849a..87c627c01c8 100644
> > --- a/arch/arc/dts/Makefile
> > +++ b/arch/arc/dts/Makefile
> > @@ -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
> 
> Thanks for the patch Eric, the changes to padding size look good to me
> although I wonder if we should expose the -R flag for configuring the
> number of /reserved-memory to user under Kconfig as well.
> 
> We have it hardcoded to 4 everywhere now, might be useful to expose it
> as CONFIG_SYS_DTC_RSVD or similar for users looking to create compact
> DTBs (-R 0) or where more reserved regions need to be added at runtime.

That could be an interesting follow-up patch, yes.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] dtc: Add Kconfig option to pad device tree blob
  2025-06-03 17:06 [PATCH] dtc: Add Kconfig option to pad device tree blob Eric Schikschneit
  2025-06-09  8:26 ` Anshul Dalal
@ 2025-06-20 13:58 ` Tom Rini
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Rini @ 2025-06-20 13:58 UTC (permalink / raw)
  To: u-boot, Eric Schikschneit

On Tue, 03 Jun 2025 12:06:24 -0500, Eric Schikschneit wrote:

> 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 occuring.
> 
> 

Applied to u-boot/next, thanks!

[1/1] dtc: Add Kconfig option to pad device tree blob
      commit: 5ba5cbf5a29d54763f30b6685e6c06ffd51d29eb
-- 
Tom



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-20 13:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 17:06 [PATCH] dtc: Add Kconfig option to pad device tree blob Eric Schikschneit
2025-06-09  8:26 ` Anshul Dalal
2025-06-09 14:56   ` Tom Rini
2025-06-20 13:58 ` Tom Rini
  -- strict thread matches above, loose matches on Subject: below --
2025-05-20 18:23 Eric Schikschneit
2025-06-02 22:31 ` Tom Rini
2025-06-03 13:57   ` Eric Schikschneit
2025-06-03 16:01     ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.