summaryrefslogtreecommitdiff
path: root/tools/binman/entry.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-07-20 21:23:50 +0300
committerSimon Glass <sjg@chromium.org>2019-07-29 18:38:06 +0300
commit10f9d0066b9e9e14327922fa62c2a1b6bea50785 (patch)
treee8f2edff2c01e0a90f203db9fc3a5d336d15fd0c /tools/binman/entry.py
parenta004f29464d14f3535ed8db22e5dfed02c8fc9d8 (diff)
downloadu-boot-10f9d0066b9e9e14327922fa62c2a1b6bea50785.tar.xz
binman: Support updating entries in an existing image
While it is useful and efficient to build images in a single pass from a unified description, it is sometimes desirable to update the image later. Add support for replace an existing file with one of the same size. This avoids needing to repack the file. Support for more advanced updates will come in future patches. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/entry.py')
-rw-r--r--tools/binman/entry.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index ddf52d8e10..07d5838c1a 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -698,6 +698,7 @@ features to produce new behaviours.
def LoadData(self, decomp=True):
data = self.ReadData(decomp)
+ self.contents_size = len(data)
self.ProcessContentsUpdate(data)
self.Detail('Loaded data size %x' % len(data))
@@ -708,3 +709,25 @@ features to produce new behaviours.
Image object containing this entry
"""
return self.section.GetImage()
+
+ def WriteData(self, data, decomp=True):
+ """Write the data to an entry in the image
+
+ This is used when the image has been read in and we want to replace the
+ data for a particular entry in that image.
+
+ The image must be re-packed and written out afterwards.
+
+ Args:
+ data: Data to replace it with
+ decomp: True to compress the data if needed, False if data is
+ already compressed so should be used as is
+
+ Returns:
+ True if the data did not result in a resize of this entry, False if
+ the entry must be resized
+ """
+ self.contents_size = self.size
+ ok = self.ProcessContentsUpdate(data)
+ self.Detail('WriteData: size=%x, ok=%s' % (len(data), ok))
+ return ok