def _GetFdtmap(self): """Build an FDT map from the entries in the current image Returns: FDT map binary data """ def _AddNode(node): """Add a node to the FDT map""" for pname, prop in node.props.items(): fsw.property(pname, prop.bytes) for subnode in node.subnodes: with fsw.add_node(subnode.name): _AddNode(subnode) data = state.GetFdtContents('fdtmap')[1] # If we have an fdtmap it means that we are using this as the # fdtmap for this image. if data is None: # Get the FDT data into an Fdt object data = state.GetFdtContents()[1] infdt = Fdt.FromData(data) infdt.Scan() # Find the node for the image containing the Fdt-map entry path = self.section.GetPath() self.Detail("Fdtmap: Using section '%s' (path '%s')" % (self.section.name, path)) node = infdt.GetNode(path) if not node: self.Raise("Internal error: Cannot locate node for path '%s'" % path) # Build a new tree with all nodes and properties starting from that # node fsw = libfdt.FdtSw() fsw.finish_reservemap() with fsw.add_node(''): fsw.property_string('image-node', node.name) _AddNode(node) fdt = fsw.as_fdt() # Pack this new FDT and return its contents fdt.pack() outfdt = Fdt.FromData(fdt.as_bytearray()) data = outfdt.GetContents() data = FDTMAP_MAGIC + tools.GetBytes(0, 8) + data return data
def ProcessContents(self): """Re-read the DTB contents so that we get any calculated properties""" _, indata = state.GetFdtContents(self.GetFdtEtype()) data = self.CompressData(indata) return self.ProcessContentsUpdate(data)
def ObtainContents(self): """Get the device-tree from the list held by the 'state' module""" self._filename = self.GetDefaultFilename() self._pathname, _ = state.GetFdtContents(self.GetFdtEtype()) return super().ReadBlobContents()