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
def _board_partition_umount(mountpoint): if syscall.call('umount "%s"' % mountpoint): raise RuntimeError("Failed to umount %s!" % mountpoint) os.rmdir(mountpoint)
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
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))
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))
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))
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))
def __prop_exists(dtb, node, prop): return syscall.call('fdtget "%s" "%s" "%s"' % (dtb, node, prop))
def remove_node(dtb, node): __files_exist(dtb) return syscall.call('fdtput -r "%s" "%s"' % (dtb, node))
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!")