Skip to main content

Devicetree-to-C generator

Test status PyPI version Documentation status Supported Python versions

Dtoc converts a devicetree binary (.dtb) into C code, so that a program can use the devicetree’s data without parsing it at run time. U-Boot uses it to give SPL and TPL their devicetree data when they are too small to include libfdt, with the OF_PLATDATA options. It:

  • generates a C struct for each devicetree compatible string, holding the node’s properties with suitable C types;

  • generates the platform data for each node, along with a U_BOOT_DRVINFO() record which binds it to its driver;

  • scans the U-Boot source tree for drivers, so that each node is matched to its driver, including driver aliases and parent drivers;

  • can instead instantiate the devices and uclasses at build time, so that U-Boot does not need to bind them at run time (OF_PLATDATA_INST).

It also provides Python libraries for reading and changing devicetrees (dtoc.fdt and dtoc.fdt_util), which binman uses too.

Installation

Install the latest release from PyPI:

pip install dtoc

The dtoc command is then on your path. It needs the devicetree compiler (dtc) to compile devicetree source files.

Quick start

Generate the C files for an SPL devicetree, scanning a U-Boot tree for drivers:

dtoc -d u-boot-spl.dtb -p spl --source-dir ~/u-boot \
    -c out -C out/include all

U-Boot’s build runs dtoc like this for each phase which uses OF_PLATDATA. See the documentation linked below for the files it writes and the other options.

Documentation

Full documentation is hosted on Read the Docs:

https://dtoc.readthedocs.io/

How U-Boot uses the generated code is described in its documentation, under Compiled-in Device Tree / Platform Data.

Development

Run the test suite from a checkout:

pip install -r requirements.txt
pip install -e .[test]
dtoc -t

Most tests generate code for U-Boot’s sandbox drivers. Set UBOOT_SRC to a U-Boot source tree to include them; otherwise they are skipped. dtoc -T checks that the tests cover all of the code.

Metadata

Release files for dtoc 0.3.0

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

Source distribution (sdist)

Source distribution for dtoc 0.3.0
File Size Uploaded Provenance Actions
dtoc-0.3.0.tar.gz 74.4 kB With provenance Details for dtoc-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 161.9 kB

Release files / dtoc-0.3.0.tar.gz

Download URL dtoc-0.3.0.tar.gz
Size 74.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9f9da4600f23ed7fdd8f0a76688135a98d714b581ebca7bce13ccd8b07ad4b9c
BLAKE2b-256 checksum
How to use checksums
affa9a1529ced9d69d18c3482cd35b988ed10ea93c137798fc639eea62a97ca4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / dtoc-0.3.0-py3-none-any.whl

Download URL dtoc-0.3.0-py3-none-any.whl
Size 87.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
498447de00e430e7a3c0840789d4c280531106d4fe78bfc7823c5e8ab027f5ab
BLAKE2b-256 checksum
How to use checksums
be3c14e1c8904e4ce09902e3db1f06d3fcc4dd261c0b34bcb74db1186d82a6a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for dtoc 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dtoc-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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