On Monday 06 February 2023 14:43:07 Tom Rini wrote: > On Sun, Jan 29, 2023 at 05:44:11PM +0100, Pali Rohár wrote: > > > If image file is stored on flash partition then it contains padding, which > > is not part of the image itself. Image data size is stored in the image > > header. So use image size from the header instead of expecting that total > > image file size is size of the header plus size of the image data. This > > allows dumpimage to parse image files with padding (e.g. dumped from flash > > partition). > > > > Signed-off-by: Pali Rohár <p...@kernel.org> > > Reviewed-by: Simon Glass <s...@chromium.org> > > This breaks imx6q_bosch_acc imx6dl_mamoj as: > ./tools/mkimage: Failed to verify header of u-boot-ivt.img > > now happens.
Ah :-( That is because IH_TYPE_FIRMWARE_IVT support was hacked into default_image.c and its format is not compatible with other formats supported but default_image.c I tested following patch with imx6q_bosch_acc_defconfig and it worked: diff --git a/tools/default_image.c b/tools/default_image.c index 0996e1dfe9c8..e0e234a1e8f4 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -83,6 +83,10 @@ static int image_verify_header(unsigned char *ptr, int image_size, data = (const unsigned char *)ptr + sizeof(struct legacy_img_hdr); len = image_get_data_size(hdr); + if (image_get_type(hdr) == IH_TYPE_FIRMWARE_IVT) + /* Add size of CSF minus IVT */ + len -= 0x2060 - sizeof(flash_header_v2_t); + if (image_size - sizeof(struct legacy_img_hdr) < len) { debug("%s: Bad image size: \"%s\" is no valid image\n", params->cmdname, params->imagefile); That is why validation functions _must_ always be implemented. Feel free to amend this chunk into patch 2/2 and check if it works also for you. And looking at the image_extract_subimage() code in default_image.c and it is also broken for IH_TYPE_FIRMWARE_IVT. Well, I'm not going to fix image_extract_subimage() as it was broken before and nobody spotted it yet.