mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 10:39:08 +00:00
binman: Allow reading an entry from an image
It is useful to be able to extract entry contents from an image to see what is inside. Add a simple function to read the contents of an entry, decompressing it by default. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
eea264ead3
commit
f667e45b1c
5 changed files with 99 additions and 1 deletions
|
@ -659,3 +659,24 @@ features to produce new behaviours.
|
|||
"""
|
||||
self.AddEntryInfo(entries, indent, self.name, self.etype, self.size,
|
||||
self.image_pos, self.uncomp_size, self.offset, self)
|
||||
|
||||
def ReadData(self, decomp=True):
|
||||
"""Read the data for an entry from the image
|
||||
|
||||
This is used when the image has been read in and we want to extract the
|
||||
data for a particular entry from that image.
|
||||
|
||||
Args:
|
||||
decomp: True to decompress any compressed data before returning it;
|
||||
False to return the raw, uncompressed data
|
||||
|
||||
Returns:
|
||||
Entry data (bytes)
|
||||
"""
|
||||
# Use True here so that we get an uncompressed section to work from,
|
||||
# although compressed sections are currently not supported
|
||||
data = self.section.ReadData(True)
|
||||
tout.Info('%s: Reading data from offset %#x-%#x, size %#x (avail %#x)' %
|
||||
(self.GetPath(), self.offset, self.offset + self.size,
|
||||
self.size, len(data)))
|
||||
return data[self.offset:self.offset + self.size]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue