[PATCH RFC u-boot-mvebu 45/59] tools: mkimage: Do not fill legacy_img_hdr for non-legacy XIP images

Pali Rohár pali at kernel.org
Tue Feb 21 21:19:11 CET 2023


Skip filling legacy_img_hdr structure for XIP images which do not use
legacy_img_hdr structure header. Adding unwanted header to other image
formats, like kwbimage cause generation of broken image.

Signed-off-by: Pali Rohár <pali at kernel.org>
---
 tools/mkimage.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 30c6df77081f..955a1f39a419 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -842,7 +842,9 @@ copy_file (int ifd, const char *datafile, int pad)
 		exit (EXIT_FAILURE);
 	}
 
-	if (params.xflag) {
+	if (params.xflag &&
+	    (((params.type > IH_TYPE_INVALID) && (params.type < IH_TYPE_FLATDT)) ||
+	     (params.type == IH_TYPE_KERNEL_NOLOAD) || (params.type == IH_TYPE_FIRMWARE_IVT))) {
 		unsigned char *p = NULL;
 		/*
 		 * XIP: do not append the struct legacy_img_hdr at the
-- 
2.20.1



More information about the U-Boot mailing list