From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 14 Aug 2026 10:06:34 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wumvx-002yiW-2a for lore@lore.pengutronix.de; Fri, 14 Aug 2026 10:06:34 +0200 Received: from [127.0.0.1] (helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1wumvw-0007Ho-Bj; Fri, 14 Aug 2026 10:06:32 +0200 Received: from mx1.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::107]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1wumvo-0007Au-S7 for ptxdist@pengutronix.de; Fri, 14 Aug 2026 10:06:24 +0200 Received: from drehscheibe.grey.stw.pengutronix.de (drehscheibe.grey.stw.pengutronix.de [IPv6:2a0a:edc0:0:c01:1d::a2]) (Authenticated sender: relay-from-drehscheibe.grey.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id 73003201D0E; Fri, 14 Aug 2026 10:06:24 +0200 (CEST) Received: from pty.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::c5]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wumvo-001QGQ-1G; Fri, 14 Aug 2026 10:06:24 +0200 Received: from mol by pty.whiteo.stw.pengutronix.de with local (Exim 4.98.2) (envelope-from ) id 1wumvo-00000001iuI-19ey; Fri, 14 Aug 2026 10:06:24 +0200 Date: Fri, 14 Aug 2026 10:06:24 +0200 From: Michael Olbrich To: Bruno Thomsen Message-ID: Mail-Followup-To: Bruno Thomsen , ptxdist@pengutronix.de References: <20260730130740.10851-1-bruno.thomsen@gmail.com> <20260730130740.10851-3-bruno.thomsen@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260730130740.10851-3-bruno.thomsen@gmail.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-IRC: #ptxdist @freenode Subject: Re: [ptxdist] [RFC PATCH 2/2] kernel: validate device trees against the DT schema X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Cc: ptxdist@pengutronix.de Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false 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 > --- > 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 .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//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 |