* [ptxdist] [RFC PATCH 0/2] Run DT schema check on selected device trees
@ 2026-07-30 13:07 Bruno Thomsen
2026-07-30 13:07 ` [ptxdist] [RFC PATCH 1/2] host-system-python: add dtschema Bruno Thomsen
2026-07-30 13:07 ` [ptxdist] [RFC PATCH 2/2] kernel: validate device trees against the DT schema Bruno Thomsen
0 siblings, 2 replies; 4+ messages in thread
From: Bruno Thomsen @ 2026-07-30 13:07 UTC (permalink / raw)
To: ptxdist; +Cc: Bruno Thomsen
From: Bruno Thomsen Bruno Thomsen <bruno.thomsen@gmail.com>
During development of new boards or preparation of upstream patches
it can be very useful to run dt-schema check on device trees.
Tested with the following PTXCONF values:
PTXCONF_KERNEL_DTS_PATH="${KERNEL_DIR}/arch/${GENERIC_KERNEL_ARCH}/boot/dts/ti/omap"
PTXCONF_KERNEL_DTS="am335x-emperor.dts am335x-emperor-mini.dts"
Bruno Thomsen (2):
host-system-python: add dtschema
kernel: validate device trees against the DT schema
platforms/kernel.in | 25 +++++++++++++++++++++++
rules/host-system-python3.in | 4 ++++
rules/host-system-python3.make | 9 +++++++++
rules/kernel.make | 36 ++++++++++++++++++++++++++++++++++
4 files changed, 74 insertions(+)
base-commit: fccbfeb4cf9fbf8a6e53d5deb5fc45d9de70aaff
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ptxdist] [RFC PATCH 1/2] host-system-python: add dtschema
2026-07-30 13:07 [ptxdist] [RFC PATCH 0/2] Run DT schema check on selected device trees Bruno Thomsen
@ 2026-07-30 13:07 ` Bruno Thomsen
2026-07-30 13:07 ` [ptxdist] [RFC PATCH 2/2] kernel: validate device trees against the DT schema Bruno Thomsen
1 sibling, 0 replies; 4+ messages in thread
From: Bruno Thomsen @ 2026-07-30 13:07 UTC (permalink / raw)
To: ptxdist; +Cc: Bruno Thomsen
Used for device tree validation.
Signed-off-by: Bruno Thomsen <bruno.thomsen@gmail.com>
---
rules/host-system-python3.in | 4 ++++
rules/host-system-python3.make | 9 +++++++++
2 files changed, 13 insertions(+)
diff --git a/rules/host-system-python3.in b/rules/host-system-python3.in
index 4d6ea7d1d..2d8296852 100644
--- a/rules/host-system-python3.in
+++ b/rules/host-system-python3.in
@@ -15,6 +15,10 @@ config HOST_SYSTEM_PYTHON3_CRYPTOGRAPHY
config HOST_SYSTEM_PYTHON3_DEV
bool
+config HOST_SYSTEM_PYTHON3_DTSCHEMA
+ select HOST_SYSTEM_PYTHON3_SYSTEM_PACKAGES
+ bool
+
config HOST_SYSTEM_PYTHON3_NUMPY
select HOST_SYSTEM_PYTHON3_SYSTEM_PACKAGES
bool
diff --git a/rules/host-system-python3.make b/rules/host-system-python3.make
index 6de4466d0..8923acfd6 100644
--- a/rules/host-system-python3.make
+++ b/rules/host-system-python3.make
@@ -42,6 +42,15 @@ ifdef PTXCONF_HOST_SYSTEM_PYTHON3_DEV
ptxd_bailout "Python development files module not found! \
Please install python3-dev (debian)";
endif
+ifdef PTXCONF_HOST_SYSTEM_PYTHON3_DTSCHEMA
+ @echo "Checking for Python dtschema ..."
+ @$(SYSTEMPYTHON3) -c 'import dtschema' 2>/dev/null || \
+ ptxd_bailout "Python dtschema module not found! \
+ Please install python3-dtschema (debian)";
+ @dt-validate --version >/dev/null 2>&1 || \
+ ptxd_bailout "'dt-validate' not found in PATH! \
+ Please install python3-dtschema (debian)";
+endif
ifdef PTXCONF_HOST_SYSTEM_PYTHON3_NUMPY
@echo "Checking for Python Numpy ..."
@$(SYSTEMPYTHON3) -c 'import numpy' 2>/dev/null || \
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ptxdist] [RFC PATCH 2/2] kernel: validate device trees against the DT schema
2026-07-30 13:07 [ptxdist] [RFC PATCH 0/2] Run DT schema check on selected device trees Bruno Thomsen
2026-07-30 13:07 ` [ptxdist] [RFC PATCH 1/2] host-system-python: add dtschema Bruno Thomsen
@ 2026-07-30 13:07 ` Bruno Thomsen
2026-08-14 8:06 ` Michael Olbrich
1 sibling, 1 reply; 4+ messages in thread
From: Bruno Thomsen @ 2026-07-30 13:07 UTC (permalink / raw)
To: ptxdist; +Cc: Bruno Thomsen
Make it possible to do device tree validation on
dts/dtsi during development and preparation for
upstream.
Signed-off-by: Bruno Thomsen <bruno.thomsen@gmail.com>
---
platforms/kernel.in | 25 +++++++++++++++++++++++++
rules/kernel.make | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/platforms/kernel.in b/platforms/kernel.in
index 2c6d906e8..79a414fd8 100644
--- a/platforms/kernel.in
+++ b/platforms/kernel.in
@@ -11,6 +11,8 @@ menuconfig KERNEL
select HOST_LZ4 if KERNEL_LZ4
select HOST_LIBKMOD if KERNEL_MODULES
select HOST_SYSTEM_BC
+ select HOST_SYSTEM_PYTHON3 if KERNEL_DTB_CHECK
+ select HOST_SYSTEM_PYTHON3_DTSCHEMA if KERNEL_DTB_CHECK
select HOST_OPENSSL if KERNEL_OPENSSL
select HOST_LIBELF if KERNEL_LIBELF
select HOST_BINDGEN_CLI if KERNEL_RUST
@@ -232,6 +234,29 @@ config KERNEL_DTSO
endif
+config KERNEL_DTB_CHECK
+ bool
+ depends on KERNEL_DTB
+ prompt "validate device trees against the DT schema"
+ help
+ Additionally build the device trees with the kernel build system
+ ('make CHECK_DTBS=y <board>.dtb') to validate them against the
+ device tree bindings in Documentation/devicetree/bindings.
+ Problems are reported as warnings, they do not break the build.
+
+ This requires the 'dtschema' python package on the build host and
+ it noticeably increases the build time of the kernel, because the
+ schema of all bindings must be processed first.
+
+ Only device trees that are part of the kernel tree can be checked.
+ Each file in KERNEL_DTS is looked up in KERNEL_DTS_PATH and the
+ first match below a 'boot/dts' directory is checked, even if the
+ device tree itself is built from an earlier entry in the search
+ path. Device trees without such a match are skipped with a
+ warning. So for device trees in a vendor directory, that directory
+ must be part of KERNEL_DTS_PATH, e.g.
+ "${KERNEL_DIR}/arch/${GENERIC_KERNEL_ARCH}/boot/dts/ti/omap".
+
config KERNEL_CODE_SIGNING
prompt "use code signing infrastructure"
select KERNEL_OPENSSL
diff --git a/rules/kernel.make b/rules/kernel.make
index af0dd3913..eaed71023 100644
--- a/rules/kernel.make
+++ b/rules/kernel.make
@@ -215,6 +215,36 @@ KERNEL_MAKE_OPT = \
$(KERNEL_IMAGE) \
$(call ptx/ifdef, PTXCONF_KERNEL_MODULES,modules)
+#
+# device tree validation
+#
+# The kernel build system can only validate device trees from the kernel tree.
+# Look up the device trees in KERNEL_DTS_PATH and use the first match below a
+# 'boot/dts' directory.
+#
+kernel/dtb-check-file = \
+ $(firstword $(foreach dts, \
+ $(call ptx/in-path-all,KERNEL_DTS_PATH,$(1)), \
+ $(if $(findstring /boot/dts/,$(dts)),$(dts))))
+
+# the dtb make targets are relative to arch/<arch>/boot/dts
+kernel/dtb-check-target = \
+ $(patsubst %.dts,%.dtb,$(patsubst /%,%,$(word 2, \
+ $(subst /boot/dts,$(ptx/def/space), \
+ $(call kernel/dtb-check-file,$(1))))))
+
+KERNEL_DTB_CHECK_FILES = $(strip \
+ $(foreach dts,$(KERNEL_DTS),$(call kernel/dtb-check-target,$(dts))))
+
+KERNEL_DTB_CHECK_SKIPPED = $(strip \
+ $(foreach dts,$(KERNEL_DTS), \
+ $(if $(call kernel/dtb-check-file,$(dts)),,$(dts))))
+
+KERNEL_DTB_CHECK_OPT = \
+ $(KERNEL_SHARED_OPT) \
+ CHECK_DTBS=y \
+ $(KERNEL_DTB_CHECK_FILES)
+
KERNEL_TOOL_PERF_OPTS := \
-C $(KERNEL_DIR)/tools/perf \
O=$(KERNEL_BUILD_DIR)/tools/perf \
@@ -263,6 +293,12 @@ $(STATEDIR)/kernel.compile:
$(KERNEL_BUILD_DIR)/usr/initramfs_data.cpio.* \
$(KERNEL_BUILD_DIR)/usr/.initramfs_data.cpio.*
@$(call world/compile, KERNEL)
+ifdef PTXCONF_KERNEL_DTB_CHECK
+ @$(foreach dts, $(KERNEL_DTB_CHECK_SKIPPED), \
+ echo "dtb-check: skipping '$(dts)': no match below 'boot/dts' in KERNEL_DTS_PATH";)
+ @$(if $(KERNEL_DTB_CHECK_FILES), \
+ $(call world/execute, KERNEL, $(MAKE) $(KERNEL_DTB_CHECK_OPT)))
+endif
ifdef PTXCONF_KERNEL_TOOL_PERF
@mkdir -p $(KERNEL_BUILD_DIR)/tools/perf
@$(call compile, KERNEL, $(KERNEL_TOOL_PERF_OPTS))
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ptxdist] [RFC PATCH 2/2] kernel: validate device trees against the DT schema
2026-07-30 13:07 ` [ptxdist] [RFC PATCH 2/2] kernel: validate device trees against the DT schema Bruno Thomsen
@ 2026-08-14 8:06 ` Michael Olbrich
0 siblings, 0 replies; 4+ messages in thread
From: Michael Olbrich @ 2026-08-14 8:06 UTC (permalink / raw)
To: Bruno Thomsen; +Cc: ptxdist
On Thu, Jul 30, 2026 at 03:07:40PM +0200, Bruno Thomsen wrote:
> Make it possible to do device tree validation on
> dts/dtsi during development and preparation for
> upstream.
>
> Signed-off-by: Bruno Thomsen <bruno.thomsen@gmail.com>
> ---
> platforms/kernel.in | 25 +++++++++++++++++++++++++
> rules/kernel.make | 36 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 61 insertions(+)
>
> diff --git a/platforms/kernel.in b/platforms/kernel.in
> index 2c6d906e8..79a414fd8 100644
> --- a/platforms/kernel.in
> +++ b/platforms/kernel.in
> @@ -11,6 +11,8 @@ menuconfig KERNEL
> select HOST_LZ4 if KERNEL_LZ4
> select HOST_LIBKMOD if KERNEL_MODULES
> select HOST_SYSTEM_BC
> + select HOST_SYSTEM_PYTHON3 if KERNEL_DTB_CHECK
> + select HOST_SYSTEM_PYTHON3_DTSCHEMA if KERNEL_DTB_CHECK
> select HOST_OPENSSL if KERNEL_OPENSSL
> select HOST_LIBELF if KERNEL_LIBELF
> select HOST_BINDGEN_CLI if KERNEL_RUST
> @@ -232,6 +234,29 @@ config KERNEL_DTSO
>
> endif
>
> +config KERNEL_DTB_CHECK
> + bool
> + depends on KERNEL_DTB
> + prompt "validate device trees against the DT schema"
> + help
> + Additionally build the device trees with the kernel build system
> + ('make CHECK_DTBS=y <board>.dtb') to validate them against the
> + device tree bindings in Documentation/devicetree/bindings.
> + Problems are reported as warnings, they do not break the build.
> +
> + This requires the 'dtschema' python package on the build host and
> + it noticeably increases the build time of the kernel, because the
> + schema of all bindings must be processed first.
> +
> + Only device trees that are part of the kernel tree can be checked.
> + Each file in KERNEL_DTS is looked up in KERNEL_DTS_PATH and the
> + first match below a 'boot/dts' directory is checked, even if the
> + device tree itself is built from an earlier entry in the search
> + path. Device trees without such a match are skipped with a
> + warning. So for device trees in a vendor directory, that directory
> + must be part of KERNEL_DTS_PATH, e.g.
> + "${KERNEL_DIR}/arch/${GENERIC_KERNEL_ARCH}/boot/dts/ti/omap".
> +
> config KERNEL_CODE_SIGNING
> prompt "use code signing infrastructure"
> select KERNEL_OPENSSL
> diff --git a/rules/kernel.make b/rules/kernel.make
> index af0dd3913..eaed71023 100644
> --- a/rules/kernel.make
> +++ b/rules/kernel.make
> @@ -215,6 +215,36 @@ KERNEL_MAKE_OPT = \
> $(KERNEL_IMAGE) \
> $(call ptx/ifdef, PTXCONF_KERNEL_MODULES,modules)
>
> +#
> +# device tree validation
> +#
> +# The kernel build system can only validate device trees from the kernel tree.
> +# Look up the device trees in KERNEL_DTS_PATH and use the first match below a
> +# 'boot/dts' directory.
> +#
> +kernel/dtb-check-file = \
> + $(firstword $(foreach dts, \
> + $(call ptx/in-path-all,KERNEL_DTS_PATH,$(1)), \
> + $(if $(findstring /boot/dts/,$(dts)),$(dts))))
> +
> +# the dtb make targets are relative to arch/<arch>/boot/dts
> +kernel/dtb-check-target = \
> + $(patsubst %.dts,%.dtb,$(patsubst /%,%,$(word 2, \
> + $(subst /boot/dts,$(ptx/def/space), \
> + $(call kernel/dtb-check-file,$(1))))))
> +
> +KERNEL_DTB_CHECK_FILES = $(strip \
> + $(foreach dts,$(KERNEL_DTS),$(call kernel/dtb-check-target,$(dts))))
> +
> +KERNEL_DTB_CHECK_SKIPPED = $(strip \
> + $(foreach dts,$(KERNEL_DTS), \
> + $(if $(call kernel/dtb-check-file,$(dts)),,$(dts))))
> +
I think this is too much complexity for the kernel.make. Instead add this
to ptxd_make_world_dtb(). That really only works with the Linux kernel
anyways.
> +KERNEL_DTB_CHECK_OPT = \
> + $(KERNEL_SHARED_OPT) \
> + CHECK_DTBS=y \
> + $(KERNEL_DTB_CHECK_FILES)
Make this conditional based on the kconfig option.
Add
pkg_dtb_check_opt="$($(1)_DTB_CHECK_OPT)"
to world/dtb/env
and use that in ptxd_make_world_dtb() to run the check if set. It will be
much cleaner to find the in-tree files there as well.
Michael
> +
> KERNEL_TOOL_PERF_OPTS := \
> -C $(KERNEL_DIR)/tools/perf \
> O=$(KERNEL_BUILD_DIR)/tools/perf \
> @@ -263,6 +293,12 @@ $(STATEDIR)/kernel.compile:
> $(KERNEL_BUILD_DIR)/usr/initramfs_data.cpio.* \
> $(KERNEL_BUILD_DIR)/usr/.initramfs_data.cpio.*
> @$(call world/compile, KERNEL)
> +ifdef PTXCONF_KERNEL_DTB_CHECK
> + @$(foreach dts, $(KERNEL_DTB_CHECK_SKIPPED), \
> + echo "dtb-check: skipping '$(dts)': no match below 'boot/dts' in KERNEL_DTS_PATH";)
> + @$(if $(KERNEL_DTB_CHECK_FILES), \
> + $(call world/execute, KERNEL, $(MAKE) $(KERNEL_DTB_CHECK_OPT)))
> +endif
> ifdef PTXCONF_KERNEL_TOOL_PERF
> @mkdir -p $(KERNEL_BUILD_DIR)/tools/perf
> @$(call compile, KERNEL, $(KERNEL_TOOL_PERF_OPTS))
> --
> 2.55.0
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-14 8:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-30 13:07 [ptxdist] [RFC PATCH 0/2] Run DT schema check on selected device trees Bruno Thomsen
2026-07-30 13:07 ` [ptxdist] [RFC PATCH 1/2] host-system-python: add dtschema Bruno Thomsen
2026-07-30 13:07 ` [ptxdist] [RFC PATCH 2/2] kernel: validate device trees against the DT schema Bruno Thomsen
2026-08-14 8:06 ` Michael Olbrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox