112468Sglenn.bergmans@arm.com## pyfdt : Python Flattened Device Tree Manipulation ## 212468Sglenn.bergmans@arm.com---------- 312468Sglenn.bergmans@arm.comThe pyfdt library is aimed to facilitate manipulation of the flattened device tree in order to parse it and generate output in various formats. 412468Sglenn.bergmans@arm.com 512468Sglenn.bergmans@arm.comIt is highly based on fdtdump for the dtc compiler package. 612468Sglenn.bergmans@arm.com 712468Sglenn.bergmans@arm.comSupport Inputs : 812468Sglenn.bergmans@arm.com - Device Tree Blob (.dtb) 912468Sglenn.bergmans@arm.com - Filesystem 1012468Sglenn.bergmans@arm.com - JSON (See JSONDeviceTree.md) 1112468Sglenn.bergmans@arm.com 1212468Sglenn.bergmans@arm.comSupported Outputs : 1312468Sglenn.bergmans@arm.com - Device Tree Blob (DTB) 1412468Sglenn.bergmans@arm.com - Device Tree Structure (text DTS) 1512468Sglenn.bergmans@arm.com - JSON (See JSONDeviceTree.md) 1612468Sglenn.bergmans@arm.com 1712468Sglenn.bergmans@arm.comDevice Tree filesystem 'output' is available via the fusemount.py FUSE sample using [fusepy](https://github.com/terencehonles/fusepy) library. 1812468Sglenn.bergmans@arm.com 1912468Sglenn.bergmans@arm.comThe object data permits : 2012468Sglenn.bergmans@arm.com - add/delete/pop nodes and attributes 2112468Sglenn.bergmans@arm.com - create attributes dynamically with native python types 2212468Sglenn.bergmans@arm.com - walk throught the tree 2312468Sglenn.bergmans@arm.com - resolve and generate "paths" 2412468Sglenn.bergmans@arm.com - parse from DTB or filesystem 2512468Sglenn.bergmans@arm.com - output DTB or DTS 2612468Sglenn.bergmans@arm.com - output JSON 2712468Sglenn.bergmans@arm.com - compare two tree 2812468Sglenn.bergmans@arm.com - merge two trees 2912468Sglenn.bergmans@arm.com 3012468Sglenn.bergmans@arm.comAny API, code, syntax, tests or whatever enhancement is welcomed, but consider this an alpha version project not yet used in production. 3112468Sglenn.bergmans@arm.com 3212468Sglenn.bergmans@arm.comNo DTS parser/compiler is event considered since "dtc" is the official compiler, but i'm open to any compiler implementation over pyfdt... 3312468Sglenn.bergmans@arm.com 3412468Sglenn.bergmans@arm.comTypical usage is : 3512468Sglenn.bergmans@arm.com``` 3612468Sglenn.bergmans@arm.comfrom pyfdt import FdtBlobParse 3712468Sglenn.bergmans@arm.comwith open("myfdt.dtb") as infile: 3812468Sglenn.bergmans@arm.com dtb = FdtBlobParse(infile) 3912468Sglenn.bergmans@arm.com print dtb.to_fdt().to_dts() 4012468Sglenn.bergmans@arm.com``` 4112468Sglenn.bergmans@arm.com 4212468Sglenn.bergmans@arm.comWill open a binary DTB and output an human readable DTS structure. 4312468Sglenn.bergmans@arm.com 4412468Sglenn.bergmans@arm.comThe samples directory shows how to : 4512468Sglenn.bergmans@arm.com - checkpath.py : resolve a FDT path to get a node object 4612468Sglenn.bergmans@arm.com - dtbtodts.py : how to convert from DTB to DTS 4712468Sglenn.bergmans@arm.com - fusemount.py : how to mount the DTB into a Device Tree filesystem you can recompile using dtc 4812468Sglenn.bergmans@arm.com - python-generate.py : generate a FDT in 100% python and generate a DTS from it 4912468Sglenn.bergmans@arm.com - walktree.py : List all paths of the device tree 5012468Sglenn.bergmans@arm.com - fstodtb.py : Device Tree blob creation from Filesystem device tree like DTC 5112468Sglenn.bergmans@arm.com 5212468Sglenn.bergmans@arm.com[Device Tree Wiki](http://www.devicetree.org) 5312468Sglenn.bergmans@arm.com[Device Tree Compiler](http://www.devicetree.org/Device_Tree_Compiler) 5412468Sglenn.bergmans@arm.com 5512468Sglenn.bergmans@arm.com[![Build Status](https://travis-ci.org/superna9999/pyfdt.svg?branch=master)](https://travis-ci.org/superna9999/pyfdt) 56