Commit c028d450 authored by Wouter Cappelle's avatar Wouter Cappelle Committed by David Brown
Browse files

imgtool: skip erased values in trailer generation



When generating an image with trailer (--pad or --confirm), the
imgtool also adds the erased values into that area. This is not
wanted for flash drivers which use ECC and treat writing erased
values as a real write action, which cannot be overwritten anymore.
See issue #1288
Signed-off-by: default avatarWouter Cappelle <wouter.cappelle@crodeon.com>
parent bb7a39d1
......@@ -242,15 +242,15 @@ class Image():
self.save_enctlv,
self.enctlv_len)
trailer_addr = (self.base_addr + self.slot_size) - trailer_size
padding = bytearray([self.erased_val] *
(trailer_size - len(self.boot_magic)))
padding += self.boot_magic
if self.confirm and not self.overwrite_only:
magic_size = 16
magic_align_size = align_up(magic_size, self.max_align)
image_ok_idx = -(magic_align_size + self.max_align)
padding[image_ok_idx] = 0x01 # image_ok = 0x01
h.puts(trailer_addr, bytes(padding))
flag = bytearray([self.erased_val] * magic_align_size)
flag[0] = 0x01 # image_ok = 0x01
h.puts(trailer_addr + image_ok_idx, bytes(flag))
h.puts(trailer_addr + (trailer_size - len(self.boot_magic)),
bytes(self.boot_magic))
h.tofile(path, 'hex')
else:
if self.pad:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment