No description
Find a file
Marc-André Lureau 588a29ff2e util: use gnu_printf format attribute
dtc uses non-portable formats. Using gnu_printf attributes (for
warnings) in combination with __USE_MINGW_ANSI_STDIO allows to build
for win32.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20191009102025.10179-8-marcandre.lureau@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14 17:07:46 +11:00
Documentation Fix typos in various documentation and source files 2019-05-21 10:01:01 +10:00
libfdt libfdt.h: add explicit cast from void* to uint8_t* in fdt(32|64)_st 2019-09-10 23:11:40 +10:00
pylibfdt pylibfdt: use python3 shebang 2019-09-09 15:20:55 +10:00
scripts dtc: Add GPLv2 SPDX tags to files missing license text 2019-06-21 21:06:10 +10:00
tests dumptrees: pass outputdir as first argument 2019-10-14 16:20:32 +11:00
.editorconfig Add .editorconfig 2019-10-09 22:41:44 +11:00
.gitignore Add fdtoverlay to .gitignore 2017-09-27 20:00:10 +10:00
.travis.yml Add support for YAML encoded output 2018-09-13 11:39:03 +10:00
BSD-2-Clause README.license: Update to reflect SPDX tag usage 2019-06-21 21:06:10 +10:00
checks.c Ignore phandle properties in /aliases 2019-09-04 14:58:28 +10:00
convert-dtsv0-lexer.l dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
data.c dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
dtc-lexer.l dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
dtc-parser.y dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
dtc.c dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
dtc.h dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
dtdiff dtc: Add GPLv2 SPDX tags to files missing license text 2019-06-21 21:06:10 +10:00
fdtdump.c dtc: Add GPLv2 SPDX tags to files missing license text 2019-06-21 21:06:10 +10:00
fdtget.c dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
fdtoverlay.c fdtoverlay: Return non-zero exit code if overlays can't be applied 2019-10-11 15:58:18 +11:00
fdtput.c dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
flattree.c dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
fstree.c fstree: replace lstat with stat 2019-10-14 17:07:10 +11:00
GPL Update the GPL2 text to the latest revision 2019-05-21 09:58:37 +10:00
livetree.c livetree: simplify condition in get_node_by_path 2019-08-28 13:57:27 +10:00
Makefile Makefile: Add EXTRA_CFLAGS variable 2019-07-22 13:13:24 +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 README: update for Python 3 2019-08-29 11:06:11 +10:00
README.license README.license: Update to reflect SPDX tag usage 2019-06-21 21:06:10 +10:00
srcpos.c dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
srcpos.h dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
TODO dtc: Update TODO files 2007-12-19 08:20:26 -06:00
treesource.c dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
util.c dtc: Replace GPLv2 boilerplate/reference with SPDX tags 2019-06-21 21:06:10 +10:00
util.h util: use gnu_printf format attribute 2019-10-14 17:07:46 +11:00
yamltree.c yamltree: Ensure consistent bracketing of properties with phandles 2019-09-25 11:48:50 +10:00

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:

David Gibson <david@gibson.dropbear.id.au>
Jon Loeliger <jdl@jdl.com>


Python library
--------------

A Python library 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


To install the library via the normal setup.py method, use:

    ./pylibfdt/setup.py install [--prefix=/path/to/install_dir]

If --prefix is not provided, the default prefix is used, typically '/usr'
or '/usr/local'. See Python's distutils documentation for details. You can
also install via the Makefile if you like, but the above is more common.

To install both libfdt and pylibfdt you can use:

    make install [SETUP_PREFIX=/path/to/install_dir] \
            [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.


Tests
-----

Test files are kept in the tests/ directory. Use 'make check' to build and run
all tests.

If you want to adjust a test file, be aware that tree_tree1.dts is compiled
and checked against a binary tree from assembler macros in trees.S. So
if you change that file you must change tree.S also.


Mailing list
------------
The following list is for discussion about dtc and libfdt implementation
mailto:devicetree-compiler@vger.kernel.org

Core device tree bindings are discussed on the devicetree-spec list:
mailto:devicetree-spec@vger.kernel.org