Skip to content

mkimage: Tidy up error handling

Tom Rini u-boot 1 version New

Get series with b4
b4 am 20160701164523.GW19080@bill-the-cat

Versions newest first

  1. v1 Latest14 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14mkimage: Honour the default image type with auto-fit+0 -00 replies
1/14mkimage: Honour the default image type with auto-fit+0 -00 replies
2/14mkimage: Explain the auto-fit imagefile special case+0 -00 replies
3/14mkimage: Require a data file when auto-fit is used+0 -00 replies
3/14mkimage: Require a data file when auto-fit is used+0 -00 replies
4/14mkimage: Drop premature setting of params.fit_image_type+0 -00 replies
4/14mkimage: Drop premature setting of params.fit_image_type+0 -00 replies
5/14mkimage: Drop blank line before main()+0 -00 replies
5/14mkimage: Drop blank line before main()+0 -00 replies
6/14image: Correct auto-fit architecture property name+0 -00 replies
6/14image: Correct auto-fit architecture property name+0 -00 replies
7/14image: Convert the IH_... values to enums+0 -00 replies
7/14image: Convert the IH_... values to enums+0 -00 replies
8/14image: Create a table of information for each category+0 -00 replies
8/14image: Create a table of information for each category+0 -00 replies
9/14image: Add a name for invalid types+0 -00 replies
9/14image: Add a name for invalid types+0 -00 replies
10/14image: Add functions to obtain category information+0 -00 replies
10/14image: Add functions to obtain category information+0 -00 replies
11/14mkimage: Allow display of a list of any image header category+0 -00 replies
11/14mkimage: Allow display of a list of any image header category+0 -00 replies
12/14mkimage: Use generic code for showing an 'image type' error+0 -00 replies
12/14mkimage: Use generic code for showing an 'image type' error+0 -00 replies
13/14mkimage: Show item lists for all categories+0 -00 replies
13/14mkimage: Show item lists for all categories+0 -00 replies
14/14tools: Allow building with debug enabled+0 -00 replies
14/14tools: Allow building with debug enabled+0 -00 replies

Reviews trailers per patch

26 of 27 patches have a Reviewed-by or Acked-by.

PatchTom Rini
1/14R-b
1/14R-b
2/14
3/14R-b
3/14R-b
4/14R-b
4/14R-b
5/14R-b
5/14R-b
6/14R-b
6/14R-b
7/14R-b
7/14R-b
8/14R-b
8/14R-b
9/14R-b
9/14R-b
10/14R-b
10/14R-b
11/14R-b
11/14R-b
12/14R-b
12/14R-b
13/14R-b
13/14R-b
14/14R-b
14/14R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [U-Boot] [PATCH 00/14] mkimage: Tidy up error handling
Quoted 77 lines · Simon Glass

Hi,

Quoted 66 lines · Tom Rini
Quoted 65 lines · Stefano Babic

Hi Simon,

Quoted 5 lines · Simon Glass

There are a few problems when mkimage is provided with invalid arguments. In one case it crashes. When an invalid image type it is provided it lists the valid types, but this is not implemented for compression, architecture or OS.

There is another issue related to mkimage. It looks like it is broken since a lot of time, but it appears it was not noted.

mkimage -l is broken. Testing with i.MX images (imximage), it does not show the header, but it reports the output as it as a "gpimage".

In fact:

./tools/mkimage -l test.imx
GP Header: Size d1002040 LoadAddr 8017

It should be:

./tools/mkimage -l test.imx

Image Type:   Freescale IMX Boot Image
Image Ver:    2 (i.MX53/6/7 compatible)
Data Size:    331776 Bytes = 324.00 kB = 0.32 MB
Load Address: 177ff420
Entry Point:  17800000

The reason is due to the format of the gpimage itself. It has no magic number, and checking for its correctness means in gph_verify_header() just check that size and address are not NULL. That let think that the image is a gpimage, it is not. gpimage simply uses the image and does not let to check for further image headers that are put int the (sorted) list with the U_BOOT_IMAGE_TYPE. Image types that are in the list *before* gpimage are correctly recognized and printed, the following (as imximage) not.

A quick fix (maybe just for the release ?) should be to let gpimage (but I do not know if there is another image type that misbehaves as it does) as the last one in the list: if all detections fail, the last one without any possibility for detection (gpimage) runs. The following patch works for me:

tools/Makefile +2 -2
index 63355aa..f72294a 100644
@@ -76,8 +76,6 @@ dumpimage-mkimage-objs := aisimage.o \
                      lib/fdtdec.o \
                      fit_common.o \
                      fit_image.o \
-                     gpimage.o \
-                     gpimage-common.o \
                      common/image-fit.o \
                      image-host.o \
                      common/image.o \
@@ -100,6 +98,8 @@ dumpimage-mkimage-objs := aisimage.o \
                      zynqimage.o \
                      zynqmpimage.o \
                      $(LIBFDT_OBJS) \
+                     gpimage.o \
+                     gpimage-common.o \
                      $(RSA_OBJS-y)
 
Quoted 7 lines
Quoted 4 lines
tools/Makefile +0 -0
 dumpimage-objs := $(dumpimage-mkimage-objs) dumpimage.o

What do you think ? If this could be a solution for release, I send a formal patch.

Ug, I think we need what you're saying at least for release. I'm kicking off a big bisect now to see just when this last worked right.

Quoted 4 lines

That patch seems reasonable to me for now. My series is intended for the next release.

Perhaps verify_header() should return a value meaning 'possibly'?

So, this was broken by:
commit 0ca6691c2ec20ff264d882854c339795579991f5

Author: Guilherme Maciel Ferreira <[email protected]>
Date:   Thu Jan 15 02:48:05 2015 -0200

imagetool: move common code to imagetool module

And yes, perhaps some way to say to say "maybe" is enough. Or maybe we just need to allow some to say that they can't verify? I think we're thinking along the same lines.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160701/f5c39d49/attachment.sig>