aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/entry.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-07-08 14:25:50 -0600
committerSimon Glass <sjg@chromium.org>2019-07-24 12:54:08 -0700
commitf667e45b1c0a7f21d433ee8f3ec18858d87dd2e5 (patch)
treeae849665f80553e7689976d578e90250545f5423 /tools/binman/entry.py
parenteea264ead3ca198ed66f62a78dc4940075621ae7 (diff)
downloadu-boot-f667e45b1c0a7f21d433ee8f3ec18858d87dd2e5.zip
u-boot-f667e45b1c0a7f21d433ee8f3ec18858d87dd2e5.tar.gz
u-boot-f667e45b1c0a7f21d433ee8f3ec18858d87dd2e5.tar.bz2
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>
Diffstat (limited to 'tools/binman/entry.py')
-rw-r--r--tools/binman/entry.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 33d3f1e..1c382f3 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -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]