summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLey Foon Tan <ley.foon.tan@intel.com>2020-12-11 14:46:47 +0800
committerLey Foon Tan <ley.foon.tan@intel.com>2021-01-15 17:48:39 +0800
commitbcf33fac64998d4c0c030d0711e6b02039f71a8d (patch)
treecc4880d0bc2973b43858eb5e07bca742ee5fba7c /tools
parent7d8890d8fb608fc86478c814f2ea1979b5d80bc0 (diff)
downloadu-boot-bcf33fac64998d4c0c030d0711e6b02039f71a8d.tar.gz
u-boot-bcf33fac64998d4c0c030d0711e6b02039f71a8d.tar.xz
u-boot-bcf33fac64998d4c0c030d0711e6b02039f71a8d.zip
tools: socfpgaimage: Print image header information
Print image header information if the header is verified. Example output from mkimage "-l" option: $ ./tools/mkimage -l spl/u-boot-spl.sfp Image Type : Cyclone V / Arria V SoC Image Validation word : 0x31305341 Version : 0x00000000 Flags : 0x00000000 Program length : 0x00003a59 Header checksum : 0x00000188 $ ./tools/mkimage -l spl/u-boot-spl.sfp Image Type : Arria 10 SoC Image Validation word : 0x31305341 Version : 0x00000001 Flags : 0x00000000 Header length : 0x00000014 Program length : 0x000138e0 Program entry : 0x00000014 Header checksum : 0x00000237 Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/socfpgaimage.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c
index 3ba3c93af1..5808b383e9 100644
--- a/tools/socfpgaimage.c
+++ b/tools/socfpgaimage.c
@@ -274,12 +274,51 @@ static int socfpgaimage_verify_header(unsigned char *ptr, int image_size,
return sfp_verify_buffer(ptr);
}
+static void socfpgaimage_print_header_v0(struct socfpga_header_v0 *header)
+{
+ printf("Image Type\t: Cyclone V / Arria V SoC Image\n");
+ printf("Validation word\t: 0x%08x\n",
+ le32_to_cpu(header->validation));
+ printf("Version\t\t: 0x%08x\n", header->version);
+ printf("Flags\t\t: 0x%08x\n", header->flags);
+ printf("Program length\t: 0x%08x\n",
+ le16_to_cpu(header->length_u32));
+ printf("Header checksum\t: 0x%08x\n",
+ le16_to_cpu(header->checksum));
+}
+
+static void socfpgaimage_print_header_v1(struct socfpga_header_v1 *header)
+{
+ printf("Image Type\t: Arria 10 SoC Image\n");
+ printf("Validation word\t: 0x%08x\n",
+ le32_to_cpu(header->validation));
+ printf("Version\t\t: 0x%08x\n", header->version);
+ printf("Flags\t\t: 0x%08x\n", header->flags);
+ printf("Header length\t: 0x%08x\n",
+ le16_to_cpu(header->header_u8));
+ printf("Program length\t: 0x%08x\n",
+ le32_to_cpu(header->length_u8));
+ printf("Program entry\t: 0x%08x\n",
+ le32_to_cpu(header->entry_offset));
+ printf("Header checksum\t: 0x%08x\n",
+ le16_to_cpu(header->checksum));
+}
+
static void socfpgaimage_print_header(const void *ptr)
{
- if (sfp_verify_buffer(ptr) == 0)
- printf("Looks like a sane SOCFPGA preloader\n");
- else
+ const void *header = ptr + HEADER_OFFSET;
+ struct socfpga_header_v0 *header_v0;
+
+ if (sfp_verify_buffer(ptr) == 0) {
+ header_v0 = (struct socfpga_header_v0 *)header;
+
+ if (header_v0->version == 0)
+ socfpgaimage_print_header_v0(header_v0);
+ else
+ socfpgaimage_print_header_v1((struct socfpga_header_v1 *)header);
+ } else {
printf("Not a sane SOCFPGA preloader\n");
+ }
}
static int socfpgaimage_check_params_v0(struct image_tool_params *params)