What is device tree?

Device tree is data structure (graph?) of all the the devices in a system where each device might be connected with its child devices. It provides compatable string(to identify driver) and other details for driver.

dt Bindings

Instead of reading device driver to know all the properties driver require to function properly, dt bindings are documented with the properties that should be included in device tree files.

but cross checking these device tree with documentation is often very time taking and prone to mistakes. For this reason DT schema is introduced. now new and existing device tree files can be checked with dt schema.

How to test device tree files against bindings?

make dtbs_check

this will check all dt files with all bindings. ofc this will take LOT of time

make dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/....../binding.yaml

to check all dt files with a single binding this binding could be generic as well (probably only time this command is used as this will take time to execute as well and if we want to check all the dts files with a single generic bindings)

make CHECK_DTBS=y arch/arm/boot/dts/gemini/cortina-gemini-sq201.dtb

to check a dtb file against all the bindings this is for people who wrote a new dt file and need to check if their device tree file follows the bindings correctly. note that this command is to be used on dtb file (compiled dts file)

make CHECK_DTBS=y DT_SCHEMS_FILES=Documentation/devicetree/bindings/....../binding.yaml arch/arm/boot/dts/...(.dtb)

to check one dts against against given 1 binding (can be a generic binding or device specific) this cmd is also used against dtb file

How to check if device tree binding is correct?

make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/iio/adc/adi,max14001.yaml -j16

dt_binding_check require dtschema library to work (it contains all the rules that dt schema should follow) you can check all those rules at venv/lib64/python3.14 (it’s fun to explore this rule book of lint and schema)

Internals of dt_binding_check

first of all it check the schema against meta-schemas (venv/lib64/python3.14/site-packages/dtschema/meta-schemas/core.yaml)

to have an example, it contains following rule:

allOf:
  - $ref: http://devicetree.org/meta-schemas/base.yaml#
  - description: Either unevaluatedProperties or additionalProperties must be present
    oneOf:
      - required: [ unevaluatedProperties ]
      - required: [ additionalProperties ]

that means the schema should have a ref, description and any one of unevaluatedProperties and additionalProperties

like this, it contains all other basic rules that a dt schema should follow

not only that, if the file references bu allOf or anyOf with other base files,

then comes example in schema - it checks if given schema with example and bottom of the file.

Processed schema

while running make dtbs_check, the tool of course doesn’t parse through all dt schema files, it will instead create processed schema a rule book that is union of all the dt schemas’. everytime something is changed in one of schema, whole rule book will be re written.