diff mbox series

[U-Boot,v2] fdt: Fix mkimage list to try every header type

Message ID 20190410164632.19597-1-jorhand@microsoft.com
State Accepted
Delegated to: Simon Glass
Headers show
Series [U-Boot,v2] fdt: Fix mkimage list to try every header type | expand

Commit Message

Jordan Hand April 10, 2019, 4:46 p.m. UTC
Image type is not supplied to `mkimage -l`. For this reason, we cannot
use imagetool_verify_print_header_by_type. Instead, this patch uses
imagetool_verify_print_header to look through all header types to find
one where image validation succeeds.

This patch fixes failures in test/image/test-imagetools.sh

Signed-off-by: Jordan Hand <jorhand@microsoft.com>
Tested-by: Alex Kiernan <alex.kiernan@gmail.com>
Tested-by: Vagrant Cascadian <vagrant@debian.org>
---

Changes in v2:
- Fix patch formatting to move commit message above the cut

 tools/mkimage.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

Comments

Simon Glass April 12, 2019, 9:49 p.m. UTC | #1
Image type is not supplied to `mkimage -l`. For this reason, we cannot
use imagetool_verify_print_header_by_type. Instead, this patch uses
imagetool_verify_print_header to look through all header types to find
one where image validation succeeds.

This patch fixes failures in test/image/test-imagetools.sh

Signed-off-by: Jordan Hand <jorhand@microsoft.com>
Tested-by: Alex Kiernan <alex.kiernan@gmail.com>
Tested-by: Vagrant Cascadian <vagrant@debian.org>
---

Changes in v2:
- Fix patch formatting to move commit message above the cut

 tools/mkimage.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 2899adff81..76c3406d37 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -403,14 +403,21 @@  int main(int argc, char **argv)
 			exit (EXIT_FAILURE);
 		}
 
-		/*
-		 * scan through mkimage registry for all supported image types
-		 * and verify the input image file header for match
-		 * Print the image information for matched image type
-		 * Returns the error code if not matched
-		 */
-		retval = imagetool_verify_print_header_by_type(ptr, &sbuf,
-				tparams, &params);
+		if (params.fflag) {
+			/*
+			 * Verifies the header format based on the expected header for
+			 * image type in tparams
+			 */
+			retval = imagetool_verify_print_header_by_type(ptr, &sbuf,
+					tparams, &params);
+		} else {
+			/**
+			 * When listing the image, we are not given the image type. Simply check all
+			 * image types to find one that matches our header
+			 */
+			retval = imagetool_verify_print_header(ptr, &sbuf,
+					tparams, &params);
+		}
 
 		(void) munmap((void *)ptr, sbuf.st_size);
 		(void) close (ifd);