summaryrefslogtreecommitdiff
path: root/tools/binman/state.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-07-20 12:23:58 -0600
committerSimon Glass <sjg@chromium.org>2019-07-29 09:38:06 -0600
commit61ec04f9eda413664e5c11a6099c89a44b73b5b9 (patch)
tree5234f74a0da4d87cd229b08ce61dd12d2c18822a /tools/binman/state.py
parent79d3c58d1268786ce40c6c0920ed2a447247fdc4 (diff)
downloadu-boot-61ec04f9eda413664e5c11a6099c89a44b73b5b9.tar.gz
binman: Support shrinking a entry after packing
Sometimes an entry may shrink after it has already been packed. In that case we must repack the items. Of course it is always possible to just leave the entry at its original size and waste space at the end. This is what binman does by default, since there is the possibility of the entry changing size every time binman calculates its contents, thus causing a loop. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/state.py')
-rw-r--r--tools/binman/state.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/binman/state.py b/tools/binman/state.py
index 65536151b4..f22cc82d87 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -42,6 +42,14 @@ main_dtb = None
# Entry.ProcessContentsUpdate()
allow_entry_expansion = True
+# Don't allow entries to contract after they have been packed. Instead just
+# leave some wasted space. If allowed, this is detected and forces a re-pack,
+# but may result in entries that oscillate in size, thus causing a pack error.
+# An example is a compressed device tree where the original offset values
+# result in a larger compressed size than the new ones, but then after updating
+# to the new ones, the compressed size increases, etc.
+allow_entry_contraction = False
+
def GetFdtForEtype(etype):
"""Get the Fdt object for a particular device-tree entry
@@ -346,3 +354,22 @@ def AllowEntryExpansion():
raised
"""
return allow_entry_expansion
+
+def SetAllowEntryContraction(allow):
+ """Set whether post-pack contraction of entries is allowed
+
+ Args:
+ allow: True to allow contraction, False to raise an exception
+ """
+ global allow_entry_contraction
+
+ allow_entry_contraction = allow
+
+def AllowEntryContraction():
+ """Check whether post-pack contraction of entries is allowed
+
+ Returns:
+ True if contraction should be allowed, False if an exception should be
+ raised
+ """
+ return allow_entry_contraction