[PATCH v3 0/2] 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 other adds support for creating legacy images with type flat_dt. regards, Marc Changes since v2: - renamed new image type to "fdt_legacy" (suggested by Sean Anderson) Changes since v1: - introduce new image type (suggested by Sean Anderson) instead of adding new cmd line parameter
[PATCH v3 2/2] tools: mkimage: add new image type "fdt_legacy"
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 a new image type "fdt_legacy" to build a legacy u-boot image with a "flat_dt" type. Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de Signed-off-by: Marc Kleine-Budde --- boot/image.c | 1 + include/image.h | 1 + tools/default_image.c | 11 +-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/boot/image.c b/boot/image.c index b33d1dfc6b36..958dbf853474 100644 --- a/boot/image.c +++ b/boot/image.c @@ -180,6 +180,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_COPRO, "copro", "Coprocessor Image"}, { IH_TYPE_SUNXI_EGON, "sunxi_egon", "Allwinner eGON Boot Image" }, { IH_TYPE_SUNXI_TOC0, "sunxi_toc0", "Allwinner TOC0 Boot Image" }, + { IH_TYPE_FDT_LEGACY, "fdt_legacy", "legacy Image with Flat Device Tree ", }, { -1, "", "", }, }; diff --git a/include/image.h b/include/image.h index 65d0d4f4387d..601bf85e3dcc 100644 --- a/include/image.h +++ b/include/image.h @@ -229,6 +229,7 @@ enum image_type_t { IH_TYPE_COPRO, /* Coprocessor Image for remoteproc*/ IH_TYPE_SUNXI_EGON, /* Allwinner eGON Boot Image */ IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */ + IH_TYPE_FDT_LEGACY, /* Binary Flat Device Tree Blob in a Legacy Image */ IH_TYPE_COUNT, /* Number of image types */ }; diff --git a/tools/default_image.c b/tools/default_image.c index 4a067e65862e..0ac3382003d5 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -27,7 +27,8 @@ static struct legacy_img_hdr header; static int image_check_image_types(uint8_t type) { if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) || - (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT)) + (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT) || + (type == IH_TYPE_FDT_LEGACY)) return EXIT_SUCCESS; else return EXIT_FAILURE; @@ -94,6 +95,7 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, uint32_t imagesize; uint32_t ep; uint32_t addr; + int type; struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr; checksum = crc32(0, @@ -113,6 +115,11 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, else imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr); + if (params->type == IH_TYPE_FDT_LEGACY) + type = IH_TYPE_FLATDT; + else + type = params->type; + if (params->os == IH_OS_TEE) { addr = optee_image_get_load_addr(hdr); ep = optee_image_get_entry_point(hdr); @@ -127,7 +134,7 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, image_set_dcrc(hdr, checksum); image_set_os(hdr, params->os); image_set_arch(hdr, params->arch); - image_set_type(hdr, params->type); + image_set_type(hdr, type); image_set_comp(hdr, params->comp); image_set_name(hdr, params->imagename); -- 2.35.1
[no subject]
Hello, the first patch cleans up the error message output if struct image_type_params::set_header is set, the other adds support for creating legacy images with type flat_dt. regards, Marc Changes since v2: - renamed new image type to "fdt_legacy" (suggested by Sean Anderson) Changes since v1: - introduce new image type (suggested by Sean Anderson) instead of adding new cmd line parameter
[PATCH v3 1/2] 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. Signed-off-by: Marc Kleine-Budde --- 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, , ifd, ); 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
Re: [PATCH v2 2/2] tools: mkimage: add new image type "flat_dt_legacy"
On 17.11.2022 00:01:19, Sean Anderson wrote: > On 11/16/22 05:49, Marc Kleine-Budde wrote: > > On 31.10.2022 15:51:21, 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 a new image type "flat_dt_legacy" to build a legacy u-boot image > > > with a "flat_dt" type. > > > > > > Link: > > > https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de > > > Signed-off-by: Marc Kleine-Budde > > > > Sean, what about this approach compared to adding the new command line > > parameter? > > > > This is good. Maybe we should just name it fdt? There is already the "flat_dt" in boot/image.c, which is the "new" image type: > { IH_TYPE_FLATDT,"flat_dt","Flat Device Tree", }, [...] >+ { IH_TYPE_FLATDT_LEGACY, "flat_dt_legacy", "Flat Device Tree >legacy Image", }, I need a legacy image, where the type is set to IH_TYPE_FLATDT. Maybe "legacy_flat_dt" or "legacy_fdt" would be an appropriate name, too. As this string is user facing I think it should have "legacy" in it. I think "flat_dt" and "fdt" is just too similar and the user can't see the difference, IMHO. > > > --- a/boot/image.c > > > +++ b/boot/image.c > > > @@ -180,6 +180,7 @@ static const table_entry_t uimage_type[] = { > > > { IH_TYPE_COPRO, "copro", "Coprocessor Image"}, > > > { IH_TYPE_SUNXI_EGON, "sunxi_egon", "Allwinner eGON Boot > > > Image" }, > > > { IH_TYPE_SUNXI_TOC0, "sunxi_toc0", "Allwinner TOC0 Boot > > > Image" }, > > > + { IH_TYPE_FLATDT_LEGACY, "flat_dt_legacy", "Flat Device > > > Tree legacy Image", }, > > > { -1, "", "", > > > }, > > > }; regards, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | signature.asc Description: PGP signature
Re: [PATCH v2 2/2] tools: mkimage: add new image type "flat_dt_legacy"
On 31.10.2022 15:51:21, 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 a new image type "flat_dt_legacy" to build a legacy u-boot image > with a "flat_dt" type. > > Link: > https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de > Signed-off-by: Marc Kleine-Budde Sean, what about this approach compared to adding the new command line parameter? Marc > --- > boot/image.c | 1 + > include/image.h | 1 + > tools/default_image.c | 11 +-- > 3 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/boot/image.c b/boot/image.c > index 9f95b3260a80..9d7e57dee985 100644 > --- a/boot/image.c > +++ b/boot/image.c > @@ -180,6 +180,7 @@ static const table_entry_t uimage_type[] = { > { IH_TYPE_COPRO, "copro", "Coprocessor Image"}, > { IH_TYPE_SUNXI_EGON, "sunxi_egon", "Allwinner eGON Boot Image" > }, > { IH_TYPE_SUNXI_TOC0, "sunxi_toc0", "Allwinner TOC0 Boot Image" > }, > + { IH_TYPE_FLATDT_LEGACY, "flat_dt_legacy", "Flat Device Tree > legacy Image", }, > { -1, "", "", }, > }; > > diff --git a/include/image.h b/include/image.h > index d7d6a3fe5b81..e578e2c5f1fd 100644 > --- a/include/image.h > +++ b/include/image.h > @@ -229,6 +229,7 @@ enum { > IH_TYPE_COPRO, /* Coprocessor Image for remoteproc*/ > IH_TYPE_SUNXI_EGON, /* Allwinner eGON Boot Image */ > IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */ > + IH_TYPE_FLATDT_LEGACY, /* Binary Flat Device Tree Blob in a > legacy image */ > > IH_TYPE_COUNT, /* Number of image types */ > }; > diff --git a/tools/default_image.c b/tools/default_image.c > index 4a067e65862e..3b49f0d70e29 100644 > --- a/tools/default_image.c > +++ b/tools/default_image.c > @@ -27,7 +27,8 @@ static struct legacy_img_hdr header; > static int image_check_image_types(uint8_t type) > { > if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) || > - (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT)) > + (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT) || > + (type == IH_TYPE_FLATDT_LEGACY)) > return EXIT_SUCCESS; > else > return EXIT_FAILURE; > @@ -94,6 +95,7 @@ static void image_set_header(void *ptr, struct stat *sbuf, > int ifd, > uint32_t imagesize; > uint32_t ep; > uint32_t addr; > + int type; > struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr; > > checksum = crc32(0, > @@ -113,6 +115,11 @@ static void image_set_header(void *ptr, struct stat > *sbuf, int ifd, > else > imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr); > > + if (params->type == IH_TYPE_FLATDT_LEGACY) > + type = IH_TYPE_FLATDT; > + else > + type = params->type; > + > if (params->os == IH_OS_TEE) { > addr = optee_image_get_load_addr(hdr); > ep = optee_image_get_entry_point(hdr); > @@ -127,7 +134,7 @@ static void image_set_header(void *ptr, struct stat > *sbuf, int ifd, > image_set_dcrc(hdr, checksum); > image_set_os(hdr, params->os); > image_set_arch(hdr, params->arch); > - image_set_type(hdr, params->type); > + image_set_type(hdr, type); > image_set_comp(hdr, params->comp); > > image_set_name(hdr, params->imagename); > -- > 2.35.1 > > > -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | signature.asc Description: PGP signature
Re: [PATCH v2 1/2] tools: mkimage: don't print error message "Success" in case of failure
On 31.10.2022 13:27:10, Simon Glass wrote: > On Mon, 31 Oct 2022 at 08:51, Marc Kleine-Budde wrote: > > > > 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 > > --- > > tools/mkimage.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > Reviewed-by: Simon Glass Has this patch already been applied? regards, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | signature.asc Description: PGP signature
[PATCH v2 2/2] tools: mkimage: add new image type "flat_dt_legacy"
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 a new image type "flat_dt_legacy" to build a legacy u-boot image with a "flat_dt" type. Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofg...@pengutronix.de Signed-off-by: Marc Kleine-Budde --- boot/image.c | 1 + include/image.h | 1 + tools/default_image.c | 11 +-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/boot/image.c b/boot/image.c index 9f95b3260a80..9d7e57dee985 100644 --- a/boot/image.c +++ b/boot/image.c @@ -180,6 +180,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_COPRO, "copro", "Coprocessor Image"}, { IH_TYPE_SUNXI_EGON, "sunxi_egon", "Allwinner eGON Boot Image" }, { IH_TYPE_SUNXI_TOC0, "sunxi_toc0", "Allwinner TOC0 Boot Image" }, + { IH_TYPE_FLATDT_LEGACY, "flat_dt_legacy", "Flat Device Tree legacy Image", }, { -1, "", "", }, }; diff --git a/include/image.h b/include/image.h index d7d6a3fe5b81..e578e2c5f1fd 100644 --- a/include/image.h +++ b/include/image.h @@ -229,6 +229,7 @@ enum { IH_TYPE_COPRO, /* Coprocessor Image for remoteproc*/ IH_TYPE_SUNXI_EGON, /* Allwinner eGON Boot Image */ IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */ + IH_TYPE_FLATDT_LEGACY, /* Binary Flat Device Tree Blob in a legacy image */ IH_TYPE_COUNT, /* Number of image types */ }; diff --git a/tools/default_image.c b/tools/default_image.c index 4a067e65862e..3b49f0d70e29 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -27,7 +27,8 @@ static struct legacy_img_hdr header; static int image_check_image_types(uint8_t type) { if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) || - (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT)) + (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT) || + (type == IH_TYPE_FLATDT_LEGACY)) return EXIT_SUCCESS; else return EXIT_FAILURE; @@ -94,6 +95,7 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, uint32_t imagesize; uint32_t ep; uint32_t addr; + int type; struct legacy_img_hdr *hdr = (struct legacy_img_hdr *)ptr; checksum = crc32(0, @@ -113,6 +115,11 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, else imagesize = sbuf->st_size - sizeof(struct legacy_img_hdr); + if (params->type == IH_TYPE_FLATDT_LEGACY) + type = IH_TYPE_FLATDT; + else + type = params->type; + if (params->os == IH_OS_TEE) { addr = optee_image_get_load_addr(hdr); ep = optee_image_get_entry_point(hdr); @@ -127,7 +134,7 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, image_set_dcrc(hdr, checksum); image_set_os(hdr, params->os); image_set_arch(hdr, params->arch); - image_set_type(hdr, params->type); + image_set_type(hdr, type); image_set_comp(hdr, params->comp); image_set_name(hdr, params->imagename); -- 2.35.1
[PATCH v2 1/2] 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. Signed-off-by: Marc Kleine-Budde --- 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, , ifd, ); 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
[PATCH v2 0/2] 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 other adds support for creating legacy images with type flat_dt. regards, Marc Changes since v1: - introduce new image type (suggested by Sean Anderson) instead of adding new cmd line parameter
[PATCH 3/3] tools: mkimage: add cmd-line option '-L' to force legacy images
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.ojw6tcso2fofg...@pengutronix.de Signed-off-by: Marc Kleine-Budde --- 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
[PATCH 2/3] tools: mkimage: pass legacy image option to struct image_type_params::check_image_type handlers
This is a preparation patch to allow legacy images with the IH_TYPE_FLATDT ("flat_dt") image type. Signed-off-by: Marc Kleine-Budde --- 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(); 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 -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) { -
[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. Signed-off-by: Marc Kleine-Budde --- 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, , ifd, ); 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
[PATCH 0/3] 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
mkimage regression: legacy images with Image Type IH_TYPE_FLATDT
e wrong? regards, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | signature.asc Description: PGP signature
[PATCH] mkimage: use environment variable MKIMAGE_SIGN_PIN to set pin for OpenSSL Engine
This patch adds the possibility to pass the PIN the OpenSSL Engine used during signing via the environment variable MKIMAGE_SIGN_PIN. This follows the approach used during kernel module signing ("KBUILD_SIGN_PIN") or UBIFS image signing ("MKIMAGE_SIGN_PIN"). Signed-off-by: Marc Kleine-Budde --- doc/uImage.FIT/signature.txt | 4 ++-- lib/rsa/rsa-sign.c | 11 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/uImage.FIT/signature.txt b/doc/uImage.FIT/signature.txt index 7cb1c15e5e15..61a72db3c74f 100644 --- a/doc/uImage.FIT/signature.txt +++ b/doc/uImage.FIT/signature.txt @@ -533,8 +533,8 @@ Generic engine key ids: or "" -As mkimage does not at this time support prompting for passwords HSM may need -key preloading wrapper to be used when invoking mkimage. +In order to set the pin in the HSM, an environment variable "MKIMAGE_SIGN_PIN" +can be specified. The following examples use the Nitrokey Pro using pkcs11 engine. Instructions for other devices may vary. diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index f4ed11e74a4a..49abec6c83fb 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -338,6 +338,7 @@ static int rsa_init(void) static int rsa_engine_init(const char *engine_id, ENGINE **pe) { + const char *key_pass; ENGINE *e; int ret; @@ -362,10 +363,20 @@ static int rsa_engine_init(const char *engine_id, ENGINE **pe) goto err_set_rsa; } + key_pass = getenv("MKIMAGE_SIGN_PIN"); + if (key_pass) { + if (!ENGINE_ctrl_cmd_string(e, "PIN", key_pass, 0)) { + fprintf(stderr, "Couldn't set PIN\n"); + ret = -1; + goto err_set_pin; + } + } + *pe = e; return 0; +err_set_pin: err_set_rsa: ENGINE_finish(e); err_engine_init: -- 2.30.2
[U-Boot] [PATCH 1/2] mxssb: Makefile: build with optimisation (-O2) by default
Signed-off-by: Marc Kleine-Budde m...@pengutronix.de --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a8dbea3a861b..af3deb920785 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS=`pkg-config --cflags libcrypto` -Wall -Wextra +CFLAGS=`pkg-config --cflags libcrypto` -Wall -Wextra -O2 LDFLAGS=`pkg-config --libs libcrypto` mxssb: mxssb.c -- 2.1.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/2] mxssb: fix uninitialized variables warnings
These warning are generated by: gcc version 4.9.1 (Debian 4.9.1-19) mxssb.c: In function ‘main’: mxssb.c:1580:10: warning: ‘ilen’ may be used uninitialized in this function [-Wmaybe-uninitialized] ret = sb_build_dcd_block(ictx, cmd, SB_DCD_CHK_EQ | ilen); ^ mxssb.c:1553:12: note: ‘ilen’ was declared here uint32_t ilen; ^ mxssb.c:1556:28: warning: ‘rptr’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (!tok || (strlen(tok) == 0) || (lptr strlen(lptr) != 1)) { ^ mxssb.c:1495:8: note: ‘rptr’ was declared here char *rptr; ^ Signed-off-by: Marc Kleine-Budde m...@pengutronix.de --- mxssb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mxssb.c b/mxssb.c index 14826e7bf84c..3a4c32cf47c9 100644 --- a/mxssb.c +++ b/mxssb.c @@ -1492,7 +1492,7 @@ static int sb_parse_line(struct sb_image_ctx *ictx, struct sb_cmd_list *cmd) { char *tok; char *line = cmd-cmd; - char *rptr; + char *rptr = NULL; int ret; /* Analyze the identifier on this line first. */ @@ -1550,7 +1550,7 @@ static int sb_parse_line(struct sb_image_ctx *ictx, struct sb_cmd_list *cmd) } } else if (ictx-in_dcd) { char *lptr; - uint32_t ilen; + uint32_t ilen = 0; tok = strtok_r(tok, ., lptr); if (!tok || (strlen(tok) == 0) || (lptr strlen(lptr) != 1)) { -- 2.1.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 0/2] mxssb: trivial fixes
Hey, this is a trivial patch series for the mxssb tool. Please review and apply. regards, Marc ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot