X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=tools%2Fstm32image.c;h=18357c051822508a652ce7bb1191390f5b71f40e;hb=0411fff36f432079cacc0697d72140b8594364f1;hp=437e384d371cad58ab719824c52149498d337a58;hpb=da773532cde226b5456b89096a1be446887c7a3e;p=oweals%2Fu-boot.git diff --git a/tools/stm32image.c b/tools/stm32image.c index 437e384d37..18357c0518 100644 --- a/tools/stm32image.c +++ b/tools/stm32image.c @@ -1,7 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause /* * Copyright (C) 2018, STMicroelectronics - All Rights Reserved - * - * SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause */ #include @@ -15,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; @@ -30,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,7 +45,8 @@ 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; } static uint32_t stm32image_checksum(void *start, uint32_t len) @@ -113,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, @@ -126,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)); } /*