Giter Club home page Giter Club logo

pyfdt's Introduction

pyfdt : Python Flattened Device Tree Manipulation


The pyfdt library is aimed to facilitate manipulation of the flattened device tree in order to parse it and generate output in various formats.

It is highly based on fdtdump for the dtc compiler package.

Support Inputs :

  • Device Tree Blob (.dtb)
  • Filesystem
  • JSON (See JSONDeviceTree.md)

Supported Outputs :

  • Device Tree Blob (DTB)
  • Device Tree Structure (text DTS)
  • JSON (See JSONDeviceTree.md)

Device Tree filesystem 'output' is available via the fusemount.py FUSE sample using fusepy library.

The object data permits :

  • add/delete/pop nodes and attributes
  • create attributes dynamically with native python types
  • walk throught the tree
  • resolve and generate "paths"
  • parse from DTB or filesystem
  • output DTB or DTS
  • output JSON
  • compare two tree
  • merge two trees

Any API, code, syntax, tests or whatever enhancement is welcomed, but consider this an alpha version project not yet used in production.

No DTS parser/compiler is event considered since "dtc" is the official compiler, but i'm open to any compiler implementation over pyfdt...

Typical usage is :

from pyfdt.pyfdt import FdtBlobParse
with open("myfdt.dtb") as infile:
    dtb = FdtBlobParse(infile)
    print dtb.to_fdt().to_dts()

Will open a binary DTB and output an human readable DTS structure.

The samples directory shows how to :

  • checkpath.py : resolve a FDT path to get a node object
  • dtbtodts.py : how to convert from DTB to DTS
  • fusemount.py : how to mount the DTB into a Device Tree filesystem you can recompile using dtc
  • python-generate.py : generate a FDT in 100% python and generate a DTS from it
  • walktree.py : List all paths of the device tree
  • fstodtb.py : Device Tree blob creation from Filesystem device tree like DTC

Device Tree Wiki Device Tree Compiler

Build Status Coverity Scan Build Status

pyfdt's People

Contributors

superna9999 avatar zaddach avatar thecodeartist avatar kapplerchris avatar rjoleary avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.