* [PATCH 0/3] tools: mkimage: cleanups + allow to create legacy image with type flat_dt
@ 2022-10-31 14:13 Marc Kleine-Budde
2022-10-31 14:13 ` [PATCH 1/3] tools: mkimage: don't print error message "Success" in case of failure Marc Kleine-Budde
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2022-10-31 14:13 UTC (permalink / raw)
To: u-boot; +Cc: embedded
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
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/3] tools: mkimage: don't print error message "Success" in case of failure 2022-10-31 14:13 [PATCH 0/3] tools: mkimage: cleanups + allow to create legacy image with type flat_dt Marc Kleine-Budde @ 2022-10-31 14:13 ` Marc Kleine-Budde 2022-10-31 14:13 ` [PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers Marc Kleine-Budde 2022-10-31 14:13 ` [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images Marc Kleine-Budde 2 siblings, 0 replies; 8+ messages in thread From: Marc Kleine-Budde @ 2022-10-31 14:13 UTC (permalink / raw) To: u-boot; +Cc: embedded, Marc Kleine-Budde 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. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- tools/mkimage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/mkimage.c b/tools/mkimage.c index 30c6df77081f..35a6b1fb799c 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -760,8 +760,8 @@ int main(int argc, char **argv) if (tparams->set_header) tparams->set_header (ptr, &sbuf, ifd, ¶ms); 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); } -- 2.35.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers 2022-10-31 14:13 [PATCH 0/3] tools: mkimage: cleanups + allow to create legacy image with type flat_dt Marc Kleine-Budde 2022-10-31 14:13 ` [PATCH 1/3] tools: mkimage: don't print error message "Success" in case of failure Marc Kleine-Budde @ 2022-10-31 14:13 ` Marc Kleine-Budde 2022-10-31 14:20 ` Sean Anderson 2022-10-31 14:13 ` [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images Marc Kleine-Budde 2 siblings, 1 reply; 8+ messages in thread From: Marc Kleine-Budde @ 2022-10-31 14:13 UTC (permalink / raw) To: u-boot; +Cc: embedded, Marc Kleine-Budde This is a preparation patch to allow legacy images with the IH_TYPE_FLATDT ("flat_dt") image type. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- 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(-) diff --git a/tools/aisimage.c b/tools/aisimage.c index b8b3ee32070f..21e5a8df8aad 100644 --- a/tools/aisimage.c +++ b/tools/aisimage.c @@ -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; diff --git a/tools/atmelimage.c b/tools/atmelimage.c index 7b3b243d58b7..3c084ba8b48d 100644 --- a/tools/atmelimage.c +++ b/tools/atmelimage.c @@ -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; diff --git a/tools/default_image.c b/tools/default_image.c index 4a067e65862e..9a6b50a946ba 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -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)) diff --git a/tools/dumpimage.c b/tools/dumpimage.c index 4791dd0dfe18..3c840985f2fe 100644 --- a/tools/dumpimage.c +++ b/tools/dumpimage.c @@ -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(¶ms); if (!params.lflag && tparams == NULL) { fprintf(stderr, "%s: unsupported type: %s\n", params.cmdname, genimg_get_type_name(params.type)); diff --git a/tools/fit_common.c b/tools/fit_common.c index 01649760ac00..b4aa89b53577 100644 --- a/tools/fit_common.c +++ b/tools/fit_common.c @@ -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; diff --git a/tools/fit_common.h b/tools/fit_common.h index 920a16acfdb2..0fd7a504cf05 100644 --- a/tools/fit_common.h +++ b/tools/fit_common.h @@ -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 diff --git a/tools/gpimage.c b/tools/gpimage.c index 27de4cfaed77..eda2532ac87a 100644 --- a/tools/gpimage.c +++ b/tools/gpimage.c @@ -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; diff --git a/tools/imagetool.c b/tools/imagetool.c index f14ca2fb979f..ff8a293f8a50 100644 --- a/tools/imagetool.c +++ b/tools/imagetool.c @@ -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; } } diff --git a/tools/imagetool.h b/tools/imagetool.h index ca7c2e48ba91..a64780e16d2d 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -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 diff --git a/tools/imx8image.c b/tools/imx8image.c index 01e14869114f..77f8d11f5c85 100644 --- a/tools/imx8image.c +++ b/tools/imx8image.c @@ -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; } diff --git a/tools/imx8mimage.c b/tools/imx8mimage.c index 35d0a92bfdf0..9316445400ed 100644 --- a/tools/imx8mimage.c +++ b/tools/imx8mimage.c @@ -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; } diff --git a/tools/imximage.c b/tools/imximage.c index 5c23fba3b121..92019f520ab5 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -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; diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 6abb9f2d5c01..2a5cf7fec6c4 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -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; diff --git a/tools/lpc32xximage.c b/tools/lpc32xximage.c index 37931f91840c..a995c53ccac9 100644 --- a/tools/lpc32xximage.c +++ b/tools/lpc32xximage.c @@ -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; diff --git a/tools/mkimage.c b/tools/mkimage.c index 35a6b1fb799c..6d029afab3a8 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -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(¶ms); 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(¶ms); memset(zeros, 0, sizeof(zeros)); diff --git a/tools/mtk_image.c b/tools/mtk_image.c index 5ef9334163de..0be0e04e7941 100644 --- a/tools/mtk_image.c +++ b/tools/mtk_image.c @@ -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; diff --git a/tools/mxsimage.c b/tools/mxsimage.c index fee022aab46b..46081a3a96aa 100644 --- a/tools/mxsimage.c +++ b/tools/mxsimage.c @@ -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; diff --git a/tools/omapimage.c b/tools/omapimage.c index c59cdcc79b3d..0060daa4e249 100644 --- a/tools/omapimage.c +++ b/tools/omapimage.c @@ -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; diff --git a/tools/pblimage.c b/tools/pblimage.c index bd639c276f9c..b0f855f9c82b 100644 --- a/tools/pblimage.c +++ b/tools/pblimage.c @@ -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; diff --git a/tools/rkimage.c b/tools/rkimage.c index 1c5540b1c3d1..df9e6eadfdc9 100644 --- a/tools/rkimage.c +++ b/tools/rkimage.c @@ -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; diff --git a/tools/rksd.c b/tools/rksd.c index 7d46a1b07b3a..9b36c63dd042 100644 --- a/tools/rksd.c +++ b/tools/rksd.c @@ -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; diff --git a/tools/rkspi.c b/tools/rkspi.c index f2530f7bde34..8e71f5877be1 100644 --- a/tools/rkspi.c +++ b/tools/rkspi.c @@ -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; diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c index eba812fec969..a5d11b306376 100644 --- a/tools/socfpgaimage.c +++ b/tools/socfpgaimage.c @@ -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; diff --git a/tools/stm32image.c b/tools/stm32image.c index 18357c051822..7bfae93e1074 100644 --- a/tools/stm32image.c +++ b/tools/stm32image.c @@ -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; diff --git a/tools/sunxi_egon.c b/tools/sunxi_egon.c index d45b6f5e4352..7a1a4ce0f96a 100644 --- a/tools/sunxi_egon.c +++ b/tools/sunxi_egon.c @@ -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; } diff --git a/tools/sunxi_toc0.c b/tools/sunxi_toc0.c index 7a8d74bb8e49..1a25ae64d5b7 100644 --- a/tools/sunxi_toc0.c +++ b/tools/sunxi_toc0.c @@ -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; } diff --git a/tools/ublimage.c b/tools/ublimage.c index 1d2e897f6b35..0cb443f32874 100644 --- a/tools/ublimage.c +++ b/tools/ublimage.c @@ -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; diff --git a/tools/vybridimage.c b/tools/vybridimage.c index 94a6684c19b7..a828c7886175 100644 --- a/tools/vybridimage.c +++ b/tools/vybridimage.c @@ -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; diff --git a/tools/zynqimage.c b/tools/zynqimage.c index d3f418b0612b..95d18ddded9b 100644 --- a/tools/zynqimage.c +++ b/tools/zynqimage.c @@ -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; diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c index 82ce0ac1a520..747b4349a59e 100644 --- a/tools/zynqmpbif.c +++ b/tools/zynqmpbif.c @@ -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; } diff --git a/tools/zynqmpimage.c b/tools/zynqmpimage.c index 19b2f02ff150..9c33e17ca11d 100644 --- a/tools/zynqmpimage.c +++ b/tools/zynqmpimage.c @@ -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; -- 2.35.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers 2022-10-31 14:13 ` [PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers Marc Kleine-Budde @ 2022-10-31 14:20 ` Sean Anderson 0 siblings, 0 replies; 8+ messages in thread From: Sean Anderson @ 2022-10-31 14:20 UTC (permalink / raw) To: Marc Kleine-Budde, u-boot; +Cc: embedded On 10/31/22 10:13, Marc Kleine-Budde wrote: > This is a preparation patch to allow legacy images with the > IH_TYPE_FLATDT ("flat_dt") image type. > > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> > --- > 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(-) > > diff --git a/tools/aisimage.c b/tools/aisimage.c > index b8b3ee32070f..21e5a8df8aad 100644 > --- a/tools/aisimage.c > +++ b/tools/aisimage.c > @@ -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; > diff --git a/tools/atmelimage.c b/tools/atmelimage.c > index 7b3b243d58b7..3c084ba8b48d 100644 > --- a/tools/atmelimage.c > +++ b/tools/atmelimage.c > @@ -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; > diff --git a/tools/default_image.c b/tools/default_image.c > index 4a067e65862e..9a6b50a946ba 100644 > --- a/tools/default_image.c > +++ b/tools/default_image.c > @@ -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)) > diff --git a/tools/dumpimage.c b/tools/dumpimage.c > index 4791dd0dfe18..3c840985f2fe 100644 > --- a/tools/dumpimage.c > +++ b/tools/dumpimage.c > @@ -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(¶ms); > if (!params.lflag && tparams == NULL) { > fprintf(stderr, "%s: unsupported type: %s\n", > params.cmdname, genimg_get_type_name(params.type)); > diff --git a/tools/fit_common.c b/tools/fit_common.c > index 01649760ac00..b4aa89b53577 100644 > --- a/tools/fit_common.c > +++ b/tools/fit_common.c > @@ -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; > diff --git a/tools/fit_common.h b/tools/fit_common.h > index 920a16acfdb2..0fd7a504cf05 100644 > --- a/tools/fit_common.h > +++ b/tools/fit_common.h > @@ -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 > diff --git a/tools/gpimage.c b/tools/gpimage.c > index 27de4cfaed77..eda2532ac87a 100644 > --- a/tools/gpimage.c > +++ b/tools/gpimage.c > @@ -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; > diff --git a/tools/imagetool.c b/tools/imagetool.c > index f14ca2fb979f..ff8a293f8a50 100644 > --- a/tools/imagetool.c > +++ b/tools/imagetool.c > @@ -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; > } > } > diff --git a/tools/imagetool.h b/tools/imagetool.h > index ca7c2e48ba91..a64780e16d2d 100644 > --- a/tools/imagetool.h > +++ b/tools/imagetool.h > @@ -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 > diff --git a/tools/imx8image.c b/tools/imx8image.c > index 01e14869114f..77f8d11f5c85 100644 > --- a/tools/imx8image.c > +++ b/tools/imx8image.c > @@ -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; > } > diff --git a/tools/imx8mimage.c b/tools/imx8mimage.c > index 35d0a92bfdf0..9316445400ed 100644 > --- a/tools/imx8mimage.c > +++ b/tools/imx8mimage.c > @@ -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; > } > diff --git a/tools/imximage.c b/tools/imximage.c > index 5c23fba3b121..92019f520ab5 100644 > --- a/tools/imximage.c > +++ b/tools/imximage.c > @@ -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; > diff --git a/tools/kwbimage.c b/tools/kwbimage.c > index 6abb9f2d5c01..2a5cf7fec6c4 100644 > --- a/tools/kwbimage.c > +++ b/tools/kwbimage.c > @@ -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; > diff --git a/tools/lpc32xximage.c b/tools/lpc32xximage.c > index 37931f91840c..a995c53ccac9 100644 > --- a/tools/lpc32xximage.c > +++ b/tools/lpc32xximage.c > @@ -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; > diff --git a/tools/mkimage.c b/tools/mkimage.c > index 35a6b1fb799c..6d029afab3a8 100644 > --- a/tools/mkimage.c > +++ b/tools/mkimage.c > @@ -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(¶ms); > 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(¶ms); > > memset(zeros, 0, sizeof(zeros)); > > diff --git a/tools/mtk_image.c b/tools/mtk_image.c > index 5ef9334163de..0be0e04e7941 100644 > --- a/tools/mtk_image.c > +++ b/tools/mtk_image.c > @@ -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; > diff --git a/tools/mxsimage.c b/tools/mxsimage.c > index fee022aab46b..46081a3a96aa 100644 > --- a/tools/mxsimage.c > +++ b/tools/mxsimage.c > @@ -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; > diff --git a/tools/omapimage.c b/tools/omapimage.c > index c59cdcc79b3d..0060daa4e249 100644 > --- a/tools/omapimage.c > +++ b/tools/omapimage.c > @@ -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; > diff --git a/tools/pblimage.c b/tools/pblimage.c > index bd639c276f9c..b0f855f9c82b 100644 > --- a/tools/pblimage.c > +++ b/tools/pblimage.c > @@ -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; > diff --git a/tools/rkimage.c b/tools/rkimage.c > index 1c5540b1c3d1..df9e6eadfdc9 100644 > --- a/tools/rkimage.c > +++ b/tools/rkimage.c > @@ -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; > diff --git a/tools/rksd.c b/tools/rksd.c > index 7d46a1b07b3a..9b36c63dd042 100644 > --- a/tools/rksd.c > +++ b/tools/rksd.c > @@ -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; > diff --git a/tools/rkspi.c b/tools/rkspi.c > index f2530f7bde34..8e71f5877be1 100644 > --- a/tools/rkspi.c > +++ b/tools/rkspi.c > @@ -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; > diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c > index eba812fec969..a5d11b306376 100644 > --- a/tools/socfpgaimage.c > +++ b/tools/socfpgaimage.c > @@ -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; > diff --git a/tools/stm32image.c b/tools/stm32image.c > index 18357c051822..7bfae93e1074 100644 > --- a/tools/stm32image.c > +++ b/tools/stm32image.c > @@ -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; > diff --git a/tools/sunxi_egon.c b/tools/sunxi_egon.c > index d45b6f5e4352..7a1a4ce0f96a 100644 > --- a/tools/sunxi_egon.c > +++ b/tools/sunxi_egon.c > @@ -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; > } > diff --git a/tools/sunxi_toc0.c b/tools/sunxi_toc0.c > index 7a8d74bb8e49..1a25ae64d5b7 100644 > --- a/tools/sunxi_toc0.c > +++ b/tools/sunxi_toc0.c > @@ -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; > } > diff --git a/tools/ublimage.c b/tools/ublimage.c > index 1d2e897f6b35..0cb443f32874 100644 > --- a/tools/ublimage.c > +++ b/tools/ublimage.c > @@ -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; > diff --git a/tools/vybridimage.c b/tools/vybridimage.c > index 94a6684c19b7..a828c7886175 100644 > --- a/tools/vybridimage.c > +++ b/tools/vybridimage.c > @@ -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; > diff --git a/tools/zynqimage.c b/tools/zynqimage.c > index d3f418b0612b..95d18ddded9b 100644 > --- a/tools/zynqimage.c > +++ b/tools/zynqimage.c > @@ -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; > diff --git a/tools/zynqmpbif.c b/tools/zynqmpbif.c > index 82ce0ac1a520..747b4349a59e 100644 > --- a/tools/zynqmpbif.c > +++ b/tools/zynqmpbif.c > @@ -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; > } > diff --git a/tools/zynqmpimage.c b/tools/zynqmpimage.c > index 19b2f02ff150..9c33e17ca11d 100644 > --- a/tools/zynqmpimage.c > +++ b/tools/zynqmpimage.c > @@ -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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images 2022-10-31 14:13 [PATCH 0/3] tools: mkimage: cleanups + allow to create legacy image with type flat_dt Marc Kleine-Budde 2022-10-31 14:13 ` [PATCH 1/3] tools: mkimage: don't print error message "Success" in case of failure Marc Kleine-Budde 2022-10-31 14:13 ` [PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers Marc Kleine-Budde @ 2022-10-31 14:13 ` Marc Kleine-Budde 2022-10-31 14:21 ` Sean Anderson 2 siblings, 1 reply; 8+ messages in thread From: Marc Kleine-Budde @ 2022-10-31 14:13 UTC (permalink / raw) To: u-boot; +Cc: embedded, 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. Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofgnhm@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- tools/default_image.c | 1 + tools/fit_common.c | 3 +++ tools/mkimage.c | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/default_image.c b/tools/default_image.c index 9a6b50a946ba..3673eaa63de2 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -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 diff --git a/tools/fit_common.c b/tools/fit_common.c index b4aa89b53577..eba13a789a72 100644 --- a/tools/fit_common.c +++ b/tools/fit_common.c @@ -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 diff --git a/tools/mkimage.c b/tools/mkimage.c index 6d029afab3a8..9e9edd65583e 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -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; -- 2.35.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images 2022-10-31 14:13 ` [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images Marc Kleine-Budde @ 2022-10-31 14:21 ` Sean Anderson 2022-10-31 19:27 ` Simon Glass 0 siblings, 1 reply; 8+ messages in thread From: Sean Anderson @ 2022-10-31 14:21 UTC (permalink / raw) To: Marc Kleine-Budde, u-boot; +Cc: embedded On 10/31/22 10:13, Marc Kleine-Budde wrote: > 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. > > Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofgnhm@pengutronix.de > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> > --- > tools/default_image.c | 1 + > tools/fit_common.c | 3 +++ > tools/mkimage.c | 7 ++++++- > 3 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/tools/default_image.c b/tools/default_image.c > index 9a6b50a946ba..3673eaa63de2 100644 > --- a/tools/default_image.c > +++ b/tools/default_image.c > @@ -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 > diff --git a/tools/fit_common.c b/tools/fit_common.c > index b4aa89b53577..eba13a789a72 100644 > --- a/tools/fit_common.c > +++ b/tools/fit_common.c > @@ -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 > diff --git a/tools/mkimage.c b/tools/mkimage.c > index 6d029afab3a8..9e9edd65583e 100644 > --- a/tools/mkimage.c > +++ b/tools/mkimage.c > @@ -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; Please add some documentation to the man page (doc/mkimage.1). And also consider not using a short option. --Sean ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images 2022-10-31 14:21 ` Sean Anderson @ 2022-10-31 19:27 ` Simon Glass 2022-11-01 0:16 ` Sean Anderson 0 siblings, 1 reply; 8+ messages in thread From: Simon Glass @ 2022-10-31 19:27 UTC (permalink / raw) To: Sean Anderson; +Cc: Marc Kleine-Budde, u-boot, embedded Hi, On Mon, 31 Oct 2022 at 08:21, Sean Anderson <seanga2@gmail.com> wrote: > > On 10/31/22 10:13, Marc Kleine-Budde wrote: > > 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. > > > > Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofgnhm@pengutronix.de > > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> > > --- > > tools/default_image.c | 1 + > > tools/fit_common.c | 3 +++ > > tools/mkimage.c | 7 ++++++- > > 3 files changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/tools/default_image.c b/tools/default_image.c > > index 9a6b50a946ba..3673eaa63de2 100644 > > --- a/tools/default_image.c > > +++ b/tools/default_image.c > > @@ -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 > > diff --git a/tools/fit_common.c b/tools/fit_common.c > > index b4aa89b53577..eba13a789a72 100644 > > --- a/tools/fit_common.c > > +++ b/tools/fit_common.c > > @@ -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 > > diff --git a/tools/mkimage.c b/tools/mkimage.c > > index 6d029afab3a8..9e9edd65583e 100644 > > --- a/tools/mkimage.c > > +++ b/tools/mkimage.c > > @@ -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; > > 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images 2022-10-31 19:27 ` Simon Glass @ 2022-11-01 0:16 ` Sean Anderson 0 siblings, 0 replies; 8+ messages in thread From: Sean Anderson @ 2022-11-01 0:16 UTC (permalink / raw) To: Simon Glass; +Cc: Marc Kleine-Budde, u-boot, embedded On 10/31/22 15:27, Simon Glass wrote: > Hi, > > On Mon, 31 Oct 2022 at 08:21, Sean Anderson <seanga2@gmail.com> wrote: >> >> On 10/31/22 10:13, Marc Kleine-Budde wrote: >>> 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. >>> >>> Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofgnhm@pengutronix.de >>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> >>> --- >>> tools/default_image.c | 1 + >>> tools/fit_common.c | 3 +++ >>> tools/mkimage.c | 7 ++++++- >>> 3 files changed, 10 insertions(+), 1 deletion(-) >>> >>> diff --git a/tools/default_image.c b/tools/default_image.c >>> index 9a6b50a946ba..3673eaa63de2 100644 >>> --- a/tools/default_image.c >>> +++ b/tools/default_image.c >>> @@ -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 >>> diff --git a/tools/fit_common.c b/tools/fit_common.c >>> index b4aa89b53577..eba13a789a72 100644 >>> --- a/tools/fit_common.c >>> +++ b/tools/fit_common.c >>> @@ -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 >>> diff --git a/tools/mkimage.c b/tools/mkimage.c >>> index 6d029afab3a8..9e9edd65583e 100644 >>> --- a/tools/mkimage.c >>> +++ b/tools/mkimage.c >>> @@ -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; >> >> Please add some documentation to the man page (doc/mkimage.1). And also consider not using a short option. > > I like short options :-) So do I, but they are a bit of an endangered species for mkimage :) --Sean ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-11-01 0:16 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-10-31 14:13 [PATCH 0/3] tools: mkimage: cleanups + allow to create legacy image with type flat_dt Marc Kleine-Budde 2022-10-31 14:13 ` [PATCH 1/3] tools: mkimage: don't print error message "Success" in case of failure Marc Kleine-Budde 2022-10-31 14:13 ` [PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers Marc Kleine-Budde 2022-10-31 14:20 ` Sean Anderson 2022-10-31 14:13 ` [PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images Marc Kleine-Budde 2022-10-31 14:21 ` Sean Anderson 2022-10-31 19:27 ` Simon Glass 2022-11-01 0:16 ` Sean Anderson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox