]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
habv4: tools: Avoid hardcoded CSF size for SPL targets
authorBreno Matheus Lima <breno.lima@nxp.com>
Thu, 18 Jul 2019 12:34:15 +0000 (12:34 +0000)
committerStefano Babic <sbabic@denx.de>
Tue, 8 Oct 2019 14:35:59 +0000 (16:35 +0200)
Currently it's not possible to authenticate the U-Boot proper of
mx6ul_14x14_evk_defconfig target:

Authenticate image from DDR location 0x877fffc0...
bad magic magic=0x0 length=0x00 version=0x3
bad length magic=0x0 length=0x00 version=0x3
bad version magic=0x0 length=0x00 version=0x3
spl: ERROR:  image authentication fail

Commit 0633e134784a ("imx: hab: Increase CSF_SIZE for i.MX6 and
i.MX7 devices") has increased CSF_SIZE to avoid a possible issue
when booting encrypted boot images.

Commit d21bd69b6e95 ("tools: mkimage: add firmware-ivt image type
for HAB verification") is hardcoding the CSF and IVT sizes, the
new CSF size is not being considered and u-boot-ivt.img fails to
boot.

Avoid hardcoded CSF and IVT size to fix this issue.

Signed-off-by: Breno Lima <breno.lima@nxp.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
common/image.c
tools/default_image.c

index 179eef0bd2dc8524bec46d4455de88d8da718162..9badb915f48adea91c2ab2088e518a3ba44ca3d3 100644 (file)
@@ -61,6 +61,8 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
 #endif /* !USE_HOSTCC*/
 
 #include <u-boot/crc.h>
+#include <imximage.h>
+#include <generated/autoconf.h>
 
 #ifndef CONFIG_SYS_BARGSIZE
 #define CONFIG_SYS_BARGSIZE 512
@@ -378,9 +380,9 @@ void image_print_contents(const void *ptr)
                }
        } else if (image_check_type(hdr, IH_TYPE_FIRMWARE_IVT)) {
                printf("HAB Blocks:   0x%08x   0x0000   0x%08x\n",
-                               image_get_load(hdr) - image_get_header_size(),
-                               image_get_size(hdr) + image_get_header_size()
-                                               - 0x1FE0);
+                       image_get_load(hdr) - image_get_header_size(),
+                       (int)(image_get_size(hdr) + image_get_header_size()
+                       + sizeof(flash_header_v2_t) - CONFIG_CSF_SIZE));
        }
 }
 
index 4b7d1ed4a1a5247d72a1f73c65466c2daac486e9..7a26232779807e187b713b02ad27582abb131bb5 100644 (file)
@@ -19,6 +19,8 @@
 #include <image.h>
 #include <tee/optee.h>
 #include <u-boot/crc.h>
+#include <imximage.h>
+#include <generated/autoconf.h>
 
 static image_header_t header;
 
@@ -106,7 +108,8 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
 
        if (params->type == IH_TYPE_FIRMWARE_IVT)
                /* Add size of CSF minus IVT */
-               imagesize = sbuf->st_size - sizeof(image_header_t) + 0x1FE0;
+               imagesize = sbuf->st_size - sizeof(image_header_t)
+                           + CONFIG_CSF_SIZE - sizeof(flash_header_v2_t);
        else
                imagesize = sbuf->st_size - sizeof(image_header_t);