Boot: Mirror changes made in MCUBoot to image_header

- Apply the same changes that were made to MCUBoot by updating the
image header struct packing format to reflect the newest memory layout:
https://github.com/runtimeco/mcuboot/commit/
b5b59f16a5768c5175cf6c7ab082e84a5843f06f

Signed-off-by: Oliver Swede <oli.swede@arm.com>
Change-Id: Icac9100de7ce1553a2c4453fb3d73f942ea4174b
diff --git a/bl2/ext/mcuboot/bootutil/include/bootutil/image.h b/bl2/ext/mcuboot/bootutil/include/bootutil/image.h
index 56cd5f4..b6a472d 100644
--- a/bl2/ext/mcuboot/bootutil/include/bootutil/image.h
+++ b/bl2/ext/mcuboot/bootutil/include/bootutil/image.h
@@ -73,11 +73,11 @@
     uint32_t ih_magic;
     uint32_t ih_load_addr;
     uint16_t ih_hdr_size; /* Size of image header (bytes). */
-    uint16_t _pad2;
+    uint16_t _pad1;
     uint32_t ih_img_size; /* Does not include header. */
     uint32_t ih_flags;    /* IMAGE_F_[...]. */
     struct image_version ih_ver;
-    uint32_t _pad3;
+    uint32_t _pad2;
 };
 
 /** Image TLV header.  All fields in little endian. */
diff --git a/bl2/ext/mcuboot/scripts/imgtool/image.py b/bl2/ext/mcuboot/scripts/imgtool/image.py
index 9731844..58f7088 100644
--- a/bl2/ext/mcuboot/scripts/imgtool/image.py
+++ b/bl2/ext/mcuboot/scripts/imgtool/image.py
@@ -35,7 +35,6 @@
 
 TLV_INFO_SIZE = 4
 TLV_INFO_MAGIC = 0x6907
-TLV_HEADER_SIZE = 4
 
 # Sizes of the image trailer, depending on flash write size.
 trailer_sizes = {
@@ -133,41 +132,31 @@
         approximate the size of the signature."""
 
         flags = 0
-        tlvsz = 0
-        if key is not None:
-            tlvsz += TLV_HEADER_SIZE + key.sig_len()
-
-        tlvsz += 4 + hashlib.sha256().digest_size
-        tlvsz += 4 + hashlib.sha256().digest_size
 
         fmt = ('<' +
             # type ImageHdr struct {
             'I' +   # Magic uint32
-            'H' +   # TlvSz uint16
-            'B' +   # KeyId uint8
-            'B' +   # Pad1  uint8
+            'I' +   # LoadAddr uint32
             'H' +   # HdrSz uint16
-            'H' +   # Pad2  uint16
+            'H' +   # Pad1  uint16
             'I' +   # ImgSz uint32
             'I' +   # Flags uint32
             'BBHI' + # Vers  ImageVersion
-            'I'     # Pad3  uint32
+            'I'     # Pad2  uint32
             ) # }
         assert struct.calcsize(fmt) == IMAGE_HEADER_SIZE
         header = struct.pack(fmt,
                 IMAGE_MAGIC,
-                tlvsz, # TlvSz
-                0, # KeyId (TODO: allow other ids)
-                0,  # Pad1
+                0, # LoadAddr
                 self.header_size,
-                0, # Pad2
+                0, # Pad1
                 len(self.payload) - self.header_size, # ImageSz
                 flags, # Flags
                 self.version.major,
                 self.version.minor or 0,
                 self.version.revision or 0,
                 self.version.build or 0,
-                0) # Pad3
+                0) # Pad2
         self.payload = bytearray(self.payload)
         self.payload[:len(header)] = header