def GetProps(self, node, path): """Get all properties from a node. Args: node: Full path to node name to look in. Returns: A dictionary containing all the properties, indexed by node name. The entries are Prop objects. Raises: ValueError: if the node does not exist. """ offset = libfdt.fdt_path_offset(self._fdt, path) if offset < 0: libfdt.Raise(offset) props_dict = {} poffset = libfdt.fdt_first_property_offset(self._fdt, offset) while poffset >= 0: dprop, plen = libfdt.fdt_get_property_by_offset(self._fdt, poffset) prop = Prop(node, poffset, libfdt.String(self._fdt, dprop.nameoff), libfdt.Data(dprop)) props_dict[prop.name] = prop poffset = libfdt.fdt_next_property_offset(self._fdt, poffset) return props_dict
#!/usr/bin/python import os import sys our_path = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(our_path, '../../b/sandbox_spl/tools')) import libfdt with open('b/sandbox_spl/u-boot.dtb') as fd: fdt = fd.read() print libfdt.fdt_path_offset(fdt, "/aliases")