Skip to contentSkip to conversation

tools: mkimage: fix STM32 image format for big endian hosts

PATCH New Patrick Delaunay 1 participant 2 messages Jan 28, 2020 – Feb 14, 2020 Arm STM32

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: mkimage: fix STM32 image format for big endian hosts

From: Antonio Borneo <[email protected]>

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.

---

 tools/stm32image.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/stm32image.c +3 -2
index ff3ec5f3f2..18357c0518 100644
@@ -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));
 }
 
 /*
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 tools: mkimage: fix STM32 image format for big endian hosts

Hi,

Quoted 8 lines

From: Patrick DELAUNAY <[email protected]>
Sent: mardi 28 janvier 2020 15:42

From: Antonio Borneo <[email protected]>

Two header fields are not properly converted to little endian before assignment, resulting in incorrect header while executing mkimage on big endian hosts.

Quoted 7 lines

Convert the value of the header fields image_checksum and edcsa_algorithm to little endian before the assignment.

---

Applied to u-boot-stm32/master, thanks!

Regards
Patrick