tools: xilinx: Fix zynq/zynqmp image recognition
authorMichal Simek <michal.simek@xilinx.com>
Wed, 14 Mar 2018 10:02:24 +0000 (11:02 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 23 Mar 2018 08:36:15 +0000 (09:36 +0100)
There is an issue to recognize zynq or zynqmp image because header
checking is just the same. That's why zynqmp images are recognized as
zynq one.
Check unused fields which are initialized to zero in zynq format
(__reserved1 0x38 and __reserved2 0x44) which are initialized for
zynqmp. This should ensure that images are properly recognized by:
./tools/mkimage -l spl/boot.bin

Also show image type as ZynqMP instead of Zynq which is confusing.

Reported-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Tested-by: Alexander Graf <agraf@suse.de>
tools/zynqimage.c
tools/zynqmpimage.c

index 021d2d3fc91f0ae515b160b33a56a8872fd5dda2..aa003a7543b65d99fb0fdd8a81db34f5bc9eabb1 100644 (file)
@@ -147,6 +147,12 @@ static int zynqimage_verify_header(unsigned char *ptr, int image_size,
        if (image_size < sizeof(struct zynq_header))
                return -1;
 
+       if (zynqhdr->__reserved1 != 0)
+               return -1;
+
+       if (zynqhdr->__reserved2 != 0)
+               return -1;
+
        if (zynqhdr->width_detection != HEADER_WIDTHDETECTION)
                return -1;
        if (zynqhdr->image_identifier != HEADER_IMAGEIDENTIFIER)
index f48ac6dbe5056de5b36a1c99695908bfdeeadb41..a61fb17c40d2adf5ef33f6a16674c49ee8a5463e 100644 (file)
@@ -178,7 +178,7 @@ static void zynqmpimage_print_header(const void *ptr)
        struct zynqmp_header *zynqhdr = (struct zynqmp_header *)ptr;
        int i;
 
-       printf("Image Type   : Xilinx Zynq Boot Image support\n");
+       printf("Image Type   : Xilinx ZynqMP Boot Image support\n");
        printf("Image Offset : 0x%08x\n", le32_to_cpu(zynqhdr->image_offset));
        printf("Image Size   : %lu bytes (%lu bytes packed)\n",
               (unsigned long)le32_to_cpu(zynqhdr->image_size),