summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAntonio Borneo <antonio.borneo@st.com>2020-01-28 15:42:13 +0100
committerPatrick Delaunay <patrick.delaunay@st.com>2020-02-13 17:32:09 +0100
commit441749d9d14d3484da1f19a0e6d4118d9fde9175 (patch)
tree77f8f7fb38b665dfd230d253a3e815764f79493a /tools
parentcf0818b4772b02e63fb980d8c146ef5d780b7940 (diff)
tools: mkimage: fix STM32 image format for big endian hosts
Two header fields are not properly converted to little endian before assignment, resulting in incorrect header while executing mkimage on big endian hosts. Convert the value of the header fields image_checksum and edcsa_algorithm to little endian before the assignment. Signed-off-by: Antonio Borneo <antonio.borneo@st.com> Reviewed-by: Patrick DELAUNAY <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/stm32image.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/stm32image.c b/tools/stm32image.c
index ff3ec5f3f2..18357c0518 100644
--- a/tools/stm32image.c
+++ b/tools/stm32image.c
@@ -45,7 +45,7 @@ static void stm32image_default_header(struct stm32_header *ptr)
ptr->magic_number = HEADER_MAGIC;
ptr->header_version[VER_MAJOR_IDX] = HEADER_VERSION_V1;
ptr->option_flags = HEADER_DEFAULT_OPTION;
- ptr->ecdsa_algorithm = 1;
+ ptr->ecdsa_algorithm = cpu_to_le32(1);
ptr->binary_type = HEADER_TYPE_UBOOT;
}
@@ -131,7 +131,8 @@ static void stm32image_set_header(void *ptr, struct stat *sbuf, int ifd,
stm32hdr->image_entry_point = cpu_to_le32(params->ep);
stm32hdr->image_length = cpu_to_le32((uint32_t)sbuf->st_size -
sizeof(struct stm32_header));
- stm32hdr->image_checksum = stm32image_checksum(ptr, sbuf->st_size);
+ stm32hdr->image_checksum =
+ cpu_to_le32(stm32image_checksum(ptr, sbuf->st_size));
}
/*