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:
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.
夏末是什么时候 | 为什么会发烧 | 怀孕后吃避孕药有什么后果 | 物上代位性是什么意思 | 食物中毒吃什么药解毒 |
大理有什么好玩的 | 五月十七号是什么星座 | 8月27号是什么星座 | 消化不好吃什么药 | 胆囊结石挂什么科 |
微笑是什么 | 生小孩有什么补贴政策 | 乾隆为什么不喜欢雍正 | 手足口病吃什么药好得快 | 到此为止是什么意思 |
几天不大便是什么原因 | 传染病八项挂什么科 | ige是什么意思 | 怀孕都有什么症状 | 天麻泡水喝有什么功效 |
装腔作势是什么意思youbangsi.com | elite是什么意思hcv8jop1ns9r.cn | 肚子长痘痘是什么原因hcv7jop6ns3r.cn | 血红蛋白偏高说明了什么hcv9jop0ns1r.cn | 彩泥可以做什么adwl56.com |
怜惜是什么意思helloaicloud.com | 控评是什么意思hcv8jop8ns7r.cn | 吃什么水果可以护肝hcv9jop2ns8r.cn | 什么的绿叶hcv7jop6ns9r.cn | 葡萄糖高是什么意思hcv8jop6ns3r.cn |
曾舜晞是什么星座hcv8jop4ns9r.cn | 莫字五行属什么dayuxmw.com | 姓叶的男孩取什么名字好hcv9jop4ns1r.cn | 脱发缺什么维生素hcv7jop6ns0r.cn | 8月27是什么星座hcv8jop0ns1r.cn |
梦见老公出轨了是什么征兆hcv8jop9ns4r.cn | 月经来了同房会导致什么后果hcv9jop4ns4r.cn | 心电轴重度左偏是什么意思hcv8jop1ns1r.cn | 淀粉酶测定是查什么sscsqa.com | 水样分泌物是什么炎症hcv8jop3ns4r.cn |