def ExpandEntries(self):
pass
- def AddMissingProperties(self):
- """Add new properties to the device tree as needed for this entry"""
- for prop in ['offset', 'size', 'image-pos']:
+ def AddMissingProperties(self, have_image_pos):
+ """Add new properties to the device tree as needed for this entry
+
+ Args:
+ have_image_pos: True if this entry has an image position. This can
+ be False if its parent section is compressed, since compression
+ groups all entries together into a compressed block of data,
+ obscuring the start of each individual child entry
+ """
+ for prop in ['offset', 'size']:
if not prop in self._node.props:
state.AddZeroProp(self._node, prop)
+ if have_image_pos and 'image-pos' not in self._node.props:
+ state.AddZeroProp(self._node, 'image-pos')
if self.GetImage().allow_repack:
if self.orig_offset is not None:
state.AddZeroProp(self._node, 'orig-offset', True)
state.SetInt(self._node, 'offset', self.offset)
state.SetInt(self._node, 'size', self.size)
base = self.section.GetRootSkipAtStart() if self.section else 0
- state.SetInt(self._node, 'image-pos', self.image_pos - base)
+ if self.image_pos is not None:
+ state.SetInt(self._node, 'image-pos', self.image_pos)
if self.GetImage().allow_repack:
if self.orig_offset is not None:
state.SetInt(self._node, 'orig-offset', self.orig_offset, True)
if entry._cbfs_compress:
entry.uncomp_size = cfile.memlen
- def AddMissingProperties(self):
- super().AddMissingProperties()
+ def AddMissingProperties(self, have_image_pos):
+ super().AddMissingProperties(have_image_pos)
for entry in self._cbfs_entries.values():
- entry.AddMissingProperties()
+ entry.AddMissingProperties(have_image_pos)
if entry._cbfs_compress:
state.AddZeroProp(entry._node, 'uncomp-size')
# Store the 'compress' property, since we don't look at
for entry in self._entries.values():
entry.ExpandEntries()
- def AddMissingProperties(self):
+ def AddMissingProperties(self, have_image_pos):
"""Add new properties to the device tree as needed for this entry"""
- super().AddMissingProperties()
+ super().AddMissingProperties(have_image_pos)
+ if self.compress != 'none':
+ have_image_pos = False
for entry in self._entries.values():
- entry.AddMissingProperties()
+ entry.AddMissingProperties(have_image_pos)
def ObtainContents(self):
return self.GetEntryContents()
def SetImagePos(self, image_pos):
super().SetImagePos(image_pos)
- for entry in self._entries.values():
- entry.SetImagePos(image_pos + self.offset)
+ if self.compress == 'none':
+ for entry in self._entries.values():
+ entry.SetImagePos(image_pos + self.offset)
def ProcessContents(self):
sizes_ok_base = super(Entry_section, self).ProcessContents()