tools: mkimage: cleanups + allow to create legacy image with type flat_dt
Subsystems (7)
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
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
@@ -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 ); }
Signature · 1 line
2.35.1
PATCH 2/3 tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers
In reply to Marc Kleine-BuddeThis 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
@@ -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
@@ -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
@@ -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
@@ -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));
tools/fit_common.c +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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));
tools/mtk_image.c +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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.Signed-off-by Marc Kleine-Budde <[email protected]>--- 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@@ -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@@ -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@@ -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@@ -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));tools/fit_common.c +1
-1@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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));tools/mtk_image.c +1
-1@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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
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
PATCH 3/3 tools: mkimage: add cmd-line option '-L' to force legacy images
In reply to Marc Kleine-BuddeIf 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
@@ -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
@@ -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
@@ -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
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.Signed-off-by Marc Kleine-Budde <[email protected]>--- 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@@ -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@@ -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@@ -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
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.Signed-off-by Marc Kleine-Budde <[email protected]>--- 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@@ -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@@ -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@@ -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
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.Signed-off-by Marc Kleine-Budde <[email protected]>--- 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@@ -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@@ -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@@ -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