Skip to contentSkip to conversation

tools/mkimage: Assume FDT image type for FIT images

PATCH New Peter Tyser 3 participants 9 messages Nov 24, 2009 – Dec 5, 2009

lore
Share & tools
lore
#0 lore raw

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.

---
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(-)
tools/mkimage.c +6 -0
index ab6ea32..07a9a6f 100644
@@ -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)
Signature · 1 line
1.6.2.1
#1 lore raw

PATCH 2/3 tools/fit_image.c: Remove unused fit_set_header()

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.

---
 tools/fit_image.c |   34 +---------------------------------
 1 files changed, 1 insertions(+), 33 deletions(-)
tools/fit_image.c +1 -33
index d1e612f..ef9ffee 100644
@@ -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,
 };
 
Signature · 1 line
1.6.2.1
#2 lore raw

PATCH 2/3 tools/fit_image.c: Remove unused fit_set_header()

Dear Peter Tyser,

Quoted 9 lines · In message <[email protected]> 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.

---
 tools/fit_image.c |   34 +---------------------------------
 1 files changed, 1 insertions(+), 33 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Those who hate and fight must stop themselves -- otherwise it is  not
stopped.
	-- Spock, "Day of the Dove", stardate unknown
#3 lore raw

PATCH 3/3 tools/mkimage: Print FIT image contents after creation

In reply to Peter Tyser

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 at 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 at 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 at 1'
   Configuration 0 (config at 1)
    Description:  Default Linux kernel
    Kernel:       kernel at 1
    FDT:          fdt at 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.

---
 tools/mkimage.c |   51 ++++++++++++++++++++++++++-------------------------
 1 files changed, 26 insertions(+), 25 deletions(-)
tools/mkimage.c +26 -25
index 07a9a6f..5a82b4e 100644
@@ -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(&params);
 
-		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(&params);
-
-		exit (retval);
 	}
 
 	/*
Signature · 1 line
1.6.2.1
#4 lore raw

PATCH 3/3 tools/mkimage: Print FIT image contents after creation

Dear Peter Tyser,

Quoted 42 lines · In message <[email protected]> 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 at 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 at 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 at 1'
   Configuration 0 (config at 1)
    Description:  Default Linux kernel
    Kernel:       kernel at 1
    FDT:          fdt at 1
Quoted 8 lines

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.

---
 tools/mkimage.c |   51 ++++++++++++++++++++++++++-------------------------
 1 files changed, 26 insertions(+), 25 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Some programming languages manage to  absorb  change,  but  withstand
progress.          -- Epigrams in Programming, ACM SIGPLAN Sept. 1982
#5 lore raw

PATCH 1/3 tools/mkimage: Assume FDT image type for FIT images

In reply to Peter Tyser
Quoted 6 lines · Peter Tyser

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

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#6 lore raw

PATCH 1/3 tools/mkimage: Assume FDT image type for FIT images

In reply to Peter Tyser

Dear Peter Tyser,

Quoted 7 lines · In message <[email protected]> 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.

Quoted 5 lines

---
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 :-)

Quoted 2 lines
 tools/mkimage.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Never underestimate the power of human stupidity  when  it  comes  to
using technology they don't understand.
#7 lore raw

PATCH 1/3 tools/mkimage: Assume FDT image type for FIT images

Quoted 18 lines · Wolfgang Denk

Dear Peter Tyser,

Quoted 7 lines · In message <[email protected]> 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.

Quoted 5 lines

---
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 :-)

Quoted 9 lines
Quoted 2 lines
 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

#8 lore raw

PATCH 1/3 tools/mkimage: Assume FDT image type for FIT images

Dear Peter Tyser,

Quoted 6 lines · In message <[email protected]> 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

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human race has one really effective weapon, and that is laughter.
                                                         - Mark Twain