imgtool: Add complete trailer to HEX images
When generating HEX output, instead of just adding the `magic`, also add the whole trailer (with erased value). This allows for HEX writing tools to erase the trailer region, avoiding possible issues when garbage exists there. Signed-off-by: Fabio Utzig <utzig@apache.org>
This commit is contained in:
parent
9117fded47
commit
2269f47eb4
|
@ -179,9 +179,13 @@ class Image():
|
||||||
self.base_addr = hex_addr
|
self.base_addr = hex_addr
|
||||||
h.frombytes(bytes=self.payload, offset=self.base_addr)
|
h.frombytes(bytes=self.payload, offset=self.base_addr)
|
||||||
if self.pad:
|
if self.pad:
|
||||||
magic_addr = (self.base_addr + self.slot_size) - \
|
trailer_size = self._trailer_size(self.align, self.max_sectors,
|
||||||
len(boot_magic)
|
self.overwrite_only,
|
||||||
h.puts(magic_addr, boot_magic)
|
self.enckey)
|
||||||
|
trailer_addr = (self.base_addr + self.slot_size) - trailer_size
|
||||||
|
padding = bytes([self.erased_val] *
|
||||||
|
(trailer_size - len(boot_magic))) + boot_magic
|
||||||
|
h.puts(trailer_addr, padding)
|
||||||
h.tofile(path, 'hex')
|
h.tofile(path, 'hex')
|
||||||
else:
|
else:
|
||||||
if self.pad:
|
if self.pad:
|
||||||
|
|
Loading…
Reference in New Issue