mkimage: change stm32image header to manage binary information
authorPatrick Delaunay <patrick.delaunay@st.com>
Thu, 18 Apr 2019 15:32:44 +0000 (17:32 +0200)
committerPatrice Chotard <patrice.chotard@st.com>
Thu, 23 May 2019 09:36:47 +0000 (11:36 +0200)
To get more information from STM32 Header about the generated binary,
we will add a new byte with the following field:
replace padding byte 255 with 0x00 for "U-Boot"

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
tools/stm32image.c

index 08b32ba87dd512a1f5377d24d679dd97731427cd..ff3ec5f3f2b914752114f91c7518db0865c1973c 100644 (file)
@@ -14,6 +14,8 @@
 #define HEADER_VERSION_V1      0x1
 /* default option : bit0 => no signature */
 #define HEADER_DEFAULT_OPTION  (cpu_to_le32(0x00000001))
+/* default binary type for U-Boot */
+#define HEADER_TYPE_UBOOT      (cpu_to_le32(0x00000000))
 
 struct stm32_header {
        uint32_t magic_number;
@@ -29,7 +31,8 @@ struct stm32_header {
        uint32_t option_flags;
        uint32_t ecdsa_algorithm;
        uint32_t ecdsa_public_key[64 / 4];
-       uint32_t padding[84 / 4];
+       uint32_t padding[83 / 4];
+       uint32_t binary_type;
 };
 
 static struct stm32_header stm32image_header;
@@ -43,6 +46,7 @@ static void stm32image_default_header(struct stm32_header *ptr)
        ptr->header_version[VER_MAJOR_IDX] = HEADER_VERSION_V1;
        ptr->option_flags = HEADER_DEFAULT_OPTION;
        ptr->ecdsa_algorithm = 1;
+       ptr->binary_type = HEADER_TYPE_UBOOT;
 }
 
 static uint32_t stm32image_checksum(void *start, uint32_t len)
@@ -112,6 +116,8 @@ static void stm32image_print_header(const void *ptr)
               le32_to_cpu(stm32hdr->image_checksum));
        printf("Option     : 0x%08x\n",
               le32_to_cpu(stm32hdr->option_flags));
+       printf("BinaryType : 0x%08x\n",
+              le32_to_cpu(stm32hdr->binary_type));
 }
 
 static void stm32image_set_header(void *ptr, struct stat *sbuf, int ifd,