Go to file
Brandon Maier 35019949c4 workflows: build: remove setuptools_scm hack
The SETUPTOOLS_SCM_PRETEND_VERSION was needed as ./setup.py would fail
without it. As setuptools_scm will fail if there is not git repo, and
the github workflow container does not include the source code git repo.

A previous commit added "fallback_version" to setuptools_scm which
instructs it to use the version from VERSION.txt when the git repo is
missing. So this hack is no longer needed.

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2023-08-06 14:53:29 +10:00
.github/workflows workflows: build: remove setuptools_scm hack 2023-08-06 14:53:29 +10:00
Documentation dtc: Add an option to generate __local_fixups__ and __fixups__ 2023-05-26 21:11:32 +10:00
libfdt libfdt: add missing version symbols 2023-08-04 18:02:33 +10:00
pylibfdt pylibtfdt: fix use of deprecated meson method 2023-08-03 12:30:55 +10:00
scripts CI: Add build matrix with multiple Linux distributions 2023-05-16 19:30:09 +10:00
tests tests: generate dtbs in Meson build directory 2023-08-04 13:15:08 +10:00
.editorconfig editorconfig: use tab indentation for version.lds 2023-08-04 18:02:21 +10:00
.gitignore pylibfdt: Move setup.py to the top level 2021-11-11 14:34:51 +11:00
BSD-2-Clause README.license: Update to reflect SPDX tag usage 2019-06-21 21:06:10 +10:00
CONTRIBUTING.md Add description of Signed-off-by lines 2022-07-29 12:55:15 +10:00
GPL Update the GPL2 text to the latest revision 2019-05-21 09:58:37 +10:00
MANIFEST.in Update README in MANIFEST.in and setup.py to README.md 2022-07-30 13:42:39 +10:00
Makefile move release version into VERSION.txt 2023-08-06 14:53:29 +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 README.license: Update to reflect SPDX tag usage 2019-06-21 21:06:10 +10:00
README.md Split out information for contributors to CONTRIBUTING.md 2022-07-28 16:25:56 +10:00
TODO dtc: Update TODO files 2007-12-19 08:20:26 -06:00
VERSION.txt move release version into VERSION.txt 2023-08-06 14:53:29 +10:00
checks.c Fix use of <ctype.h> functions 2023-07-28 20:55:34 +10:00
convert-dtsv0-lexer.l convert-dtsv0: Fix signedness comparisons warning 2020-10-13 15:48:40 +11:00
data.c dtc: Fix signedness comparisons warnings: Wrap (-1) 2020-10-13 15:58:53 +11:00
dtc-lexer.l dtc: introduce label relative path references 2022-01-25 17:10:47 +11:00
dtc-parser.y Make name_node() xstrdup its name argument 2023-03-01 17:55:35 +11:00
dtc.c dtc: Add an option to generate __local_fixups__ and __fixups__ 2023-05-26 21:11:32 +10:00
dtc.h Make name_node() xstrdup its name argument 2023-03-01 17:55:35 +11:00
dtdiff dtc: Add GPLv2 SPDX tags to files missing license text 2019-06-21 21:06:10 +10:00
fdtdump.c fdtdump: fix -Werror=int-to-pointer-cast 2021-08-26 10:58:26 +10:00
fdtget.c Support 'r' format for printing raw bytes with fdtget 2021-12-09 17:48:58 +11:00
fdtoverlay.c fdtoverlay: Drop a a repeated article 2023-04-28 16:26:39 +10:00
fdtput.c Support 'r' format for printing raw bytes with fdtget 2021-12-09 17:48:58 +11:00
flattree.c Delay xstrdup() of node and property names coming from a flat tree 2023-03-01 17:53:27 +11:00
fstree.c Make build_property() xstrdup its name argument 2023-03-01 17:47:27 +11:00
livetree.c livetree: fix off-by-one in propval_cell_n() bounds check 2023-05-14 15:22:09 +10:00
meson.build move release version into VERSION.txt 2023-08-06 14:53:29 +10:00
meson_options.txt meson: allow disabling tests 2023-07-29 13:28:40 +10:00
setup.py pylibfdt: use fallback version in tarballs 2023-08-06 14:53:29 +10:00
srcpos.c srcpos.c: fix -Wwrite-strings 2023-03-01 15:36:40 +11:00
srcpos.h dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
treesource.c dtc: Correct invalid dts output with mixed phandles and integers 2023-05-14 16:27:27 +10:00
util.c util: introduce xstrndup helper 2022-01-25 17:10:47 +11:00
util.h Add -Wsuggest-attribute=format warning, correct warnings thus generated 2023-02-27 19:18:35 +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:

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:

$ 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 pylibfdt
$ python3 -c "import libfdt; help(libfdt)"

If you add new features, please check code coverage:

$ sudo apt-get install python3-coverage
$ cd tests
# It's just 'coverage' on most other distributions
$ python3-coverage run 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 via make if you like, but pip is recommended.

To install both libfdt and pylibfdt you can use:

$ make install [PREFIX=/path/to/install_dir]

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

$ make NO_PYTHON=1

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

Mailing lists