Blame README

Packit 2ad57b
The source tree contains the Device Tree Compiler (dtc) toolchain for
Packit 2ad57b
working with device tree source and binary files and also libfdt, a
Packit 2ad57b
utility library for reading and manipulating the binary format.
Packit 2ad57b
Packit 2ad57b
DTC and LIBFDT are maintained by:
Packit 2ad57b
Packit 2ad57b
David Gibson <david@gibson.dropbear.id.au>
Packit 2ad57b
Jon Loeliger <jdl@jdl.com>
Packit 2ad57b
Packit 2ad57b
Packit 2ad57b
Python library
Packit 2ad57b
--------------
Packit 2ad57b
Packit 2ad57b
A Python library is also available. To build this you will need to install
Packit 2ad57b
swig and Python development files. On Debian distributions:
Packit 2ad57b
Packit Service 0ee8e1
   sudo apt-get install swig python3-dev
Packit 2ad57b
Packit 2ad57b
The library provides an Fdt class which you can use like this:
Packit 2ad57b
Packit Service 0ee8e1
$ PYTHONPATH=../pylibfdt python3
Packit 2ad57b
>>> import libfdt
Packit Service 0ee8e1
>>> fdt = libfdt.Fdt(open('test_tree1.dtb', mode='rb').read())
Packit 2ad57b
>>> node = fdt.path_offset('/subnode@1')
Packit Service 0ee8e1
>>> print(node)
Packit 2ad57b
124
Packit 2ad57b
>>> prop_offset = fdt.first_property_offset(node)
Packit 2ad57b
>>> prop = fdt.get_property_by_offset(prop_offset)
Packit Service 0ee8e1
>>> print('%s=%s' % (prop.name, prop.as_str()))
Packit 2ad57b
compatible=subnode1
Packit 2ad57b
>>> node2 = fdt.path_offset('/')
Packit Service 0ee8e1
>>> print(fdt.getprop(node2, 'compatible').as_str())
Packit 2ad57b
test_tree1
Packit 2ad57b
Packit 2ad57b
You will find tests in tests/pylibfdt_tests.py showing how to use each
Packit 2ad57b
method. Help is available using the Python help command, e.g.:
Packit 2ad57b
Packit 2ad57b
    $ cd pylibfdt
Packit Service 0ee8e1
    $ python3 -c "import libfdt; help(libfdt)"
Packit 2ad57b
Packit 2ad57b
If you add new features, please check code coverage:
Packit 2ad57b
Packit Service 0ee8e1
    $ sudo apt-get install python3-coverage
Packit 2ad57b
    $ cd tests
Packit Service 0ee8e1
    # It's just 'coverage' on most other distributions
Packit Service 0ee8e1
    $ python3-coverage run pylibfdt_tests.py
Packit Service 0ee8e1
    $ python3-coverage html
Packit 2ad57b
    # Open 'htmlcov/index.html' in your browser
Packit 2ad57b
Packit 2ad57b
Packit 2ad57b
To install the library via the normal setup.py method, use:
Packit 2ad57b
Packit Service 0ee8e1
    ./pylibfdt/setup.py install [--prefix=/path/to/install_dir]
Packit 2ad57b
Packit 2ad57b
If --prefix is not provided, the default prefix is used, typically '/usr'
Packit 2ad57b
or '/usr/local'. See Python's distutils documentation for details. You can
Packit 2ad57b
also install via the Makefile if you like, but the above is more common.
Packit 2ad57b
Packit 2ad57b
To install both libfdt and pylibfdt you can use:
Packit 2ad57b
Packit 2ad57b
    make install [SETUP_PREFIX=/path/to/install_dir] \
Packit 2ad57b
            [PREFIX=/path/to/install_dir]
Packit 2ad57b
Packit 2ad57b
To disable building the python library, even if swig and Python are available,
Packit 2ad57b
use:
Packit 2ad57b
Packit 2ad57b
    make NO_PYTHON=1
Packit 2ad57b
Packit 2ad57b
Packit 2ad57b
More work remains to support all of libfdt, including access to numeric
Packit 2ad57b
values.
Packit 2ad57b
Packit 2ad57b
Packit 2ad57b
Tests
Packit 2ad57b
-----
Packit 2ad57b
Packit 2ad57b
Test files are kept in the tests/ directory. Use 'make check' to build and run
Packit 2ad57b
all tests.
Packit 2ad57b
Packit 2ad57b
If you want to adjust a test file, be aware that tree_tree1.dts is compiled
Packit 2ad57b
and checked against a binary tree from assembler macros in trees.S. So
Packit 2ad57b
if you change that file you must change tree.S also.
Packit 2ad57b
Packit 2ad57b
Packit 2ad57b
Mailing list
Packit 2ad57b
------------
Packit 2ad57b
The following list is for discussion about dtc and libfdt implementation
Packit 2ad57b
mailto:devicetree-compiler@vger.kernel.org
Packit 2ad57b
Packit 2ad57b
Core device tree bindings are discussed on the devicetree-spec list:
Packit 2ad57b
mailto:devicetree-spec@vger.kernel.org