tools: mkimage: cleanups + allow to create legacy image with type flat_dt
v2 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 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 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.
--- 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
Re: [PATCH v2 1/2] tools: mkimage: don't print error message "Success" in case of failure
Quoted 9 lines · Marc Kleine-Budde
In case there's no struct
image_type_params::set_headercallback, 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 <[email protected]>--- tools/mkimage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Re: [PATCH v2 1/2] tools: mkimage: don't print error message "Success" in case of failure
Quoted 6 lines · Simon Glass
Quoted 5 lines · Marc Kleine-Budde
In case there's no struct
image_type_params::set_headercallback, no "errno" will be set. Don't fail with an error message, followed by "Success". Remove the printing of the human readable "errno" value.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Marc Kleine-Budde <[email protected]>--- tools/mkimage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Reviewed-by Simon Glass <[email protected]>
Has this patch already been applied?
regards,
Marc
Signature · 4 lines
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-5555 |
Re: [PATCH v2 1/2] tools: mkimage: don't print error message "Success" in case of failure
+Tom Rini
Hi Marc,
Quoted 8 lines · Marc Kleine-Budde
Quoted 6 lines · Simon Glass
Quoted 5 lines · Marc Kleine-Budde
In case there's no struct
image_type_params::set_headercallback, no "errno" will be set. Don't fail with an error message, followed by "Success". Remove the printing of the human readable "errno" value.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Signed-off-by Marc Kleine-Budde <[email protected]>--- tools/mkimage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Reviewed-by Simon Glass <[email protected]>Has this patch already been applied?
No, you can see the status here:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Regards,
SImon
PATCH v2 2/2 tools: mkimage: add new image type "flat_dt_legacy"
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 a new image type "flat_dt_legacy" to build a legacy u-boot image with a "flat_dt" type.
--- boot/image.c | 1 + include/image.h | 1 + tools/default_image.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-)
boot/image.c +1 -0
@@ -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, "", "", }, };
include/image.h +1 -0
@@ -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 */ };
tools/default_image.c +9 -2
@@ -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);
Signature · 1 line
2.35.1
Re: [PATCH v2 2/2] tools: mkimage: add new image type "flat_dt_legacy"
Quoted 9 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 a new image type "
flat_dt_legacy" to build a legacy u-boot image with a "flat_dt" type.
Sean, what about this approach compared to adding the new command line parameter?
Marc
Quoted 78 lines
--- boot/image.c | 1 + include/image.h | 1 + tools/default_image.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-)boot/image.c +1
-0@@ -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, "", "", }, };include/image.h +1
-0@@ -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 */ };tools/default_image.c +9
-2@@ -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);Signature · 1 line
2.35.1
Signature · 4 lines
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-5555 |
Re: [PATCH v2 2/2] tools: mkimage: add new image type "flat_dt_legacy"
Quoted 5 lines · Marc Kleine-Budde
Quoted 4 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.
Quoted 9 lines
Quoted 5 lines
Add a new image type "
flat_dt_legacy" to build a legacy u-boot image with a "flat_dt" type.Sean, what about this approach compared to adding the new command line parameter?
This is good. Maybe we should just name it fdt?
--Sean
Quoted 79 lines
Quoted 78 lines
--- boot/image.c | 1 + include/image.h | 1 + tools/default_image.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-)boot/image.c +1
-0@@ -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, "", "", }, };include/image.h +1
-0@@ -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 */ };tools/default_image.c +9
-2@@ -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);Signature · 1 line
2.35.1
Re: [PATCH v2 2/2] tools: mkimage: add new image type "flat_dt_legacy"
Quoted 9 lines · Sean Anderson
Quoted 8 lines · Marc Kleine-Budde
Quoted 7 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 a new image type "
flat_dt_legacy" to build a legacy u-boot image with a "flat_dt" type.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
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:
Quoted 1 line
{
IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", },
[...]
Quoted 1 line
+ {
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.
Quoted 9 lines
Quoted 9 lines
boot/image.c static const table_entry_t uimage_type[] = { · line 185
Quoted 9 lines
boot/image.c +1
-0@@ -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
Signature · 4 lines
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-5555 |
Re: [PATCH v2 2/2] tools: mkimage: add new image type "flat_dt_legacy"
Quoted 22 lines · Marc Kleine-Budde
Quoted 9 lines · Sean Anderson
Quoted 8 lines · Marc Kleine-Budde
Quoted 7 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 a new image type "
flat_dt_legacy" to build a legacy u-boot image with a "flat_dt" type.Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
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" inboot/image.c, which is the "new" image type:
Quoted 8 lines
Quoted 1 line
{
IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", },[...]
Quoted 1 line
+ {
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.
fdt_legacy?
I just think flat_dt_legacy is quite wordy.
--Sean
Quoted 16 lines
I think "
flat_dt" and "fdt" is just too similar and the user can't see the difference, IMHO.Quoted 9 lines
Quoted 9 lines
boot/image.c static const table_entry_t uimage_type[] = { · line 185
Quoted 9 lines
boot/image.c +1
-0@@ -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