[PATCH 2/8] Makefile: Add support for DT bindings schema checks

Sumit Garg sumit.garg at linaro.org
Wed Dec 20 12:27:49 CET 2023


On Wed, 20 Dec 2023 at 10:17, Simon Glass <sjg at chromium.org> wrote:
>
> Hi Sumit,
>
> On Thu, 14 Dec 2023 at 06:51, Sumit Garg <sumit.garg at linaro.org> wrote:
> >
> > This adds the build infrastructure for checking DT binding schema
> > documents and validating dtb files using the binding schema. Here we use
> > devicetree-rebasing directory to provide the DT bindings.
> >
> > Dependency:
> > -----------
> >
> > The DT schema project must be installed in order to validate the DT schema
> > binding documents and validate DTS files using the DT schema. The DT schema
> > project can be installed with pip::
> >
> >     pip3 install dtschema
> >
> > Note that 'dtschema' installation requires 'swig' and Python development
> > files installed first. On Debian/Ubuntu systems::
> >
> >     apt install swig python3-dev
> >
> > Testing:
> > --------
> >
> > Build dts files and check using DT binding schema:
> > $ make dtbs_check
> >
> > Optionally, DT_SCHEMA_FILES can be passed in with a schema file(s) to
> > use for validation. This makes it easier to find and fix errors
> > generated by a specific schema.
> >
> > Note, at this point dtbs_check is an optional build target as there are
> > many warnings generated due to custom DT properties used by many
> > platforms in u-boot. It is expected with these checks that compliance
> > with DT bindings to take place. Once that's done it can be added to CI
> > builds to remain compliant with DT bindings.
> >
> > Signed-off-by: Sumit Garg <sumit.garg at linaro.org>
> > ---
> >  Makefile             | 20 ++++++++++++++++++--
> >  scripts/Makefile.lib | 17 +++++++++++++++--
> >  2 files changed, 33 insertions(+), 4 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 750bbdb1b71..d8d168cd4c3 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1158,12 +1158,28 @@ endif
> >         @# disabling OF_BOARD.
> >         $(call cmd,ofcheck,$(KCONFIG_CONFIG))
> >
> > -PHONY += dtbs
> > +PHONY += dtbs dtbs_check
> >  dtbs: dts/dt.dtb
> >         @:
> > -dts/dt.dtb: u-boot
> > +dts/dt.dtb: dtbs_prepare u-boot
> >         $(Q)$(MAKE) $(build)=dts dtbs
> >
> > +dtbs_prepare: prepare3
> > +
> > +ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
> > +export CHECK_DTBS=y
> > +endif
> > +
> > +ifneq ($(CHECK_DTBS),)
> > +dtbs_prepare: dt_binding_check
> > +endif
> > +
> > +dtbs_check: dt_binding_check dtbs
> > +
> > +DT_BINDING_DIR := devicetree-rebasing/Bindings
> > +dt_binding_check: scripts_dtc
> > +       $(Q)$(MAKE) $(build)=$(DT_BINDING_DIR) $(DT_BINDING_DIR)/processed-schema.json
> > +
> >  quiet_cmd_copy = COPY    $@
> >        cmd_copy = cp $< $@
> >
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index 16bbc277a9f..27b9437027c 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -356,8 +356,21 @@ endif
> >
> >  dtsi_include_list_deps = $(addprefix $(obj)/,$(subst $(quote),,$(dtsi_include_list)))
> >
> > -$(obj)/%.dtb: $(src)/%.dts $(DTC) $(dtsi_include_list_deps) FORCE
> > -       $(call if_changed_dep,dtc)
> > +ifneq ($(CHECK_DTBS),)
> > +DT_CHECKER ?= dt-validate
> > +DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),-l $(DT_SCHEMA_FILES),-m)
> > +DT_BINDING_DIR := devicetree-rebasing/Bindings
> > +DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.json
> > +
> > +quiet_cmd_dtb = DTC_CHK $@
> > +      cmd_dtb = $(cmd_dtc) ; $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ || true
> > +else
> > +quiet_cmd_dtb = $(quiet_cmd_dtc)
> > +      cmd_dtb = $(cmd_dtc)
> > +endif
> > +
> > +$(obj)/%.dtb: $(src)/%.dts $(DTC) $(dtsi_include_list_deps) $(DT_TMP_SCHEMA) FORCE
> > +       $(call if_changed_dep,dtb)
> >
> >  pre-tmp = $(subst $(comma),_,$(dot-target).pre.tmp)
> >  dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
> > --
> > 2.34.1
> >
>
> This is great.
>
> Can you put the commit message in doc/ somewhere?

As per your comment on the doc patch, this is already addressed.

-Sumit

>
> Regards,
> Simon


More information about the U-Boot-Custodians mailing list