Skip to main content

Devicetree Schema Tools

The dtschema module contains tools and schema data for Devicetree schema validation using the json-schema vocabulary. The tools validate Devicetree files using DT binding schema files. The tools also validate the DT binding schema files. Schema files are written in a JSON compatible subset of YAML to be both human and machine readable.

Data Model

To understand how validation works, it is important to understand how schema data is organized and used. If you're reading this, I assume you're already familiar with Devicetree and the .dts file format.

In this repository you will find 2 kinds of data files; Schemas and Meta-Schemas.

Devicetree Schemas

Found under ./dtschema/schemas

Devicetree Schemas describe the format of devicetree data. The raw Devicetree file format is very open ended and doesn't restrict how data is encoded.Hence, it is easy to make mistakes when writing a Devicetree. Schema files impose the constraints on what data can be put into a Devicetree.

This repository contains the 'core' schemas which consists of DT properties defined within the DT Specification and common bindings such as the GPIO, clock, and PHY bindings.

This repository does not contain device specific bindings. Those are currently maintained within the Linux kernel tree alongside Devicetree files (.dts).

When validating, the tool will load all the schema files it can find and then iterate over all the nodes of the Devicetree. For each node, the tool will determine which schema(s) are applicable and make sure the node data matches the schema constraints. Nodes failing a schema test will emit an error. Nodes that don't match any schema can emit a warning.

As a developer, you would write a Devicetree schema file for each new device binding that you create and add it to the ./schemas directory.

Schema files also have the dual purpose of documenting a binding. When you define a new binding, you only have to create one file that contains both the machine-verifiable data format and the documentation.

Devicetree Schema files are normal YAML files using the jsonschema vocabulary.

The Devicetree Schema files are simplified to make them more compact.

The default for arrays in json-schema is they are variable sized. This can be restricted by defining 'minItems', 'maxItems', and 'additionalItems'. For DeviceTree Schemas, a fixed size is desired in most cases, so these properties are added based on the size of 'items' list.

Devicetree Meta-Schemas

Found in ./dtschema/meta-schemas

Devicetree Meta-Schemas describe the data format of Devicetree Schema files. The Meta-schemas make sure all the binding schemas are in the correct format and the tool will emit an error if the format is incorrect. json-schema by default is very relaxed in terms of what is allowed in schemas. Unknown keywords are silently ignored as an example. The DT Meta-schemas are designed to limit what is allowed and catch common errors in writing schemas.

As a developer you normally will not need to write metaschema files.

Devicetree Meta-Schema files are normal YAML files using the jsonschema vocabulary.

Usage

There are several tools available in the tools/ directory.

tools/dt-doc-validate This tool takes a schema file(s) or directory of schema files and validates them against the DT meta-schema.

Example:

dt-doc-validate -u test/schemas test/schemas/good-example.yaml

tools/dt-mk-schema This tool takes user-provided schema file(s) plus the core schema files in this repo, removes everything not needed for validation, applies fix-ups to the schemas, and outputs a single file with the processed schema. This step is optional and can be done separately to speed up subsequent validation of Devicetrees.

Example:

dt-mk-schema -j test/schemas/ > processed-schema.json

tools/dt-validate This tool takes user-provided Devicetree(s) and either a schema directory or a pre-processed schema file from dt-mk-schema, and then validates the Devicetree against the schema.

Example:

dtc -O dtb -o device.dtb test/device.dts
dt-validate -s processed-schema.json device.dtb

tools/dt-check-compatible This tool tests whether a list of compatible strings are found or not in the schemas. By default, a compatible string is printed when it matches one (or a pattern) in the schemas.

Example:

dt-check-compatible -s processed-schema.json vendor,a-compatible

Installing

The project and its dependencies can be installed with pip:

pip3 install dtschema

or directly from git:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@main

All executables will be installed. Ensure ~/.local/bin is in the PATH.

For development, clone the git repository manually and run pip on local tree::

git clone https://github.com/devicetree-org/dt-schema.git
cd dt-schema
pip3 install -e .

Dependencies

Note: The above installation instructions handle all of the dependencies automatically.

This code depends on Python 3 with the pylibfdt, ruamel.yaml, rfc3987, and jsonschema libraries. Building pylibfdt depends on the 'swig' program.

On Debian/Ubuntu, the dependencies can be installed with apt and/or pip.

sudo apt install python3 python3-jsonschema python3-libfdt python3-ruamel.yaml python3-rfc3987

On Fedora, the dependencies can be installed with dnf.

sudo dnf install python3-devel python3-jsonschema python3-libfdt python3-ruamel-yaml python3-rfc3987

Metadata

Release files for dtschema 2026.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dtschema 2026.9
File Size Uploaded
dtschema-2026.9.tar.gz 96.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dtschema 2026.9
File Interpreter ABI Platform
dtschema-2026.9-py3-none-any.whl Python 3 none any Details

Total release size: 222.8 kB

Release files / dtschema-2026.9.tar.gz

Download URL dtschema-2026.9.tar.gz
Size 96.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d50aa00414f09b7aadc776afabe623915b8f94e59d6eddef80920d6505cba671
BLAKE2b-256 checksum
How to use checksums
25610ec805ea47bc1411bcecc65d2f9fcb129455c0f859624fdc06c4a22f8579
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / dtschema-2026.9-py3-none-any.whl

Download URL dtschema-2026.9-py3-none-any.whl
Size 125.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
defcbe1be176dec69c65b9700c9cd992cba3b409976a1404b9c0b5080aa5f4c1
BLAKE2b-256 checksum
How to use checksums
3259e5fafef672bde12c0d237462e5e936650df55e2bfc46aac3164ad5d4e953
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

2026.9 This release

2 release files

2026.6

2 release files

2025.6

2 release files

2024.5

2 release files

2024.4

2 release files

2024.2

2 release files

2023.9

2 release files

2023.7

2 release files

2023.6

2 release files

2023.4

2 release files

2023.1

2 release files

2022.9

2 release files

2022.5

2 release files

2022.4

2 release files

2021.7

2 release files

2021.6

2 release files

2021.5

1 release file

2021.3

1 release file

2021.2

1 release file

2021.1

1 release file

2020.12

1 release file

2020.8

1 release file

2020.6

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page