Go to file
Douglas Anderson 54e547173b libfdt: overlay: Make fdto const in overlay_apply_node()
`overlay_apply_node()` only reads from the overlay blob `@fdto` while
merging properties and subnodes into `@fdt`. Mark `@fdto` as
`const void *` so callers holding a `const void *fdto` pointer (such as
the upcoming `/__local_fixups__` update logic) can call
`overlay_apply_node()` without casting away `const`.

Assisted-by: Gemini:gemini-pro-prerelease
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Message-ID: <20261101220224.1436242-11-dianders@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2026-11-04 17:22:44 +11:00
.github/workflows libfdt: Find a node's parent in a single pass 2026-10-27 13:14:52 +11:00
Documentation fdtput: Correct the description of -t in the manual 2026-10-28 12:45:39 +11:00
libfdt libfdt: overlay: Make fdto const in overlay_apply_node() 2026-11-04 17:22:44 +11:00
pylibfdt pylibfdt: Support copy.copy() and copy.deepcopy() on Property 2026-11-02 15:38:53 +11:00
scripts scripts: Report failures in scripts/install-deps.sh 2026-10-19 12:50:24 +11:00
tests tests: Allow dtc-fatal.sh to check the error message 2026-11-03 09:36:43 -07:00
.clang-format Add clang-format config 2024-12-06 14:44:46 +11:00
.editorconfig editorconfig: use tab indentation for version.lds 2023-08-04 18:02:21 +10:00
.gitignore pylibfdt: clean up python build directory 2024-07-01 11:49:27 +10:00
.gitlab-ci.yml ci: Add GitLab CI configuration for Linux builds 2025-08-01 15:46:48 +10:00
AGENTS.md tests: More portable installation of SIGINT handler 2026-05-28 13:55:51 +10:00
BSD-2-Clause README.license: Update to reflect SPDX tag usage 2019-06-21 21:06:10 +10:00
CLAUDE.md docs: Add CLAUDE.md referencing AGENTS.md 2026-05-26 17:50:29 +10:00
CONTRIBUTING.md README: Explain how to build with meson 2026-10-30 06:52:57 -06:00
GPL Update the GPL2 text to the latest revision 2019-05-21 09:58:37 +10:00
Makefile ci: Add macOS build to GitHub Actions 2026-05-26 17:52:08 +10:00
Makefile.convert-dtsv0 dtc: Add GPLv2 SPDX tags to files missing license text 2019-06-21 21:06:10 +10:00
Makefile.dtc dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
Makefile.utils dtc: Add GPLv2 SPDX tags to files missing license text 2019-06-21 21:06:10 +10:00
README.license Fix some typos 2025-03-14 13:50:32 +11:00
README.md README: Use meson in the Python section 2026-10-30 06:52:57 -06:00
TODO dtc: Update TODO files 2007-12-19 08:20:26 -06:00
VERSION.txt Bump version to v1.8.1 2026-05-28 12:40:45 +10:00
checks.c checks: Add missing phandle_references prereq to interrupts_property 2026-05-16 16:31:39 +10:00
convert-dtsv0-lexer.l convert-dtsv0: Fix signedness comparisons warning 2020-10-13 15:48:40 +11:00
data.c dtc: Add data_insert_data function 2025-06-12 16:37:31 +10:00
dtc-lexer.l dtc: Remove unused dts_version in dtc-lexer.l 2026-03-27 20:20:54 +11:00
dtc-parser.y dtc-parser.y: Avoid an empty proplist 2026-10-14 20:16:02 +11:00
dtc.c dtc: Move fill_fullpaths() into build_dt_info() 2026-10-19 13:04:22 +11:00
dtc.h dtc: Use a consistent type for basenamelen 2026-02-13 16:27:22 +11:00
dtdiff dtdiff: Use input format dtb for dtbo files 2025-07-01 20:42:22 +10:00
fdtdump.c fdtdump: Return an error code on wrong tag value 2026-02-24 16:52:47 +11:00
fdtget.c fdtget: Use libfdt iterators instead of open coded loops 2026-08-27 13:48:09 +10:00
fdtoverlay.c fdtoverlay: provide better error message for missing `/__symbols__` 2024-10-30 16:01:37 +11:00
fdtput.c fdtput: Name the property when it cannot be deleted 2026-10-29 12:59:28 +11:00
flattree.c Set DTSF_PLUGIN if needed when compiling from dtb 2026-01-16 12:02:30 +11:00
fstree.c Make build_property() xstrdup its name argument 2023-03-01 17:47:27 +11:00
livetree.c dtc: Move fill_fullpaths() into build_dt_info() 2026-10-19 13:04:22 +11:00
meson.build meson: Only take the version from dtc's own git repository 2026-10-07 15:45:24 +11:00
meson_options.txt meson: port python bindings to build natively via meson and meson-python 2025-05-01 19:27:10 +07:00
pyproject.toml meson: port python bindings to build natively via meson and meson-python 2025-05-01 19:27:10 +07:00
srcpos.c Consider drive letters when checking for absolute paths on Windows. 2025-08-07 21:42:42 +10:00
srcpos.h srcpos: Define srcpos_free 2025-06-09 22:27:00 +10:00
treesource.c Restore phandle references from __fixups__ node 2026-01-16 13:45:59 +11:00
util.c Escape spaces in depfile with backslashes. 2024-10-24 15:44:47 +11:00
util.h Escape spaces in depfile with backslashes. 2024-10-24 15:44:47 +11:00
version_gen.h.in build-sys: add meson build 2020-10-21 14:36:07 +11:00
yamltree.c Fix use of <ctype.h> functions 2023-07-28 20:55:34 +10:00

README.md

Device Tree Compiler and libfdt

The source tree contains the Device Tree Compiler (dtc) toolchain for working with device tree source and binary files and also libfdt, a utility library for reading and manipulating the binary format.

dtc and libfdt are maintained by:

Building

dtc and libfdt are built with Meson:

$ meson setup build
$ meson compile -C build
$ meson test -C build
$ meson install -C build

meson configure build lists the build options, e.g. -Dpython=disabled to skip the Python library. See the Meson quick guide for more, such as installing with --destdir. scripts/install-deps.sh installs the packages needed on common systems.

Building with make still works but is deprecated.

Python library

A Python library wrapping libfdt is also available. To build this you will need to install swig and Python development files. On Debian distributions:

$ sudo apt-get install swig python3-dev

The library provides an Fdt class which you can use like this, from build/tests after running the tests:

$ PYTHONPATH=../pylibfdt python3
>>> import libfdt
>>> fdt = libfdt.Fdt(open('test_tree1.dtb', mode='rb').read())
>>> node = fdt.path_offset('/subnode@1')
>>> print(node)
124
>>> prop_offset = fdt.first_property_offset(node)
>>> prop = fdt.get_property_by_offset(prop_offset)
>>> print('%s=%s' % (prop.name, prop.as_str()))
compatible=subnode1
>>> node2 = fdt.path_offset('/')
>>> print(fdt.getprop(node2, 'compatible').as_str())
test_tree1

You will find tests in tests/pylibfdt_tests.py showing how to use each method. Help is available using the Python help command, e.g.:

$ cd build/pylibfdt
$ python3 -c "import libfdt; help(libfdt)"

If you add new features, please check code coverage:

$ sudo apt-get install python3-coverage
$ cd build/tests
# It's just 'coverage' on most other distributions
$ python3-coverage run ../../tests/pylibfdt_tests.py
$ python3-coverage html
# Open 'htmlcov/index.html' in your browser

The library can be installed with pip from a local source tree:

$ pip install . [--user|--prefix=/path/to/install_dir]

Or directly from a remote git repo:

$ pip install git+git://git.kernel.org/pub/scm/utils/dtc/dtc.git@main

The install depends on libfdt shared library being installed on the host system first. Generally, using --user or --prefix is not necessary and pip will use the default location for the Python installation which varies if the user is root or not.

You can also install everything with meson if you like, but pip is recommended.

To install both libfdt and pylibfdt you can use:

$ meson setup [--prefix=/path/to/install_dir] build
$ meson install -C build

To disable building the python library, even if swig and Python are available, use:

$ meson setup -Dpython=disabled build

More work remains to support all of libfdt, including access to numeric values.

Mailing lists