binman: Support updating section contents
PATCH 1/1 binman: Support updating section contents
Implement this feature since it is useful for updating FITs within an image.
Signed-off-by Simon Glass <[email protected]>
---
tools/binman/binman.rst | 16 ++++++++++ tools/binman/etype/section.py | 28 ++++++++++++----- tools/binman/ftest.py | 58 ++++++++++++++++++++++++++++++++--- 3 files changed, 90 insertions(+), 12 deletions(-)
tools/binman/binman.rst +16 -0
@@ -1327,6 +1327,22 @@ You can also replace just a selection of entries:: $ binman replace -i image.bin "*u-boot*" -I indir +It is possible to replace whole sections as well, but in that case any +information about entries within the section may become outdated. This is +because Binman cannot know whether things have moved around or resized within +the section, once you have updated its data. + +Technical note: With 'allow-repack', Binman writes information about the +original offset and size properties of each entry, if any were specified, in +the 'orig-offset' and 'orig-size' properties. This allows Binman to distinguish +between an entry which ended up being packed at an offset (or assigned a size) +and an entry which had a particular offset / size requested in the Binman +configuration. Where are particular offset / size was requested, this is treated +as set in stone, so Binman will ensure it doesn't change. Without this feature, +repacking an entry might cause it to disobey the original constraints provided +when it was created. + + Repacking an image involves .. _`BinmanLogging`:
tools/binman/etype/section.py +21 -7
@@ -168,6 +168,9 @@ class Entry_section(Entry): self._end_4gb = False self._ignore_missing = False self._filename = None + # Indicates that self.data should be used as is, without calling + # BuildSectionData() + self._build_done = False def IsSpecialSubnode(self, node): """Check if a node is a special one used by the section itself
@@ -397,10 +400,13 @@ class Entry_section(Entry): This excludes any padding. If the section is compressed, the compressed data is returned """ - data = self.BuildSectionData(required) - if data is None: - return None - self.SetContents(data) + if not self._build_done: + data = self.BuildSectionData(required) + if data is None: + return None + self.SetContents(data) + else: + data = self.data if self._filename: tools.write_file(tools.get_output_filename(self._filename), data) return data
@@ -427,8 +433,11 @@ class Entry_section(Entry): self._SortEntries() self._extend_entries() - data = self.BuildSectionData(True) - self.SetContents(data) + if self._build_done: + self.size = None + else: + data = self.BuildSectionData(True) + self.SetContents(data) self.CheckSize()
@@ -866,7 +875,12 @@ class Entry_section(Entry): return data def WriteData(self, data, decomp=True): - self.Raise("Replacing sections is not implemented yet") + ok = super().WriteData(data, decomp) + + # The section contents are now fixed and cannot be rebuilt from the + # containing entries. + self._build_done = True + return ok def WriteChildData(self, child): return True
tools/binman/ftest.py +53 -5
66 lines not on this page · raw message
Signature · 1 line
2.39.1.519.gcb327c4b5f-goog
Hi Simon,
Quoted 20 lines · Simon Glass
Implement this feature since it is useful for updating FITs within an image.
Signed-off-by Simon Glass <[email protected]>---
tools/binman/binman.rst | 16 ++++++++++ tools/binman/etype/section.py | 28 ++++++++++++----- tools/binman/ftest.py | 58 ++++++++++++++++++++++++++++++++--- 3 files changed, 90 insertions(+), 12 deletions(-)tools/binman/binman.rst +1
-0@@ -1327,6 +1327,22 @@ You can also replace just a selection of entries:: $ binman replace -i image.bin "*u-boot*" -I indir +It is possible to replace whole sections as well, but in that case any
tools/binman/binman.rst You can also replace just a selection of entries:: · line 1340
Quoted 10 lines
tools/binman/binman.rst +10
-0+information about entries within the section may become outdated. This is +because Binman cannot know whether things have moved around or resized within +the section, once you have updated its data. + +Technical note: With 'allow-repack', Binman writes information about the +original offset and size properties of each entry, if any were specified, in +the 'orig-offset' and 'orig-size' properties. This allows Binman to distinguish +between an entry which ended up being packed at an offset (or assigned a size) +and an entry which had a particular offset / size requested in the Binman +configuration. Where are particular offset / size was requested, this is treated
s/Where are/Where a/
Cheers,
Quentin
Hi Quentin,
Quoted 23 lines · Quentin Schulz
Hi Simon,
Quoted 19 lines · Simon Glass
Implement this feature since it is useful for updating FITs within an image.
Signed-off-by Simon Glass <[email protected]>---
tools/binman/binman.rst | 16 ++++++++++ tools/binman/etype/section.py | 28 ++++++++++++----- tools/binman/ftest.py | 58 ++++++++++++++++++++++++++++++++--- 3 files changed, 90 insertions(+), 12 deletions(-)tools/binman/binman.rst +0
-0@@ -1327,6 +1327,22 @@ You can also replace just a selection of entries:: $ binman replace -i image.bin "*u-boot*" -I indir
Quoted 13 lines
tools/binman/binman.rst You can also replace just a selection of entries:: · line 1340
Quoted 11 lines
tools/binman/binman.rst +11
-0+It is possible to replace whole sections as well, but in that case any +information about entries within the section may become outdated. This is +because Binman cannot know whether things have moved around or resized within +the section, once you have updated its data. + +Technical note: With 'allow-repack', Binman writes information about the +original offset and size properties of each entry, if any were specified, in +the 'orig-offset' and 'orig-size' properties. This allows Binman to distinguish +between an entry which ended up being packed at an offset (or assigned a size) +and an entry which had a particular offset / size requested in the Binman +configuration. Where are particular offset / size was requested, this is treateds/Where are/Where a/
Sadly I forgot about this. Will fix in the next version/
Regards,
Simon