Skip to contentSkip to conversation

tools: mkimage: cleanups + allow to create legacy image with type flat_dt

PATCH Superseded Marc Kleine-Budde 3 participants 8 messages Oct 31, 2022 – Nov 1, 2022

Subsystems (7)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover tools: mkimage: cleanups + allow to create legacy image with type flat_dt

Hello,

the first patch cleans up the error message output if struct image_type_params::set_header is set, the remaining 2 add support for creating legacy images with type flat_dt.

regards,
Marc

#1 lore raw

PATCH 1/3 tools: mkimage: don't print error message "Success" in case of failure

In case there's no struct image_type_params::set_header callback, no "errno" will be set. Don't fail with an error message, followed by "Success". Remove the printing of the human readable "errno" value.

---
 tools/mkimage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/mkimage.c +2 -2
index 30c6df77081f..35a6b1fb799c 100644
@@ -760,8 +760,8 @@ int main(int argc, char **argv)
 	if (tparams->set_header)
 		tparams->set_header (ptr, &sbuf, ifd, &params);
 	else {
-		fprintf (stderr, "%s: Can't set header for %s: %s\n",
-			params.cmdname, tparams->name, strerror(errno));
+		fprintf (stderr, "%s: Can't set header for %s\n",
+			params.cmdname, tparams->name);
 		exit (EXIT_FAILURE);
 	}
 
Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/3 tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers

In reply to Marc Kleine-Budde

This is a preparation patch to allow legacy images with the IH_TYPE_FLATDT ("flat_dt") image type.

---
 tools/aisimage.c      | 2 +-
 tools/atmelimage.c    | 2 +-
 tools/default_image.c | 2 +-
 tools/dumpimage.c     | 2 +-
 tools/fit_common.c    | 2 +-
 tools/fit_common.h    | 2 +-
 tools/gpimage.c       | 2 +-
 tools/imagetool.c     | 4 ++--
 tools/imagetool.h     | 5 +++--
 tools/imx8image.c     | 2 +-
 tools/imx8mimage.c    | 2 +-
 tools/imximage.c      | 2 +-
 tools/kwbimage.c      | 2 +-
 tools/lpc32xximage.c  | 2 +-
 tools/mkimage.c       | 4 ++--
 tools/mtk_image.c     | 2 +-
 tools/mxsimage.c      | 2 +-
 tools/omapimage.c     | 2 +-
 tools/pblimage.c      | 2 +-
 tools/rkimage.c       | 2 +-
 tools/rksd.c          | 2 +-
 tools/rkspi.c         | 2 +-
 tools/socfpgaimage.c  | 4 ++--
 tools/stm32image.c    | 2 +-
 tools/sunxi_egon.c    | 2 +-
 tools/sunxi_toc0.c    | 2 +-
 tools/ublimage.c      | 2 +-
 tools/vybridimage.c   | 2 +-
 tools/zynqimage.c     | 2 +-
 tools/zynqmpbif.c     | 2 +-
 tools/zynqmpimage.c   | 2 +-
 31 files changed, 36 insertions(+), 35 deletions(-)
tools/aisimage.c +1 -1
index b8b3ee32070f..21e5a8df8aad 100644
@@ -360,7 +360,7 @@ static int aisimage_generate(struct image_tool_params *params,
 	return 0;
 }
 
-static int aisimage_check_image_types(uint8_t type)
+static int aisimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_AISIMAGE)
 		return EXIT_SUCCESS;
tools/atmelimage.c +1 -1
index 7b3b243d58b7..3c084ba8b48d 100644
@@ -11,7 +11,7 @@
 
 #define pr_err(fmt, args...) fprintf(stderr, "atmelimage Error: " fmt, ##args)
 
-static int atmel_check_image_type(uint8_t type)
+static int atmel_check_image_type(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_ATMELIMAGE)
 		return EXIT_SUCCESS;
tools/default_image.c +1 -1
index 4a067e65862e..9a6b50a946ba 100644
@@ -24,7 +24,7 @@
 
 static struct legacy_img_hdr header;
 
-static int image_check_image_types(uint8_t type)
+static int image_check_image_types(uint8_t type, bool legacy)
 {
 	if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
 	    (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
tools/dumpimage.c +1 -1
index 4791dd0dfe18..3c840985f2fe 100644
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
 	params.imagefile = argv[optind];
 
 	/* set tparams as per input type_id */
-	tparams = imagetool_get_type(params.type);
+	tparams = imagetool_get_type(&params);
 	if (!params.lflag && tparams == NULL) {
 		fprintf(stderr, "%s: unsupported type: %s\n",
 			params.cmdname, genimg_get_type_name(params.type));
tools/fit_common.c +1 -1
index 01649760ac00..b4aa89b53577 100644
@@ -41,7 +41,7 @@ int fit_verify_header(unsigned char *ptr, int image_size,
 	return EXIT_SUCCESS;
 }
 
-int fit_check_image_types(uint8_t type)
+int fit_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_FLATDT)
 		return EXIT_SUCCESS;
tools/fit_common.h +1 -1
index 920a16acfdb2..0fd7a504cf05 100644
@@ -21,7 +21,7 @@
 int fit_verify_header(unsigned char *ptr, int image_size,
 			struct image_tool_params *params);
 
-int fit_check_image_types(uint8_t type);
+int fit_check_image_types(uint8_t type, bool legacy);
 
 /**
  * Map an FDT into memory, optionally increasing its size
tools/gpimage.c +1 -1
index 27de4cfaed77..eda2532ac87a 100644
@@ -26,7 +26,7 @@
 static uint8_t gpimage_header[GPIMAGE_HDR_SIZE];
 
 /* to be in keystone gpimage */
-static int gpimage_check_image_types(uint8_t type)
+static int gpimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_GPIMAGE)
 		return EXIT_SUCCESS;
tools/imagetool.c +2 -2
index f14ca2fb979f..ff8a293f8a50 100644
@@ -9,7 +9,7 @@
 
 #include <image.h>
 
-struct image_type_params *imagetool_get_type(int type)
+struct image_type_params *imagetool_get_type(const struct image_tool_params *params)
 {
 	struct image_type_params **curr;
 	INIT_SECTION(image_type);
@@ -19,7 +19,7 @@ struct image_type_params *imagetool_get_type(int type)
 
 	for (curr = start; curr != end; curr++) {
 		if ((*curr)->check_image_type) {
-			if (!(*curr)->check_image_type(type))
+			if (!(*curr)->check_image_type(params->type, params->Lflag))
 				return *curr;
 		}
 	}
tools/imagetool.h +3 -2
index ca7c2e48ba91..a64780e16d2d 100644
@@ -50,6 +50,7 @@ struct image_tool_params {
 	int fflag;
 	int iflag;
 	int lflag;
+	int Lflag;
 	int pflag;
 	int vflag;
 	int xflag;
@@ -149,7 +150,7 @@ struct image_type_params {
 	 * whether input (-T <image_type>) is supported by registered image
 	 * generation/list low level code
 	 */
-	int (*check_image_type) (uint8_t);
+	int (*check_image_type) (uint8_t, bool);
 	/* This callback function will be executed if fflag is defined */
 	int (*fflag_handle) (struct image_tool_params *);
 	/*
@@ -175,7 +176,7 @@ struct image_type_params {
  * if input type_id is not supported by any of image_type_support
  *     returns NULL
  */
-struct image_type_params *imagetool_get_type(int type);
+struct image_type_params *imagetool_get_type(const struct image_tool_params *params);
 
 /*
  * imagetool_verify_print_header() - verifies the image header
tools/imx8image.c +1 -1
index 01e14869114f..77f8d11f5c85 100644
@@ -34,7 +34,7 @@ static void imx8image_print_header(const void *ptr)
 {
 }
 
-static int imx8image_check_image_types(uint8_t type)
+static int imx8image_check_image_types(uint8_t type, bool legacy)
 {
 	return (type == IH_TYPE_IMX8IMAGE) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
tools/imx8mimage.c +1 -1
index 35d0a92bfdf0..9316445400ed 100644
@@ -64,7 +64,7 @@ static void imx8mimage_print_header(const void *ptr)
 {
 }
 
-static int imx8mimage_check_image_types(uint8_t type)
+static int imx8mimage_check_image_types(uint8_t type, bool legacy)
 {
 	return (type == IH_TYPE_IMX8MIMAGE) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
tools/imximage.c +1 -1
index 5c23fba3b121..92019f520ab5 100644
@@ -794,7 +794,7 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name)
 }
 
 
-static int imximage_check_image_types(uint8_t type)
+static int imximage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_IMXIMAGE)
 		return EXIT_SUCCESS;
tools/kwbimage.c +1 -1
index 6abb9f2d5c01..2a5cf7fec6c4 100644
@@ -1952,7 +1952,7 @@ static void kwbimage_print_header(const void *ptr)
 	printf("Entry Point:  %08x\n", mhdr->execaddr);
 }
 
-static int kwbimage_check_image_types(uint8_t type)
+static int kwbimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_KWBIMAGE)
 		return EXIT_SUCCESS;
tools/lpc32xximage.c +1 -1
index 37931f91840c..a995c53ccac9 100644
@@ -72,7 +72,7 @@ struct nand_page_0_boot_header {
 
 static struct nand_page_0_boot_header lpc32xximage_header;
 
-static int lpc32xximage_check_image_types(uint8_t type)
+static int lpc32xximage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_LPC32XXIMAGE)
 		return EXIT_SUCCESS;
tools/mkimage.c +2 -2
index 35a6b1fb799c..6d029afab3a8 100644
@@ -448,7 +448,7 @@ int main(int argc, char **argv)
 	process_args(argc, argv);
 
 	/* set tparams as per input type_id */
-	tparams = imagetool_get_type(params.type);
+	tparams = imagetool_get_type(&params);
 	if (tparams == NULL && !params.lflag) {
 		fprintf (stderr, "%s: unsupported type %s\n",
 			params.cmdname, genimg_get_type_name(params.type));
@@ -809,7 +809,7 @@ copy_file (int ifd, const char *datafile, int pad)
 	uint8_t zeros[4096];
 	int offset = 0;
 	int size, ret;
-	struct image_type_params *tparams = imagetool_get_type(params.type);
+	struct image_type_params *tparams = imagetool_get_type(&params);
 
 	memset(zeros, 0, sizeof(zeros));
 
tools/mtk_image.c +1 -1
index 5ef9334163de..0be0e04e7941 100644
@@ -87,7 +87,7 @@ static void crc32_normal_init(uint32_t *crc32c_table, uint32_t poly)
 	}
 }
 
-static int mtk_image_check_image_types(uint8_t type)
+static int mtk_image_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_MTKIMAGE)
 		return EXIT_SUCCESS;
tools/mxsimage.c +1 -1
index fee022aab46b..46081a3a96aa 100644
@@ -2163,7 +2163,7 @@ static void sb_free_image(struct sb_image_ctx *ictx)
 /*
  * MXSSB-MKIMAGE glue code.
  */
-static int mxsimage_check_image_types(uint8_t type)
+static int mxsimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_MXSIMAGE)
 		return EXIT_SUCCESS;
tools/omapimage.c +1 -1
index c59cdcc79b3d..0060daa4e249 100644
@@ -29,7 +29,7 @@ static int do_swap32 = 0;
 
 static uint8_t omapimage_header[OMAP_FILE_HDR_SIZE];
 
-static int omapimage_check_image_types(uint8_t type)
+static int omapimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_OMAPIMAGE)
 		return EXIT_SUCCESS;
tools/pblimage.c +1 -1
index bd639c276f9c..b0f855f9c82b 100644
@@ -218,7 +218,7 @@ void pbl_load_uboot(int ifd, struct image_tool_params *params)
 	}
 }
 
-static int pblimage_check_image_types(uint8_t type)
+static int pblimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_PBLIMAGE)
 		return EXIT_SUCCESS;
tools/rkimage.c +1 -1
index 1c5540b1c3d1..df9e6eadfdc9 100644
@@ -21,7 +21,7 @@ static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
 		rkcommon_rc4_encode_spl(buf, 0, params->file_size);
 }
 
-static int rkimage_check_image_type(uint8_t type)
+static int rkimage_check_image_type(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_RKIMAGE)
 		return EXIT_SUCCESS;
tools/rksd.c +1 -1
index 7d46a1b07b3a..9b36c63dd042 100644
@@ -12,7 +12,7 @@
 #include "mkimage.h"
 #include "rkcommon.h"
 
-static int rksd_check_image_type(uint8_t type)
+static int rksd_check_image_type(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_RKSD)
 		return EXIT_SUCCESS;
tools/rkspi.c +1 -1
index f2530f7bde34..8e71f5877be1 100644
@@ -45,7 +45,7 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd,
 	}
 }
 
-static int rkspi_check_image_type(uint8_t type)
+static int rkspi_check_image_type(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_RKSPI)
 		return EXIT_SUCCESS;
tools/socfpgaimage.c +2 -2
index eba812fec969..a5d11b306376 100644
@@ -358,14 +358,14 @@ static int socfpgaimage_check_params_v1(struct image_tool_params *params)
 		(params->lflag && (params->dflag || params->fflag));
 }
 
-static int socfpgaimage_check_image_types_v0(uint8_t type)
+static int socfpgaimage_check_image_types_v0(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_SOCFPGAIMAGE)
 		return EXIT_SUCCESS;
 	return EXIT_FAILURE;
 }
 
-static int socfpgaimage_check_image_types_v1(uint8_t type)
+static int socfpgaimage_check_image_types_v1(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_SOCFPGAIMAGE_V1)
 		return EXIT_SUCCESS;
tools/stm32image.c +1 -1
index 18357c051822..7bfae93e1074 100644
@@ -70,7 +70,7 @@ static uint32_t stm32image_checksum(void *start, uint32_t len)
 	return csum;
 }
 
-static int stm32image_check_image_types(uint8_t type)
+static int stm32image_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_STM32IMAGE)
 		return EXIT_SUCCESS;
tools/sunxi_egon.c +1 -1
index d45b6f5e4352..7a1a4ce0f96a 100644
@@ -166,7 +166,7 @@ static void egon_set_header(void *buf, struct stat *sbuf, int infd,
 	header->check_sum = cpu_to_le32(checksum);
 }
 
-static int egon_check_image_type(uint8_t type)
+static int egon_check_image_type(uint8_t type, bool legacy)
 {
 	return type == IH_TYPE_SUNXI_EGON ? 0 : 1;
 }
tools/sunxi_toc0.c +1 -1
index 7a8d74bb8e49..1a25ae64d5b7 100644
@@ -883,7 +883,7 @@ err:
 		exit(ret);
 }
 
-static int toc0_check_image_type(uint8_t type)
+static int toc0_check_image_type(uint8_t type, bool legacy)
 {
 	return type == IH_TYPE_SUNXI_TOC0 ? 0 : 1;
 }
tools/ublimage.c +1 -1
index 1d2e897f6b35..0cb443f32874 100644
@@ -183,7 +183,7 @@ static uint32_t parse_cfg_file(struct ubl_header *ublhdr, char *name)
 	return dcd_len;
 }
 
-static int ublimage_check_image_types(uint8_t type)
+static int ublimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_UBLIMAGE)
 		return EXIT_SUCCESS;
tools/vybridimage.c +1 -1
index 94a6684c19b7..a828c7886175 100644
@@ -30,7 +30,7 @@ struct nand_page_0_boot_header {
 
 static struct nand_page_0_boot_header vybridimage_header;
 
-static int vybridimage_check_image_types(uint8_t type)
+static int vybridimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_VYBRIDIMAGE)
 		return EXIT_SUCCESS;
tools/zynqimage.c +1 -1
index d3f418b0612b..95d18ddded9b 100644
@@ -220,7 +220,7 @@ static int zynqimage_check_params(struct image_tool_params *params)
 	return !(params->lflag || params->dflag);
 }
 
-static int zynqimage_check_image_types(uint8_t type)
+static int zynqimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_ZYNQIMAGE)
 		return EXIT_SUCCESS;
tools/zynqmpbif.c +1 -1
index 82ce0ac1a520..747b4349a59e 100644
@@ -102,7 +102,7 @@ static int zynqmpbif_check_params(struct image_tool_params *params)
 	return !(params->lflag || params->dflag);
 }
 
-static int zynqmpbif_check_image_types(uint8_t type)
+static int zynqmpbif_check_image_types(uint8_t type, bool legacy)
 {
 	return (type == IH_TYPE_ZYNQMPBIF) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
tools/zynqmpimage.c +1 -1
index 19b2f02ff150..9c33e17ca11d 100644
@@ -295,7 +295,7 @@ static int zynqmpimage_check_params(struct image_tool_params *params)
 	return !(params->lflag || params->dflag);
 }
 
-static int zynqmpimage_check_image_types(uint8_t type)
+static int zynqmpimage_check_image_types(uint8_t type, bool legacy)
 {
 	if (type == IH_TYPE_ZYNQMPIMAGE)
 		return EXIT_SUCCESS;
Signature · 1 line
2.35.1
#3 lore raw

Re: [PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers

Quoted 476 lines · Marc Kleine-Budde

This is a preparation patch to allow legacy images with the IH_TYPE_FLATDT ("flat_dt") image type.

---
  tools/aisimage.c      | 2 +-
  tools/atmelimage.c    | 2 +-
  tools/default_image.c | 2 +-
  tools/dumpimage.c     | 2 +-
  tools/fit_common.c    | 2 +-
  tools/fit_common.h    | 2 +-
  tools/gpimage.c       | 2 +-
  tools/imagetool.c     | 4 ++--
  tools/imagetool.h     | 5 +++--
  tools/imx8image.c     | 2 +-
  tools/imx8mimage.c    | 2 +-
  tools/imximage.c      | 2 +-
  tools/kwbimage.c      | 2 +-
  tools/lpc32xximage.c  | 2 +-
  tools/mkimage.c       | 4 ++--
  tools/mtk_image.c     | 2 +-
  tools/mxsimage.c      | 2 +-
  tools/omapimage.c     | 2 +-
  tools/pblimage.c      | 2 +-
  tools/rkimage.c       | 2 +-
  tools/rksd.c          | 2 +-
  tools/rkspi.c         | 2 +-
  tools/socfpgaimage.c  | 4 ++--
  tools/stm32image.c    | 2 +-
  tools/sunxi_egon.c    | 2 +-
  tools/sunxi_toc0.c    | 2 +-
  tools/ublimage.c      | 2 +-
  tools/vybridimage.c   | 2 +-
  tools/zynqimage.c     | 2 +-
  tools/zynqmpbif.c     | 2 +-
  tools/zynqmpimage.c   | 2 +-
  31 files changed, 36 insertions(+), 35 deletions(-)
tools/aisimage.c +1 -1
index b8b3ee32070f..21e5a8df8aad 100644
@@ -360,7 +360,7 @@ static int aisimage_generate(struct image_tool_params *params,
  	return 0;
  }
 
-static int aisimage_check_image_types(uint8_t type)
+static int aisimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_AISIMAGE)
  		return EXIT_SUCCESS;
tools/atmelimage.c +1 -1
index 7b3b243d58b7..3c084ba8b48d 100644
@@ -11,7 +11,7 @@
 
  #define pr_err(fmt, args...) fprintf(stderr, "atmelimage Error: " fmt, ##args)
 
-static int atmel_check_image_type(uint8_t type)
+static int atmel_check_image_type(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_ATMELIMAGE)
  		return EXIT_SUCCESS;
tools/default_image.c +1 -1
index 4a067e65862e..9a6b50a946ba 100644
@@ -24,7 +24,7 @@
 
  static struct legacy_img_hdr header;
 
-static int image_check_image_types(uint8_t type)
+static int image_check_image_types(uint8_t type, bool legacy)
  {
  	if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
  	    (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
tools/dumpimage.c +1 -1
index 4791dd0dfe18..3c840985f2fe 100644
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
  	params.imagefile = argv[optind];
 
  	/* set tparams as per input type_id */
-	tparams = imagetool_get_type(params.type);
+	tparams = imagetool_get_type(&params);
  	if (!params.lflag && tparams == NULL) {
  		fprintf(stderr, "%s: unsupported type: %s\n",
  			params.cmdname, genimg_get_type_name(params.type));
tools/fit_common.c +1 -1
index 01649760ac00..b4aa89b53577 100644
@@ -41,7 +41,7 @@ int fit_verify_header(unsigned char *ptr, int image_size,
  	return EXIT_SUCCESS;
  }
 
-int fit_check_image_types(uint8_t type)
+int fit_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_FLATDT)
  		return EXIT_SUCCESS;
tools/fit_common.h +1 -1
index 920a16acfdb2..0fd7a504cf05 100644
@@ -21,7 +21,7 @@
  int fit_verify_header(unsigned char *ptr, int image_size,
  			struct image_tool_params *params);
 
-int fit_check_image_types(uint8_t type);
+int fit_check_image_types(uint8_t type, bool legacy);
 
  /**
   * Map an FDT into memory, optionally increasing its size
tools/gpimage.c +1 -1
index 27de4cfaed77..eda2532ac87a 100644
@@ -26,7 +26,7 @@
  static uint8_t gpimage_header[GPIMAGE_HDR_SIZE];
 
  /* to be in keystone gpimage */
-static int gpimage_check_image_types(uint8_t type)
+static int gpimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_GPIMAGE)
  		return EXIT_SUCCESS;
tools/imagetool.c +2 -2
index f14ca2fb979f..ff8a293f8a50 100644
@@ -9,7 +9,7 @@
 
  #include <image.h>
 
-struct image_type_params *imagetool_get_type(int type)
+struct image_type_params *imagetool_get_type(const struct image_tool_params *params)
  {
  	struct image_type_params **curr;
  	INIT_SECTION(image_type);
@@ -19,7 +19,7 @@ struct image_type_params *imagetool_get_type(int type)
 
  	for (curr = start; curr != end; curr++) {
  		if ((*curr)->check_image_type) {
-			if (!(*curr)->check_image_type(type))
+			if (!(*curr)->check_image_type(params->type, params->Lflag))
  				return *curr;
  		}
  	}
tools/imagetool.h +3 -2
index ca7c2e48ba91..a64780e16d2d 100644
@@ -50,6 +50,7 @@ struct image_tool_params {
  	int fflag;
  	int iflag;
  	int lflag;
+	int Lflag;
  	int pflag;
  	int vflag;
  	int xflag;
@@ -149,7 +150,7 @@ struct image_type_params {
  	 * whether input (-T <image_type>) is supported by registered image
  	 * generation/list low level code
  	 */
-	int (*check_image_type) (uint8_t);
+	int (*check_image_type) (uint8_t, bool);
  	/* This callback function will be executed if fflag is defined */
  	int (*fflag_handle) (struct image_tool_params *);
  	/*
@@ -175,7 +176,7 @@ struct image_type_params {
   * if input type_id is not supported by any of image_type_support
   *     returns NULL
   */
-struct image_type_params *imagetool_get_type(int type);
+struct image_type_params *imagetool_get_type(const struct image_tool_params *params);
 
  /*
   * imagetool_verify_print_header() - verifies the image header
tools/imx8image.c +1 -1
index 01e14869114f..77f8d11f5c85 100644
@@ -34,7 +34,7 @@ static void imx8image_print_header(const void *ptr)
  {
  }
 
-static int imx8image_check_image_types(uint8_t type)
+static int imx8image_check_image_types(uint8_t type, bool legacy)
  {
  	return (type == IH_TYPE_IMX8IMAGE) ? EXIT_SUCCESS : EXIT_FAILURE;
  }
tools/imx8mimage.c +1 -1
index 35d0a92bfdf0..9316445400ed 100644
@@ -64,7 +64,7 @@ static void imx8mimage_print_header(const void *ptr)
  {
  }
 
-static int imx8mimage_check_image_types(uint8_t type)
+static int imx8mimage_check_image_types(uint8_t type, bool legacy)
  {
  	return (type == IH_TYPE_IMX8MIMAGE) ? EXIT_SUCCESS : EXIT_FAILURE;
  }
tools/imximage.c +1 -1
index 5c23fba3b121..92019f520ab5 100644
@@ -794,7 +794,7 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name)
  }
 
 
-static int imximage_check_image_types(uint8_t type)
+static int imximage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_IMXIMAGE)
  		return EXIT_SUCCESS;
tools/kwbimage.c +1 -1
index 6abb9f2d5c01..2a5cf7fec6c4 100644
@@ -1952,7 +1952,7 @@ static void kwbimage_print_header(const void *ptr)
  	printf("Entry Point:  %08x\n", mhdr->execaddr);
  }
 
-static int kwbimage_check_image_types(uint8_t type)
+static int kwbimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_KWBIMAGE)
  		return EXIT_SUCCESS;
tools/lpc32xximage.c +1 -1
index 37931f91840c..a995c53ccac9 100644
@@ -72,7 +72,7 @@ struct nand_page_0_boot_header {
 
  static struct nand_page_0_boot_header lpc32xximage_header;
 
-static int lpc32xximage_check_image_types(uint8_t type)
+static int lpc32xximage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_LPC32XXIMAGE)
  		return EXIT_SUCCESS;
tools/mkimage.c +2 -2
index 35a6b1fb799c..6d029afab3a8 100644
@@ -448,7 +448,7 @@ int main(int argc, char **argv)
  	process_args(argc, argv);
 
  	/* set tparams as per input type_id */
-	tparams = imagetool_get_type(params.type);
+	tparams = imagetool_get_type(&params);
  	if (tparams == NULL && !params.lflag) {
  		fprintf (stderr, "%s: unsupported type %s\n",
  			params.cmdname, genimg_get_type_name(params.type));
@@ -809,7 +809,7 @@ copy_file (int ifd, const char *datafile, int pad)
  	uint8_t zeros[4096];
  	int offset = 0;
  	int size, ret;
-	struct image_type_params *tparams = imagetool_get_type(params.type);
+	struct image_type_params *tparams = imagetool_get_type(&params);
 
  	memset(zeros, 0, sizeof(zeros));
 
tools/mtk_image.c +1 -1
index 5ef9334163de..0be0e04e7941 100644
@@ -87,7 +87,7 @@ static void crc32_normal_init(uint32_t *crc32c_table, uint32_t poly)
  	}
  }
 
-static int mtk_image_check_image_types(uint8_t type)
+static int mtk_image_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_MTKIMAGE)
  		return EXIT_SUCCESS;
tools/mxsimage.c +1 -1
index fee022aab46b..46081a3a96aa 100644
@@ -2163,7 +2163,7 @@ static void sb_free_image(struct sb_image_ctx *ictx)
  /*
   * MXSSB-MKIMAGE glue code.
   */
-static int mxsimage_check_image_types(uint8_t type)
+static int mxsimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_MXSIMAGE)
  		return EXIT_SUCCESS;
tools/omapimage.c +1 -1
index c59cdcc79b3d..0060daa4e249 100644
@@ -29,7 +29,7 @@ static int do_swap32 = 0;
 
  static uint8_t omapimage_header[OMAP_FILE_HDR_SIZE];
 
-static int omapimage_check_image_types(uint8_t type)
+static int omapimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_OMAPIMAGE)
  		return EXIT_SUCCESS;
tools/pblimage.c +1 -1
index bd639c276f9c..b0f855f9c82b 100644
@@ -218,7 +218,7 @@ void pbl_load_uboot(int ifd, struct image_tool_params *params)
  	}
  }
 
-static int pblimage_check_image_types(uint8_t type)
+static int pblimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_PBLIMAGE)
  		return EXIT_SUCCESS;
tools/rkimage.c +1 -1
index 1c5540b1c3d1..df9e6eadfdc9 100644
@@ -21,7 +21,7 @@ static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
  		rkcommon_rc4_encode_spl(buf, 0, params->file_size);
  }
 
-static int rkimage_check_image_type(uint8_t type)
+static int rkimage_check_image_type(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_RKIMAGE)
  		return EXIT_SUCCESS;
tools/rksd.c +1 -1
index 7d46a1b07b3a..9b36c63dd042 100644
@@ -12,7 +12,7 @@
  #include "mkimage.h"
  #include "rkcommon.h"
 
-static int rksd_check_image_type(uint8_t type)
+static int rksd_check_image_type(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_RKSD)
  		return EXIT_SUCCESS;
tools/rkspi.c +1 -1
index f2530f7bde34..8e71f5877be1 100644
@@ -45,7 +45,7 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd,
  	}
  }
 
-static int rkspi_check_image_type(uint8_t type)
+static int rkspi_check_image_type(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_RKSPI)
  		return EXIT_SUCCESS;
tools/socfpgaimage.c +2 -2
index eba812fec969..a5d11b306376 100644
@@ -358,14 +358,14 @@ static int socfpgaimage_check_params_v1(struct image_tool_params *params)
  		(params->lflag && (params->dflag || params->fflag));
  }
 
-static int socfpgaimage_check_image_types_v0(uint8_t type)
+static int socfpgaimage_check_image_types_v0(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_SOCFPGAIMAGE)
  		return EXIT_SUCCESS;
  	return EXIT_FAILURE;
  }
 
-static int socfpgaimage_check_image_types_v1(uint8_t type)
+static int socfpgaimage_check_image_types_v1(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_SOCFPGAIMAGE_V1)
  		return EXIT_SUCCESS;
tools/stm32image.c +1 -1
index 18357c051822..7bfae93e1074 100644
@@ -70,7 +70,7 @@ static uint32_t stm32image_checksum(void *start, uint32_t len)
  	return csum;
  }
 
-static int stm32image_check_image_types(uint8_t type)
+static int stm32image_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_STM32IMAGE)
  		return EXIT_SUCCESS;
tools/sunxi_egon.c +1 -1
index d45b6f5e4352..7a1a4ce0f96a 100644
@@ -166,7 +166,7 @@ static void egon_set_header(void *buf, struct stat *sbuf, int infd,
  	header->check_sum = cpu_to_le32(checksum);
  }
 
-static int egon_check_image_type(uint8_t type)
+static int egon_check_image_type(uint8_t type, bool legacy)
  {
  	return type == IH_TYPE_SUNXI_EGON ? 0 : 1;
  }
tools/sunxi_toc0.c +1 -1
index 7a8d74bb8e49..1a25ae64d5b7 100644
@@ -883,7 +883,7 @@ err:
  		exit(ret);
  }
 
-static int toc0_check_image_type(uint8_t type)
+static int toc0_check_image_type(uint8_t type, bool legacy)
  {
  	return type == IH_TYPE_SUNXI_TOC0 ? 0 : 1;
  }
tools/ublimage.c +1 -1
index 1d2e897f6b35..0cb443f32874 100644
@@ -183,7 +183,7 @@ static uint32_t parse_cfg_file(struct ubl_header *ublhdr, char *name)
  	return dcd_len;
  }
 
-static int ublimage_check_image_types(uint8_t type)
+static int ublimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_UBLIMAGE)
  		return EXIT_SUCCESS;
tools/vybridimage.c +1 -1
index 94a6684c19b7..a828c7886175 100644
@@ -30,7 +30,7 @@ struct nand_page_0_boot_header {
 
  static struct nand_page_0_boot_header vybridimage_header;
 
-static int vybridimage_check_image_types(uint8_t type)
+static int vybridimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_VYBRIDIMAGE)
  		return EXIT_SUCCESS;
tools/zynqimage.c +1 -1
index d3f418b0612b..95d18ddded9b 100644
@@ -220,7 +220,7 @@ static int zynqimage_check_params(struct image_tool_params *params)
  	return !(params->lflag || params->dflag);
  }
 
-static int zynqimage_check_image_types(uint8_t type)
+static int zynqimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_ZYNQIMAGE)
  		return EXIT_SUCCESS;
tools/zynqmpbif.c +1 -1
index 82ce0ac1a520..747b4349a59e 100644
@@ -102,7 +102,7 @@ static int zynqmpbif_check_params(struct image_tool_params *params)
  	return !(params->lflag || params->dflag);
  }
 
-static int zynqmpbif_check_image_types(uint8_t type)
+static int zynqmpbif_check_image_types(uint8_t type, bool legacy)
  {
  	return (type == IH_TYPE_ZYNQMPBIF) ? EXIT_SUCCESS : EXIT_FAILURE;
  }
tools/zynqmpimage.c +0 -0
index 19b2f02ff150..9c33e17ca11d 100644

tools/zynqmpimage.c static int zynqmpimage_check_params(struct image_tool_params *params) · line 301

Quoted 8 lines
tools/zynqmpimage.c +1 -1
@@ -295,7 +295,7 @@ static int zynqmpimage_check_params(struct image_tool_params *params)
  	return !(params->lflag || params->dflag);
  }
 
-static int zynqmpimage_check_image_types(uint8_t type)
+static int zynqmpimage_check_image_types(uint8_t type, bool legacy)
  {
  	if (type == IH_TYPE_ZYNQMPIMAGE)
  		return EXIT_SUCCESS;

Why not add a new image type IH_TYPE_FLATDT_ANDNOTFIT or whatever?

--Sean

#4 lore raw

PATCH 3/3 tools: mkimage: add cmd-line option '-L' to force legacy images

In reply to Marc Kleine-Budde

If the user select the image type "flat_dt" a FIT image will be build. This breaks the legacy use case of putting a Flat Device Tree into a legacy u-boot image.

Add command line options "-L" and "--legacy" to let the user force the creation of a legacy u-boot image, even if "flat_dt" is selected.

---
 tools/default_image.c | 1 +
 tools/fit_common.c    | 3 +++
 tools/mkimage.c       | 7 ++++++-
 3 files changed, 10 insertions(+), 1 deletion(-)
tools/default_image.c +1 -0
index 9a6b50a946ba..3673eaa63de2 100644
@@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
 static int image_check_image_types(uint8_t type, bool legacy)
 {
 	if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
+	    ((type == IH_TYPE_FLATDT) && legacy) ||
 	    (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
 		return EXIT_SUCCESS;
 	else
tools/fit_common.c +3 -0
index b4aa89b53577..eba13a789a72 100644
@@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,
 
 int fit_check_image_types(uint8_t type, bool legacy)
 {
+	if (legacy)
+		return EXIT_FAILURE;
+
 	if (type == IH_TYPE_FLATDT)
 		return EXIT_SUCCESS;
 	else
tools/mkimage.c +6 -1
index 6d029afab3a8..9e9edd65583e 100644
@@ -91,6 +91,7 @@ static void usage(const char *msg)
 	fprintf(stderr,
 		"       %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n"
 		"          -A ==> set architecture to 'arch'\n"
+		"          -L ==> force legacy image\n"
 		"          -O ==> set operating system to 'os'\n"
 		"          -T ==> set image type to 'type'\n"
 		"          -C ==> set compression type 'comp'\n"
@@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
 }
 
 static const char optstring[] =
-	"a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
+	"a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";
 
 static const struct option longopts[] = {
 	{ "load-address", required_argument, NULL, 'a' },
@@ -181,6 +182,7 @@ static const struct option longopts[] = {
 	{ "key-dir", required_argument, NULL, 'k' },
 	{ "key-dest", required_argument, NULL, 'K' },
 	{ "list", no_argument, NULL, 'l' },
+	{ "legacy", no_argument, NULL, 'L' },
 	{ "config", required_argument, NULL, 'n' },
 	{ "engine", required_argument, NULL, 'N' },
 	{ "algo", required_argument, NULL, 'o' },
@@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
 		case 'l':
 			params.lflag = 1;
 			break;
+		case 'L':
+			params.Lflag = 1;
+			break;
 		case 'n':
 			params.imagename = optarg;
 			break;
Signature · 1 line
2.35.1
#5 lore raw

Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images

Quoted 71 lines · Marc Kleine-Budde

If the user select the image type "flat_dt" a FIT image will be build. This breaks the legacy use case of putting a Flat Device Tree into a legacy u-boot image.

Add command line options "-L" and "--legacy" to let the user force the creation of a legacy u-boot image, even if "flat_dt" is selected.

---
  tools/default_image.c | 1 +
  tools/fit_common.c    | 3 +++
  tools/mkimage.c       | 7 ++++++-
  3 files changed, 10 insertions(+), 1 deletion(-)
tools/default_image.c +1 -0
index 9a6b50a946ba..3673eaa63de2 100644
@@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
  static int image_check_image_types(uint8_t type, bool legacy)
  {
  	if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
+	    ((type == IH_TYPE_FLATDT) && legacy) ||
  	    (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
  		return EXIT_SUCCESS;
  	else
tools/fit_common.c +3 -0
index b4aa89b53577..eba13a789a72 100644
@@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,
 
  int fit_check_image_types(uint8_t type, bool legacy)
  {
+	if (legacy)
+		return EXIT_FAILURE;
+
  	if (type == IH_TYPE_FLATDT)
  		return EXIT_SUCCESS;
  	else
tools/mkimage.c +3 -1
index 6d029afab3a8..9e9edd65583e 100644
@@ -91,6 +91,7 @@ static void usage(const char *msg)
  	fprintf(stderr,
  		"       %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n"
  		"          -A ==> set architecture to 'arch'\n"
+		"          -L ==> force legacy image\n"
  		"          -O ==> set operating system to 'os'\n"
  		"          -T ==> set image type to 'type'\n"
  		"          -C ==> set compression type 'comp'\n"
@@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
  }
 
  static const char optstring[] =
-	"a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
+	"a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";
 
  static const struct option longopts[] = {
  	{ "load-address", required_argument, NULL, 'a' },
@@ -181,6 +182,7 @@ static const struct option longopts[] = {
  	{ "key-dir", required_argument, NULL, 'k' },
  	{ "key-dest", required_argument, NULL, 'K' },
  	{ "list", no_argument, NULL, 'l' },
+	{ "legacy", no_argument, NULL, 'L' },
  	{ "config", required_argument, NULL, 'n' },
  	{ "engine", required_argument, NULL, 'N' },
  	{ "algo", required_argument, NULL, 'o' },

tools/mkimage.c static void process_args(int argc, char **argv) · line 308

Quoted 9 lines
tools/mkimage.c +3 -0
@@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
  		case 'l':
  			params.lflag = 1;
  			break;
+		case 'L':
+			params.Lflag = 1;
+			break;
  		case 'n':
  			params.imagename = optarg;
  			break;

Please add some documentation to the man page (doc/mkimage.1). And also consider not using a short option.

--Sean

#6 lore raw

Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images

Hi,

Quoted 76 lines · Sean Anderson
Quoted 74 lines · Marc Kleine-Budde

If the user select the image type "flat_dt" a FIT image will be build. This breaks the legacy use case of putting a Flat Device Tree into a legacy u-boot image.

Add command line options "-L" and "--legacy" to let the user force the creation of a legacy u-boot image, even if "flat_dt" is selected.

---
  tools/default_image.c | 1 +
  tools/fit_common.c    | 3 +++
  tools/mkimage.c       | 7 ++++++-
  3 files changed, 10 insertions(+), 1 deletion(-)
tools/default_image.c +1 -0
index 9a6b50a946ba..3673eaa63de2 100644
@@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
  static int image_check_image_types(uint8_t type, bool legacy)
  {
      if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
+         ((type == IH_TYPE_FLATDT) && legacy) ||
          (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
              return EXIT_SUCCESS;
      else
tools/fit_common.c +3 -0
index b4aa89b53577..eba13a789a72 100644
@@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,
 
  int fit_check_image_types(uint8_t type, bool legacy)
  {
+     if (legacy)
+             return EXIT_FAILURE;
+
      if (type == IH_TYPE_FLATDT)
              return EXIT_SUCCESS;
      else
tools/mkimage.c +3 -1
index 6d029afab3a8..9e9edd65583e 100644
@@ -91,6 +91,7 @@ static void usage(const char *msg)
      fprintf(stderr,
              "       %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n"
              "          -A ==> set architecture to 'arch'\n"
+             "          -L ==> force legacy image\n"
              "          -O ==> set operating system to 'os'\n"
              "          -T ==> set image type to 'type'\n"
              "          -C ==> set compression type 'comp'\n"
@@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
  }
 
  static const char optstring[] =
-     "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
+     "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";
 
  static const struct option longopts[] = {
      { "load-address", required_argument, NULL, 'a' },
@@ -181,6 +182,7 @@ static const struct option longopts[] = {
      { "key-dir", required_argument, NULL, 'k' },
      { "key-dest", required_argument, NULL, 'K' },
      { "list", no_argument, NULL, 'l' },
+     { "legacy", no_argument, NULL, 'L' },
      { "config", required_argument, NULL, 'n' },
      { "engine", required_argument, NULL, 'N' },
      { "algo", required_argument, NULL, 'o' },
@@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
              case 'l':
                      params.lflag = 1;
                      break;
Quoted 8 lines

tools/mkimage.c static void process_args(int argc, char **argv) · line 308

Quoted 6 lines
tools/mkimage.c +3 -0
+             case 'L':
+                     params.Lflag = 1;
+                     break;
              case 'n':
                      params.imagename = optarg;
                      break;

Please add some documentation to the man page (doc/mkimage.1). And also consider not using a short option.

I like short options :-)

Regards,
Simon

#7 lore raw

Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images

Quoted 88 lines · Simon Glass

Hi,

Quoted 76 lines · Sean Anderson
Quoted 74 lines · Marc Kleine-Budde

If the user select the image type "flat_dt" a FIT image will be build. This breaks the legacy use case of putting a Flat Device Tree into a legacy u-boot image.

Add command line options "-L" and "--legacy" to let the user force the creation of a legacy u-boot image, even if "flat_dt" is selected.

---
   tools/default_image.c | 1 +
   tools/fit_common.c    | 3 +++
   tools/mkimage.c       | 7 ++++++-
   3 files changed, 10 insertions(+), 1 deletion(-)
tools/default_image.c +1 -0
index 9a6b50a946ba..3673eaa63de2 100644
@@ -27,6 +27,7 @@ static struct legacy_img_hdr header;
   static int image_check_image_types(uint8_t type, bool legacy)
   {
       if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) ||
+         ((type == IH_TYPE_FLATDT) && legacy) ||
           (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT))
               return EXIT_SUCCESS;
       else
tools/fit_common.c +3 -0
index b4aa89b53577..eba13a789a72 100644
@@ -43,6 +43,9 @@ int fit_verify_header(unsigned char *ptr, int image_size,
 
   int fit_check_image_types(uint8_t type, bool legacy)
   {
+     if (legacy)
+             return EXIT_FAILURE;
+
       if (type == IH_TYPE_FLATDT)
               return EXIT_SUCCESS;
       else
tools/mkimage.c +3 -1
index 6d029afab3a8..9e9edd65583e 100644
@@ -91,6 +91,7 @@ static void usage(const char *msg)
       fprintf(stderr,
               "       %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n"
               "          -A ==> set architecture to 'arch'\n"
+             "          -L ==> force legacy image\n"
               "          -O ==> set operating system to 'os'\n"
               "          -T ==> set image type to 'type'\n"
               "          -C ==> set compression type 'comp'\n"
@@ -159,7 +160,7 @@ static int add_content(int type, const char *fname)
   }
 
   static const char optstring[] =
-     "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:ln:N:o:O:p:qrR:stT:vVx";
+     "a:A:b:B:c:C:d:D:e:Ef:Fg:G:i:k:K:Lln:N:o:O:p:qrR:stT:vVx";
 
   static const struct option longopts[] = {
       { "load-address", required_argument, NULL, 'a' },
@@ -181,6 +182,7 @@ static const struct option longopts[] = {
       { "key-dir", required_argument, NULL, 'k' },
       { "key-dest", required_argument, NULL, 'K' },
       { "list", no_argument, NULL, 'l' },
+     { "legacy", no_argument, NULL, 'L' },
       { "config", required_argument, NULL, 'n' },
       { "engine", required_argument, NULL, 'N' },
       { "algo", required_argument, NULL, 'o' },
@@ -298,6 +300,9 @@ static void process_args(int argc, char **argv)
               case 'l':
                       params.lflag = 1;
                       break;
Quoted 8 lines

tools/mkimage.c static void process_args(int argc, char **argv) · line 308

Quoted 6 lines
tools/mkimage.c +3 -0
+             case 'L':
+                     params.Lflag = 1;
+                     break;
               case 'n':
                       params.imagename = optarg;
                       break;

Please add some documentation to the man page (doc/mkimage.1). And also consider not using a short option.

Quoted 1 line

I like short options :-)

So do I, but they are a bit of an endangered species for mkimage :)

--Sean