diff --git a/include/elf.h b/include/elf.h index 4c330dc0..ca1f2bdf 100644 --- a/include/elf.h +++ b/include/elf.h @@ -168,7 +168,7 @@ typedef struct elf64_program_header { typedef int (*elf_mmu_map_cb)(uint64_t, uint64_t, uint32_t); int elf_load_image_mmu(uint8_t *image, uintptr_t *entry, elf_mmu_map_cb mmu_cb); int elf_load_image(uint8_t *image, uintptr_t *entry, int is_ext); -int elf_hdr_pht_combined_size(const unsigned char *ehdr); +int64_t elf_hdr_pht_combined_size(const unsigned char* ehdr); int elf_open(const unsigned char *ehdr, int *is_elf32); diff --git a/src/elf.c b/src/elf.c index 8e4f2ee7..b3ff6bb9 100644 --- a/src/elf.c +++ b/src/elf.c @@ -203,7 +203,7 @@ static int check_scatter_format(const unsigned char* ehdr, int is_elf32) /* Returns the combined size of the elf header and program header table. This * assumes the program header table immediately follows the elf header. */ -int elf_hdr_pht_combined_size(const unsigned char* ehdr) +int64_t elf_hdr_pht_combined_size(const unsigned char* ehdr) { int sz = 0; int is_elf32; diff --git a/src/image.c b/src/image.c index bda01f89..e850a859 100644 --- a/src/image.c +++ b/src/image.c @@ -1631,7 +1631,7 @@ int wolfBoot_check_flash_image_elf(uint8_t part, unsigned long* entry_out) eh->entry, (unsigned long)entry_off, entry_count); } - elf_hdr_sz = elf_hdr_pht_combined_size(elf_h); + elf_hdr_sz = (size_t)elf_hdr_pht_combined_size(elf_h); wolfBoot_printf("ELF: [CHECK] Header size: %zu bytes\n", elf_hdr_sz); /* Hash the elf header and program header in the image, assuming the PHT diff --git a/tools/scripts/tc3xx/wbaurixtool.sh b/tools/scripts/tc3xx/wbaurixtool.sh index 6821d815..32067dbc 100644 --- a/tools/scripts/tc3xx/wbaurixtool.sh +++ b/tools/scripts/tc3xx/wbaurixtool.sh @@ -43,6 +43,9 @@ HSM="" ELF="" OPERATIONS=() +# Important Constants +PFLASH1_RANGE="0xA0300000-0xA0500000" + # Structure to hold command options declare -A KEYGEN_OPTS=( [sign_algo]="$DEFAULT_SIGN_ALGO" @@ -208,7 +211,7 @@ do_sign() { if [[ "${SIGN_OPTS[file_ext]}" == ".elf" ]]; then local temp_file="${bin_path}.squashed" echo "Preprocessing ELF file with $SQUASHELF" - "$SQUASHELF" -v --nosht -r 0xA0300000-0xA0500000 "$bin_path" "$temp_file" + "$SQUASHELF" -v --nosht -r "$PFLASH1_RANGE" "$bin_path" "$temp_file" echo "Replacing original ELF with squashed version" cp "$temp_file" "$bin_path" rm "$temp_file" @@ -241,11 +244,15 @@ do_gen_target() { local wolfboot_partition_swap_address if [[ -n "${TARGET_OPTS[use_elf_format]}" ]]; then + # These addresses and values must match those defined in the test-app + # linker file wolfboot_partition_size=0xC0000 wolfboot_partition_boot_address=0xA047C000 wolfboot_partition_update_address=0xA053C000 wolfboot_partition_swap_address=0xA05FC000 else + # These addresses and values must match those defined in the test-app + # linker file wolfboot_partition_size=0x17C000 wolfboot_partition_boot_address=0xA0300000 wolfboot_partition_update_address=0xA047C000 diff --git a/tools/squashelf/README.md b/tools/squashelf/README.md index ea6e972d..3b8af741 100644 --- a/tools/squashelf/README.md +++ b/tools/squashelf/README.md @@ -60,10 +60,3 @@ squashelf [options] ```bash squashelf --help ``` - -## Dependencies - -`squashelf` depends on `libelf`. You can typically install the development package for `libelf` using your system's package manager. - -* **Debian/Ubuntu:** `sudo apt-get install libelf-dev` - diff --git a/tools/squashelf/squashelf.c b/tools/squashelf/squashelf.c index d2884050..1ee422aa 100644 --- a/tools/squashelf/squashelf.c +++ b/tools/squashelf/squashelf.c @@ -107,20 +107,8 @@ static int parseRange(const char* rangeStr, AddressRange* range) char* minStr = copyStr; char* maxStr = dashPos + 1; - /* Check for hex or decimal format and convert */ - if (strncmp(minStr, "0x", 2) == 0 || strncmp(minStr, "0X", 2) == 0) { - range->min = strtoull(minStr, NULL, 16); - } - else { - range->min = strtoull(minStr, NULL, 10); - } - - if (strncmp(maxStr, "0x", 2) == 0 || strncmp(maxStr, "0X", 2) == 0) { - range->max = strtoull(maxStr, NULL, 16); - } - else { - range->max = strtoull(maxStr, NULL, 10); - } + range->min = strtoull(minStr, NULL, 0); + range->max = strtoull(maxStr, NULL, 0); free(copyStr);