Beispiel #1
0
@author: Neil 'superna' Armstrong <*****@*****.**>
"""

import argparse
from pyfdt.pyfdt import FdtBlobParse

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Device Tree Blob dump')
    parser.add_argument('--format', dest = 'format' ,help="output format (dts, json or dtb), default to dts", default = "dts")
    parser.add_argument('in_filename', help="input filename")
    parser.add_argument('out_filename', help="output filename")
    args = parser.parse_args()

    if args.format not in ('dts', 'json', 'dtb'):
        raise Exception('Invalid Output Format')
    
    with open(args.in_filename, 'rb') as infile:
        dtb = FdtBlobParse(infile)
    
    fdt = dtb.to_fdt()
    
    if args.format == "dts":
        with open(args.out_filename, 'wb') as outfile:
            outfile.write(fdt.to_dts().encode('ascii'))
    elif args.format == "dtb":
        with open(args.out_filename, 'wb') as outfile:
            outfile.write(fdt.to_dtb())
    elif args.format == "json":
        with open(args.out_filename, 'wb') as outfile:
            outfile.write(fdt.to_json().encode('ascii'))
Beispiel #2
0
def read_binary_file(fname):
    with open(fname, "rb") as f:
        dtb = FdtBlobParse(f)
        ftd = dtb.to_fdt()
    return ftd
Beispiel #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
DTB to DTS

@author: Neil 'superna' Armstrong <*****@*****.**>
"""

import argparse
from pyfdt.pyfdt import FdtBlobParse

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Device Tree Blob dump')
    parser.add_argument('in_filename', help="input filename")
    args = parser.parse_args()

    with open(args.in_filename) as infile:
        dtb = FdtBlobParse(infile)

    fdt = dtb.to_fdt()

    print fdt.to_json()
Beispiel #4
0
    parser.add_argument(
        "--format2", dest="format2", help="input format (dtb, fs or json), default to dtb", default="dtb"
    )
    parser.add_argument("in_dtb1", help="input filename 1")
    parser.add_argument("in_dtb2", help="input filename 2")
    args = parser.parse_args()

    if args.format1 not in ("fs", "dtb", "json"):
        raise Exception("Invalid Format1")
    if args.format2 not in ("fs", "dtb", "json"):
        raise Exception("Invalid Format2")

    if args.format1 == "dtb":
        with open(args.in_dtb1, "rb") as infile:
            dtb1 = FdtBlobParse(infile)
        fdt1 = dtb1.to_fdt()
    elif args.format1 == "json":
        with open(args.in_dtb1) as infile:
            fdt1 = FdtJsonParse(infile.read())
    else:
        fdt1 = FdtFsParse(args.in_dtb1)

    if args.format2 == "dtb":
        with open(args.in_dtb2, "rb") as infile:
            dtb2 = FdtBlobParse(infile)
        fdt2 = dtb2.to_fdt()
    elif args.format2 == "json":
        with open(args.in_dtb2, "r") as infile:
            fdt2 = FdtJsonParse(infile.read())
    else:
        fdt2 = FdtFsParse(args.in_dtb2)
Beispiel #5
0
    parser.add_argument('--format2', dest = 'format2' ,help="input format2 (dtb, fs or json), default to dtb", default = "dtb")
    parser.add_argument('--outformat', dest = 'outformat' ,help="output format (dtb, dts or json), default to dtb", default = "dtb")
    parser.add_argument('in_dtb1', help="input filename 1")
    parser.add_argument('in_dtb2', help="input filename 2")
    parser.add_argument('out_filename', help="output filename")
    args = parser.parse_args()

    if args.format1 not in ('fs', 'dtb', 'json'):
        raise Exception('Invalid Format1')
    if args.format2 not in ('fs', 'dtb', 'json'):
        raise Exception('Invalid Format2')

    if args.format1 == 'dtb':
        with open(args.in_dtb1) as infile:
            dtb1 = FdtBlobParse(infile)
        fdt1 = dtb1.to_fdt()
    elif args.format1 == 'json':
        with open(args.in_dtb1) as infile:
            fdt1 = FdtJsonParse(infile.read())
    else:
        fdt1 = FdtFsParse(args.in_dtb1)

    if args.format2 == 'dtb':
        with open(args.in_dtb2) as infile:
            dtb2 = FdtBlobParse(infile)
        fdt2 = dtb2.to_fdt()
    elif args.format2 == 'json':
        with open(args.in_dtb2) as infile:
            fdt2 = FdtJsonParse(infile.read())
    else:
        fdt2 = FdtFsParse(args.in_dtb2)