]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: socfpgaimage: Print image header information
authorLey Foon Tan <ley.foon.tan@intel.com>
Fri, 11 Dec 2020 06:46:47 +0000 (14:46 +0800)
committerLey Foon Tan <ley.foon.tan@intel.com>
Fri, 15 Jan 2021 09:48:39 +0000 (17:48 +0800)
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>
tools/socfpgaimage.c

index 3ba3c93af1bdf5832f74bdd85b92accbaced2c82..5808b383e9cbde1a68e7b3cda9092787c39a7625 100644 (file)
@@ -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)