[U-Boot] [PATCH 1/3] tools/mkimage: Assume FDT image type for FIT images

When building a Flattened Image Tree (FIT) the image type needs to be "flat_dt". Commit 89a4d6b12fd6394898b8a454cbabeaf1cd59bae5 introduced a regression which caused the user to need to specify the "-T flat_dt" parameter on the command line when building a FIT image. The "-T flat_dt" parameter should not be needed and is at odds with the current FIT image documentation.
Signed-off-by: Peter Tyser ptyser@xes-inc.com --- Ideally this patch would make it into the upcoming release as its a regression. I don't really care when 2/3 and 3/3 are applied, they aren't really bug fixes.
tools/mkimage.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/tools/mkimage.c b/tools/mkimage.c index ab6ea32..07a9a6f 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -231,6 +231,12 @@ main (int argc, char **argv) usage (); params.datafile = *++argv; params.fflag = 1; + + /* + * The flattened image tree (FIT) format + * requires a flattened device tree image type + */ + params.type = IH_TYPE_FLATDT; goto NXTARG; case 'n': if (--argc <= 0)

The FIT fit_set_header() function was copied from the standard uImage's image_set_header() function during mkimage reorganization. However, the fit_set_header() function is not used since FIT images use a standard device tree blob header.
Signed-off-by: Peter Tyser ptyser@xes-inc.com --- tools/fit_image.c | 34 +--------------------------------- 1 files changed, 1 insertions(+), 33 deletions(-)
diff --git a/tools/fit_image.c b/tools/fit_image.c index d1e612f..ef9ffee 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -155,38 +155,6 @@ static int fit_handle_file (struct mkimage_params *params) return (EXIT_SUCCESS); }
-static void fit_set_header (void *ptr, struct stat *sbuf, int ifd, - struct mkimage_params *params) -{ - uint32_t checksum; - - image_header_t * hdr = (image_header_t *)ptr; - - checksum = crc32 (0, - (const unsigned char *)(ptr + - sizeof(image_header_t)), - sbuf->st_size - sizeof(image_header_t)); - - /* Build new header */ - image_set_magic (hdr, IH_MAGIC); - image_set_time (hdr, sbuf->st_mtime); - image_set_size (hdr, sbuf->st_size - sizeof(image_header_t)); - image_set_load (hdr, params->addr); - image_set_ep (hdr, params->ep); - 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_comp (hdr, params->comp); - - image_set_name (hdr, params->imagename); - - checksum = crc32 (0, (const unsigned char *)hdr, - sizeof(image_header_t)); - - image_set_hcrc (hdr, checksum); -} - static int fit_check_params (struct mkimage_params *params) { return ((params->dflag && (params->fflag || params->lflag)) || @@ -202,7 +170,7 @@ static struct image_type_params fitimage_params = { .print_header = fit_print_contents, .check_image_type = fit_check_image_types, .fflag_handle = fit_handle_file, - .set_header = fit_set_header, + .set_header = NULL, /* FIT images use DTB header */ .check_params = fit_check_params, };

Dear Peter Tyser,
In message 1259102530-32071-2-git-send-email-ptyser@xes-inc.com you wrote:
The FIT fit_set_header() function was copied from the standard uImage's image_set_header() function during mkimage reorganization. However, the fit_set_header() function is not used since FIT images use a standard device tree blob header.
Signed-off-by: Peter Tyser ptyser@xes-inc.com
tools/fit_image.c | 34 +--------------------------------- 1 files changed, 1 insertions(+), 33 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Previously, there was no indication to the user that a FIT image was successfully created after executing mkimage. For example:
$ mkimage -f uImage.its uImage.itb DTC: dts->dtb on file "uImage.its"
Adding some additional output after creating a FIT image lets the user know exactly what is contained in their image, eg:
$ mkimage -f uImage.its uImage.itb DTC: dts->dtb on file "uImage.its" FIT description: Linux kernel 2.6.32-rc7-00201-g7550d6f-dirty Created: Tue Nov 24 15:43:01 2009 Image 0 (kernel@1) Description: Linux Kernel 2.6.32-rc7-00201-g7550d6f-dirty Type: Kernel Image Compression: gzip compressed Data Size: 2707311 Bytes = 2643.86 kB = 2.58 MB Architecture: PowerPC OS: Linux Load Address: 0x00000000 Entry Point: 0x00000000 Hash algo: crc32 Hash value: efe0798b Hash algo: sha1 Hash value: ecafba8c95684f2c8fec67e33c41ec88df1534d7 Image 1 (fdt@1) Description: Flattened Device Tree blob Type: Flat Device Tree Compression: uncompressed Data Size: 12288 Bytes = 12.00 kB = 0.01 MB Architecture: PowerPC Hash algo: crc32 Hash value: a5cab676 Hash algo: sha1 Hash value: 168722b13e305283cfd6603dfe8248cc329adea6 Default Configuration: 'config@1' Configuration 0 (config@1) Description: Default Linux kernel Kernel: kernel@1 FDT: fdt@1
This brings the behavior of creating a FIT image in line with creating a standard uImage, which also prints out the uImage contents after creation.
Signed-off-by: Peter Tyser ptyser@xes-inc.com --- tools/mkimage.c | 51 ++++++++++++++++++++++++++------------------------- 1 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/tools/mkimage.c b/tools/mkimage.c index 07a9a6f..5a82b4e 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -298,23 +298,35 @@ NXTARG: ;
params.imagefile = *argv;
- if (!params.fflag){ - if (params.lflag) { - ifd = open (params.imagefile, O_RDONLY|O_BINARY); - } else { - ifd = open (params.imagefile, - O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); - } + if (params.fflag){ + if (tparams->fflag_handle) + /* + * in some cases, some additional processing needs + * to be done if fflag is defined + * + * For ex. fit_handle_file for Fit file support + */ + retval = tparams->fflag_handle(¶ms);
- if (ifd < 0) { - fprintf (stderr, "%s: Can't open %s: %s\n", - params.cmdname, params.imagefile, - strerror(errno)); - exit (EXIT_FAILURE); - } + if (retval != EXIT_SUCCESS) + exit (retval); + } + + if (params.lflag || params.fflag) { + ifd = open (params.imagefile, O_RDONLY|O_BINARY); + } else { + ifd = open (params.imagefile, + O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); + } + + if (ifd < 0) { + fprintf (stderr, "%s: Can't open %s: %s\n", + params.cmdname, params.imagefile, + strerror(errno)); + exit (EXIT_FAILURE); }
- if (params.lflag) { + if (params.lflag || params.fflag) { /* * list header information of existing image */ @@ -352,17 +364,6 @@ NXTARG: ; (void) close (ifd);
exit (retval); - } else if (params.fflag) { - if (tparams->fflag_handle) - /* - * in some cases, some additional processing needs - * to be done if fflag is defined - * - * For ex. fit_handle_file for Fit file support - */ - retval = tparams->fflag_handle(¶ms); - - exit (retval); }
/*

Dear Peter Tyser,
In message 1259102530-32071-3-git-send-email-ptyser@xes-inc.com you wrote:
Previously, there was no indication to the user that a FIT image was successfully created after executing mkimage. For example:
$ mkimage -f uImage.its uImage.itb DTC: dts->dtb on file "uImage.its"
Adding some additional output after creating a FIT image lets the user know exactly what is contained in their image, eg:
$ mkimage -f uImage.its uImage.itb DTC: dts->dtb on file "uImage.its" FIT description: Linux kernel 2.6.32-rc7-00201-g7550d6f-dirty Created: Tue Nov 24 15:43:01 2009 Image 0 (kernel@1) Description: Linux Kernel 2.6.32-rc7-00201-g7550d6f-dirty Type: Kernel Image Compression: gzip compressed Data Size: 2707311 Bytes = 2643.86 kB = 2.58 MB Architecture: PowerPC OS: Linux Load Address: 0x00000000 Entry Point: 0x00000000 Hash algo: crc32 Hash value: efe0798b Hash algo: sha1 Hash value: ecafba8c95684f2c8fec67e33c41ec88df1534d7 Image 1 (fdt@1) Description: Flattened Device Tree blob Type: Flat Device Tree Compression: uncompressed Data Size: 12288 Bytes = 12.00 kB = 0.01 MB Architecture: PowerPC Hash algo: crc32 Hash value: a5cab676 Hash algo: sha1 Hash value: 168722b13e305283cfd6603dfe8248cc329adea6 Default Configuration: 'config@1' Configuration 0 (config@1) Description: Default Linux kernel Kernel: kernel@1 FDT: fdt@1
This brings the behavior of creating a FIT image in line with creating a standard uImage, which also prints out the uImage contents after creation.
Signed-off-by: Peter Tyser ptyser@xes-inc.com
tools/mkimage.c | 51 ++++++++++++++++++++++++++------------------------- 1 files changed, 26 insertions(+), 25 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Peter Tyser wrote:
When building a Flattened Image Tree (FIT) the image type needs to be "flat_dt". Commit 89a4d6b12fd6394898b8a454cbabeaf1cd59bae5 introduced a regression which caused the user to need to specify the "-T flat_dt" parameter on the command line when building a FIT image. The "-T flat_dt" parameter should not be needed and is at odds with the current FIT image documentation.
I have found that recent commit 6a590c5f5fd12cdd27f3153522acfac3854590e7 has already fix this issue.
Regards, Stefano

Dear Peter Tyser,
In message 1259102530-32071-1-git-send-email-ptyser@xes-inc.com you wrote:
When building a Flattened Image Tree (FIT) the image type needs to be "flat_dt". Commit 89a4d6b12fd6394898b8a454cbabeaf1cd59bae5 introduced a regression which caused the user to need to specify the "-T flat_dt" parameter on the command line when building a FIT image. The "-T flat_dt" parameter should not be needed and is at odds with the current FIT image documentation.
Signed-off-by: Peter Tyser ptyser@xes-inc.com
Ideally this patch would make it into the upcoming release as its a regression. I don't really care when 2/3 and 3/3 are applied, they aren't really bug fixes.
Not really, but a nice cleanup is as good as a fix :-)
tools/mkimage.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

On Sat, 2009-12-05 at 01:13 +0100, Wolfgang Denk wrote:
Dear Peter Tyser,
In message 1259102530-32071-1-git-send-email-ptyser@xes-inc.com you wrote:
When building a Flattened Image Tree (FIT) the image type needs to be "flat_dt". Commit 89a4d6b12fd6394898b8a454cbabeaf1cd59bae5 introduced a regression which caused the user to need to specify the "-T flat_dt" parameter on the command line when building a FIT image. The "-T flat_dt" parameter should not be needed and is at odds with the current FIT image documentation.
Signed-off-by: Peter Tyser ptyser@xes-inc.com
Ideally this patch would make it into the upcoming release as its a regression. I don't really care when 2/3 and 3/3 are applied, they aren't really bug fixes.
Not really, but a nice cleanup is as good as a fix :-)
tools/mkimage.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Hi Wolfgang, Thanks for applying patches 2 and 3. Stefano Babic noticed that this change was already submitted by Remy and was merged in 6a590c5f5fd12cdd27f3153522acfac3854590e7, so 1/3 shouldn't be necessary. My fix was nearly identical to Remy's I'm a bit surprised mine would apply cleanly...
Thanks! Peter

Dear Peter Tyser,
In message 1259972321.23828.13300.camel@localhost.localdomain you wrote:
Thanks for applying patches 2 and 3. Stefano Babic noticed that this change was already submitted by Remy and was merged in 6a590c5f5fd12cdd27f3153522acfac3854590e7, so 1/3 shouldn't be necessary. My fix was nearly identical to Remy's I'm a bit surprised mine would apply cleanly...
Git seems to be clever :-)
Best regards,
Wolfgang Denk
participants (3)
-
Peter Tyser
-
Stefano Babic
-
Wolfgang Denk