Example #1
0
def _board_partition_mount(partlabel):
    path = os.path.join('/mnt', partlabel)
    if os.path.exists(path):
        raise RuntimeError("Mountpoint %s already exists!" % path)
    os.makedirs(path)
    syscall.call('mount PARTLABEL="%s" "%s"' % (partlabel, path))
    return path
Example #2
0
def _board_partition_umount(mountpoint):
    if syscall.call('umount "%s"' % mountpoint):
        raise RuntimeError("Failed to umount %s!" % mountpoint)
    os.rmdir(mountpoint)
Example #3
0
def _board_partition_is_mounted(partlabel):
    if not syscall.call_out('findfs PARTLABEL="%s"' % partlabel):
        raise RuntimeError("No %s partition found!" % partlabel)
    return syscall.call('findmnt -n -S PARTLABEL="%s"' % partlabel) == 0
Example #4
0
def overlay(dtb, out, *overlays):
    for overlay in overlays:
        __files_exist(dtb, overlay)
    files = ' '.join(overlays)
    if syscall.call('fdtoverlay -i "%s" -o "%s" "%s"' % (dtb, out, files)):
        raise RuntimeError("Failed to overlay %s with %s!" % (dtb, files))
Example #5
0
def set_prop_value(dtb, node, dtype, prop, value):
    __files_exist(dtb)
    if syscall.call('fdtput -t "%s" "%s" "%s" "%s" "%s"' %
                    (dtype, dtb, node, prop, value)):
        raise RuntimeError("Failed to get property value for %s%s!" %
                           (node, prop))
Example #6
0
def compile(dts, dtb):
    __files_exist(dts)
    if syscall.call('dtc -I dts -O dtb "%s" -o "%s"' % (dts, dtb)):
        raise RuntimeError("Failed to compile %s to %s!" % (dts, dtb))
Example #7
0
def extract(dtb, dts):
    __files_exist(dtb)
    if syscall.call('dtc -I dtb -O dts "%s" -o "%s"' % (dtb, dts)):
        raise RuntimeError("Failed to extract %s to %s!" % (dtb, dts))
Example #8
0
def __prop_exists(dtb, node, prop):
    return syscall.call('fdtget "%s" "%s" "%s"' % (dtb, node, prop))
Example #9
0
def remove_node(dtb, node):
    __files_exist(dtb)
    return syscall.call('fdtput -r "%s" "%s"' % (dtb, node))
Example #10
0
            continue
        if model != get_model(dtb):
            continue
        dtbs.append(dtb)
    if not dtbs:
        return None
    return dtbs


def find_compatible_dtbo_files(compat, path):
    dtbos = []
    for dtbo in glob.glob(os.path.join(path, '*.dtbo')):
        c = get_compatible(dtbo)
        if c is None:
            continue
        if compat in c:
            dtbos.append(dtbo)
    if not dtbos:
        return None
    return dtbos


def remove_node(dtb, node):
    __files_exist(dtb)
    return syscall.call('fdtput -r "%s" "%s"' % (dtb, node))


if syscall.call('which dtc') or syscall.call('which fdtoverlay') or \
   syscall.call('which fdtget') or syscall.call('which fdtput'):
    raise RuntimeError("Device-tree compiler not found!")