Skip to contentSkip to conversation

tools: mkimage: hdr_size used to facilitate customized support

PATCH Superseded Prafulla Wadaskar 3 participants 15 messages Jul 18, 2009 – Jul 22, 2009 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 tools: mkimage: hdr_size used to facilitate customized support

hdr_size variable is initialized
at the start of image creation algorithm instead of reading it each time. This facilitate to use the common code for other image type implementations for ex. kwbimage

---
 tools/mkimage.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
tools/mkimage.c +8 -10
index 967fe9a..c5b593c 100644
@@ -250,9 +250,10 @@ NXTARG:		;
 	 *
 	 * write dummy header, to be fixed later
 	 */
-	memset (hdr, 0, image_get_header_size ());
-
-	if (write(ifd, hdr, image_get_header_size ()) != image_get_header_size ()) {
+	int hdr_size;
+	hdr_size = image_get_header_size ();
+	memset (hdr, 0, hdr_size);
+	if (write(ifd, hdr, hdr_size) != hdr_size) {
 		fprintf (stderr, "%s: Write error on %s: %s\n",
 			cmdname, imagefile, strerror(errno));
 		exit (EXIT_FAILURE);
@@ -339,14 +340,12 @@ NXTARG:		;
 	hdr = (image_header_t *)ptr;
 
 	checksum = crc32 (0,
-			  (const char *)(ptr + image_get_header_size ()),
-			  sbuf.st_size - image_get_header_size ()
-			 );
-
+			(const char *)(ptr + hdr_size),
+			sbuf.st_size - hdr_size);
 	/* Build new header */
 	image_set_magic (hdr, IH_MAGIC);
 	image_set_time (hdr, sbuf.st_mtime);
-	image_set_size (hdr, sbuf.st_size - image_get_header_size ());
+	image_set_size (hdr, sbuf.st_size - hdr_size);
 	image_set_load (hdr, addr);
 	image_set_ep (hdr, ep);
 	image_set_dcrc (hdr, checksum);
@@ -354,10 +353,9 @@ NXTARG:		;
 	image_set_arch (hdr, opt_arch);
 	image_set_type (hdr, opt_type);
 	image_set_comp (hdr, opt_comp);
-
 	image_set_name (hdr, name);
 
-	checksum = crc32 (0, (const char *)hdr, image_get_header_size ());
+	checksum = crc32 (0, (const char *)hdr, hdr_size);
 
 	image_set_hcrc (hdr, checksum);
 
Signature · 1 line
1.5.3.4
#1 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

For more details refer docs/README.kwbimage

---
 Makefile            |    5 ++
 common/image.c      |    1 +
 doc/README.kwbimage |   77 ++++++++++++++++++++++
 include/image.h     |    1 +
 tools/Makefile      |    1 +
 tools/kwbimage.c    |  181 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/kwbimage.h    |  105 +++++++++++++++++++++++++++++
 tools/mkimage.c     |   23 ++++++-
 8 files changed, 393 insertions(+), 1 deletions(-)
 create mode 100644 doc/README.kwbimage
 create mode 100644 tools/kwbimage.c
 create mode 100644 tools/kwbimage.h
Makefile +5 -0
index 55fc2a3..b9e45ed 100644
@@ -339,6 +339,10 @@ $(obj)u-boot.img:	$(obj)u-boot.bin
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
 
+$(obj)u-boot.kwb:	$(obj)u-boot.bin
+		./tools/mkimage -n ./board/$(BOARDDIR)/kwbimage.cfg \
+		-T kwbimage -a $(TEXT_BASE) -e $(TEXT_BASE) -d $< $@
+
 $(obj)u-boot.sha1:	$(obj)u-boot.bin
 		$(obj)tools/ubsha1 $(obj)u-boot.bin
 
@@ -3638,6 +3642,7 @@ clobber:	clean
 	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
 		$(obj)cscope.* $(obj)*.*~
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
+	@rm -f $(obj)u-boot.kwb
 	@rm -f $(obj)tools/{env/crc32.c,inca-swap-bytes}
 	@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
 	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
common/image.c +1 -0
index e22c974..845006f 100644
@@ -145,6 +145,7 @@ static table_entry_t uimage_type[] = {
 	{	IH_TYPE_SCRIPT,     "script",	  "Script",		},
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
 	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
+	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
 	{	-1,		    "",		  "",			},
 };
 
doc/README.kwbimage new file +77 -0

77 lines not on this page · raw message

include/image.h +1 -0
index f183757..ed94dda 100644
@@ -158,6 +158,7 @@
 #define IH_TYPE_SCRIPT		6	/* Script file			*/
 #define IH_TYPE_FILESYSTEM	7	/* Filesystem Image (any type)	*/
 #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
+#define IH_TYPE_KWBIMAGE		9	/* Boot Rom Image		*/
 
 /*
  * Compression Types
tools/Makefile +1 -0
index 43c284c..5ead74c 100644
@@ -167,6 +167,7 @@ $(obj)img2srec$(SFX):	$(obj)img2srec.o
 	$(STRIP) $@
 
 $(obj)mkimage$(SFX):	$(obj)mkimage.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
+			$(obj)kwbimage.o \
 			$(obj)sha1.o $(LIBFDT_OBJS) $(obj)os_support.o
 	$(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
 	$(STRIP) $@
tools/kwbimage.c new file +181 -0

181 lines not on this page · raw message

tools/kwbimage.h new file +105 -0

105 lines not on this page · raw message

tools/mkimage.c +22 -1
index c5b593c..9a11071 100644
@@ -24,6 +24,7 @@
 
 #include "mkimage.h"
 #include <image.h>
+#include "kwbimage.h"
 
 extern int errno;
 
@@ -251,7 +252,13 @@ NXTARG:		;
 	 * write dummy header, to be fixed later
 	 */
 	int hdr_size;
-	hdr_size = image_get_header_size ();
+
+	if (opt_type == IH_TYPE_KWBIMAGE) {
+		hdr = kwbimage_get_header_ptr();
+		hdr_size = kwbimage_get_header_size ();
+	} else
+		hdr_size = image_get_header_size ();
+
 	memset (hdr, 0, hdr_size);
 	if (write(ifd, hdr, hdr_size) != hdr_size) {
 		fprintf (stderr, "%s: Write error on %s: %s\n",
@@ -339,6 +346,19 @@ NXTARG:		;
 
 	hdr = (image_header_t *)ptr;
 
+	/* Build new header */
+	if (opt_type == IH_TYPE_KWBIMAGE) {
+		checksum = kwbimage_checksum32((void *)ptr, sbuf.st_size, 0);
+
+		if (write(ifd, &checksum, sizeof(uint32_t))
+					!= sizeof(uint32_t)) {
+			fprintf (stderr, "%s: Checksum wr err on %s: %s\n",
+				cmdname, imagefile, strerror(errno));
+			exit (EXIT_FAILURE);
+		}
+		sbuf.st_size += sizeof(uint32_t);
+		kwbimage_set_header (hdr, &sbuf, addr, ep, name);
+	} else {
 	checksum = crc32 (0,
 			(const char *)(ptr + hdr_size),
 			sbuf.st_size - hdr_size);
@@ -361,6 +381,7 @@ NXTARG:		;
 
 	image_print_contents (hdr);
 
+	}
 	(void) munmap((void *)ptr, sbuf.st_size);
 
 	/* We're a bit of paranoid */
Signature · 1 line
1.5.3.4
#2 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

Quoted 22 lines · Prafulla Wadaskar

For more details refer docs/README.kwbimage

---
 Makefile            |    5 ++
 common/image.c      |    1 +
 doc/README.kwbimage |   77 ++++++++++++++++++++++
 include/image.h     |    1 +
 tools/Makefile      |    1 +
 tools/kwbimage.c    |  181 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/kwbimage.h    |  105 +++++++++++++++++++++++++++++
 tools/mkimage.c     |   23 ++++++-
 8 files changed, 393 insertions(+), 1 deletions(-)
 create mode 100644 doc/README.kwbimage
 create mode 100644 tools/kwbimage.c
 create mode 100644 tools/kwbimage.h
Makefile +0 -0
index 55fc2a3..b9e45ed 100644

Makefile $(obj)u-boot.img: $(obj)u-boot.bin · line 344

Quoted 6 lines
Makefile +3 -0
@@ -339,6 +339,10 @@ $(obj)u-boot.img:	$(obj)u-boot.bin
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
 
+$(obj)u-boot.kwb:	$(obj)u-boot.bin
+		./tools/mkimage -n ./board/$(BOARDDIR)/kwbimage.cfg \
+		-T kwbimage -a $(TEXT_BASE) -e $(TEXT_BASE) -d $< $@

It will be better to make it a few more generic (and btw fix the out of tree support) as this
MKIMAGE = $(OBJTREE)/tools/mkimage

$(obj)u-boot.kwb: $(obj)u-boot.bin

		$(MKIMAGE) -n $(KWD_CONFIG) -T kwbimage -a $(TEXT_BASE) \
		-e $(TEXT_BASE) -d $< $@

and in the board config.mk or soc anyother config.mk KWD_CONFIG = $(SRCTREE)/board/$(BOARDDIR)/kwbimage.cfg

Best Regards,
J.

#3 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

________________________________________
From: Jean-Christophe PLAGNIOL-VILLARD [plagnioj at jcrosoft.com]
Sent: Sunday, July 19, 2009 2:55 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Manas Saksena; Ronen Shitrit; Nicolas Pitre; Ashish Karkare; Prabhanjan Sarnaik; Lennert Buijtenhek
Subject: Re: [U-Boot] [PATCH 2/3] tools: mkimage (type=kwbimage) kirkwood boot image support

Quoted 22 lines · Prafulla Wadaskar

For more details refer docs/README.kwbimage

---
 Makefile            |    5 ++
 common/image.c      |    1 +
 doc/README.kwbimage |   77 ++++++++++++++++++++++
 include/image.h     |    1 +
 tools/Makefile      |    1 +
 tools/kwbimage.c    |  181 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/kwbimage.h    |  105 +++++++++++++++++++++++++++++
 tools/mkimage.c     |   23 ++++++-
 8 files changed, 393 insertions(+), 1 deletions(-)
 create mode 100644 doc/README.kwbimage
 create mode 100644 tools/kwbimage.c
 create mode 100644 tools/kwbimage.h
Makefile +0 -0
index 55fc2a3..b9e45ed 100644

Makefile $(obj)u-boot.img: $(obj)u-boot.bin · line 344

Quoted 6 lines
Makefile +3 -0
@@ -339,6 +339,10 @@ $(obj)u-boot.img:        $(obj)u-boot.bin
                      sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
              -d $< $@
 
+$(obj)u-boot.kwb:    $(obj)u-boot.bin
+             ./tools/mkimage -n ./board/$(BOARDDIR)/kwbimage.cfg \
+             -T kwbimage -a $(TEXT_BASE) -e $(TEXT_BASE) -d $< $@

It will be better to make it a few more generic (and btw fix the out of tree support) as this
MKIMAGE = $(OBJTREE)/tools/mkimage
[prafulla] this is generic change and should be done for other mkimage references too. for kwbimage patch I am skipping this, I will issue separate patch for this.

$(obj)u-boot.kwb: $(obj)u-boot.bin

                $(MKIMAGE) -n $(KWD_CONFIG) -T kwbimage -a $(TEXT_BASE) \
                -e $(TEXT_BASE) -d $< $@

[prafulla] done..

and in the board config.mk or soc anyother config.mk
KWD_CONFIG = $(SRCTREE)/board/$(BOARDDIR)/kwbimage.cfg
[prafulla] done in board config.mk,
thanks for this suggestion, this will add more flexibility to share kwbimage config file for multiple boards

Regards..
Prafulla . .

#4 lore raw

PATCH 3/3 Kirkwood: Sheevaplug: kwimage configuration

In reply to Prafulla Wadaskar
---
 board/Marvell/sheevaplug/kwbimage.cfg |   61 +++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/sheevaplug/kwbimage.cfg
board/Marvell/sheevaplug/kwbimage.cfg new file +61 -0
new file mode 100644
index 0000000..874dcd2
@@ -0,0 +1,61 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Written-by: Prafulla Wadaskar <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+# Refer docs/README.kwimage for more details about how-to configure
+# and create kirkwood boot image
+#
+
+# Boot Media configurations
+BOOT_FROM	nand
+NAND_ECC_MODE	default
+NAND_PAGE_SIZE	0x0800
+
+# SOC registers configuration for initial values using bootrom header extension
+# Maximum KWBIMAGE_MAX_CONFIG configurations allowed
+
+# Configure RGMII-0 interface pad voltage to 1.8V
+0xFFD100e0 0x1b1b1b9b
+# DRAM Configuration
+0xFFD01400 0x43000c30
+0xFFD01404 0x37543000
+0xFFD01408 0x22125451
+0xFFD0140C 0x00000a33
+0xFFD01410 0x000000cc
+0xFFD01414 0x00000000
+0xFFD01418 0x00000000
+0xFFD0141C 0x00000C52
+0xFFD01420 0x00000040
+0xFFD01424 0x0000F17F
+0xFFD01428 0x00085520
+0xFFD0147C 0x00008552
+0xFFD01504 0x0FFFFFF1
+0xFFD01508 0x10000000
+0xFFD0150C 0x0FFFFFF5
+0xFFD01514 0x00000000
+0xFFD0151C 0x00000000
+0xFFD01494 0x00030000
+0xFFD01498 0x00000000
+0xFFD0149C 0x0000E803
+0xFFD01480 0x00000001
+# End of Header extension
+0x0 0x0
Signature · 1 line
1.5.3.4
#5 lore raw

PATCH 3/3 Kirkwood: Sheevaplug: kwimage configuration

board/Marvell/sheevaplug/kwbimage.cfg line 39

Quoted 13 lines
board/Marvell/sheevaplug/kwbimage.cfg new file +13 -0
+
+# Boot Media configurations
+BOOT_FROM	nand
+NAND_ECC_MODE	default
+NAND_PAGE_SIZE	0x0800
+
+# SOC registers configuration for initial values using bootrom header extension
+# Maximum KWBIMAGE_MAX_CONFIG configurations allowed
+
+# Configure RGMII-0 interface pad voltage to 1.8V
+0xFFD100e0 0x1b1b1b9b
+# DRAM Configuration
+0xFFD01400 0x43000c30

could you give more details about the configs

Best Regards,
J.

#6 lore raw

PATCH 3/3 Kirkwood: Sheevaplug: kwimage configuration

Quoted 19 lines

-----Original Message-----
From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
Sent: Sunday, July 19, 2009 2:56 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Manas Saksena; Ronen Shitrit; Nicolas Pitre; Ashish Karkare; Prabhanjan Sarnaik; Lennert Buijtenhek
Subject: Re: [U-Boot] [PATCH 3/3] Kirkwood: Sheevaplug:
kwimage configuration

board/Marvell/sheevaplug/kwbimage.cfg

Quoted 7 lines
board/Marvell/sheevaplug/kwbimage.cfg new file +7 -0
+
+# Boot Media configurations
+BOOT_FROM	nand
+NAND_ECC_MODE	default
+NAND_PAGE_SIZE	0x0800
+
+# SOC registers configuration for initial values using 

bootrom header

Quoted 5 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+extension # Maximum KWBIMAGE_MAX_CONFIG configurations allowed
+
+# Configure RGMII-0 interface pad voltage to 1.8V 0xFFD100e0 
+0x1b1b1b9b # DRAM Configuration 0xFFD01400 0x43000c30

could you give more details about the configs

Dear Jean
I will add details for each configuration

Regards..
Prafulla . .

Quoted 4 lines

Best Regards,
J.

#7 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

In reply to Prafulla Wadaskar

Dear Prafulla Wadaskar,

Quoted 1 line · In message <[email protected]> you wrote:

For more details refer docs/README.kwbimage

...

Quoted 18 lines
doc/README.kwbimage new file +12 -0
new file mode 100644
index 0000000..b00a053
@@ -0,0 +1,77 @@
+---------------------------------------------
+Kirkwood Boot Image generation using mkimage
+---------------------------------------------
+
+This document describes the U-Boot feature as it
+is implemented for the Kirkwood family of SoCs.
+
+The Kirkwood SoC's can boot directly from NAND FLASH,
+SPI FLASH, SATA etc. using its internal bootRom support.
+
+for more details refer section 24.2 of Kirkwood functional specifications.
+ref: www.marvell.com/products/embedded.../kirkwood/index.jsp

doc/README.kwbimage line 22

Quoted 10 lines
doc/README.kwbimage new file +10 -0
+
+Commad syntax:
+./tools/mkimage -n <board specific configuration file> \
+                -T kwbimage -a <start address> -e <execution address> -d <input_raw_binary> <output_kwboot_file>
+
+for ex.
+./tools/mkimage -n ./board/Marvell/openrd_base/kwbimage.cfg \
+                -T kwbimage -a 0x00600000 -e 0x00600000 -d u-boot.bin u-boot.kwb
+
+kwimage support available with mkimage utility will generate kirkwood boot image that can be flashed on the board nand/spi flash

Maximum line length exceeded. Please fix globally.

...

doc/README.kwbimage line 77

Quoted 3 lines
doc/README.kwbimage new file +3 -0
+Author: Prafulla Wadaskar <[email protected]>
+------------------------------------------------------
+

Please do not add trailing empty lines.

include/image.h line 161

Quoted 9 lines
include/image.h +1 -0
index f183757..ed94dda 100644
@@ -158,6 +158,7 @@
 #define IH_TYPE_SCRIPT		6	/* Script file			*/
 #define IH_TYPE_FILESYSTEM	7	/* Filesystem Image (any type)	*/
 #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
+#define IH_TYPE_KWBIMAGE		9	/* Boot Rom Image		*/

Please s/Boot Rom Image/Kirkwood Boot Rom Image/ or similar.

Quoted 11 lines
tools/kwbimage.c new file +5 -0
new file mode 100644
index 0000000..06f256e
...
+/*
+ * Generates 32 bit checksum
+ */
+u32 kwbimage_checksum32(void *start, u32 len, u32 csum)
+{

tools/kwbimage.c line 66

Quoted 10 lines
tools/kwbimage.c new file +10 -0
+	register u32 sum = csum;
+	volatile u32 *startp = (volatile u32 *)start;
+
+	do {
+		sum += *startp;
+		startp++;
+		len -= sizeof(u32);
+	} while (len > 0);
+	return (sum);
+}

This will fail if start is not 32bit aligned; if you can guarantee that it is always aligned, then please pass a u32 pointer.

Quoted 10 lines
tools/kwbimage.c new file +10 -0
+void kwdimage_set_ext_header(struct kwb_header *kwbhdr, char* fname) {
+	bhr_t *mhdr = &kwbhdr->kwb_hdr;
+	extbhr_t *exthdr = &kwbhdr->kwb_exthdr;
+	int fd = -1;
+	int lineno, i;
+	char *line = NULL;
+	char cmdstr[MAX_KWBCMD_LEN], datastr[MAX_KWBDATA_LEN];
+	size_t len = 0;
+
+	exthdr->dramregsoffs = (u32)&exthdr->rcfg - (u32)mhdr;

tools/kwbimage.c line 97

Quoted 10 lines
tools/kwbimage.c new file +10 -0
+
+	if ((fd = fopen(fname, "r")) == 0) {
+		fprintf (stderr, "Err: Can't open %s: %s\n",
+			fname, strerror(errno));
+		exit (EXIT_FAILURE);
+	}
+
+	i = lineno = 0;
+	while ((getline(&line, &len, fd)) != -1) {
+		/* skip empty lines and lines staring with # */

s/staring/starting/

tools/kwbimage.c line 100

Quoted 3 lines
tools/kwbimage.c new file +3 -0
+		lineno++;
+		if (!(line[0] != '#' && strlen(line) != 1))
+			continue;

This is a bit simple-minded. This will for example fail on DOS-formatted files, and for lines that contain only white space (which still look "empty" to most users and are thus hard to spot).

tools/kwbimage.c line 103

Quoted 2 lines
tools/kwbimage.c new file +2 -0
+		if (strlen(line) > (MAX_KWBCMD_LEN + MAX_KWBDATA_LEN)) {
+			printf("Err.. %s(line no %d) too long\n",

"Error: %s[%d] Line too long\n" ?

Quoted 8 lines
tools/kwbimage.h new file +2 -0
new file mode 100644
index 0000000..c54b701
...
+/* typedefs */
+typedef char s8;

tools/kwbimage.h line 58

Quoted 10 lines
tools/kwbimage.h new file +10 -0
+typedef unsigned char u8;
+
+typedef int s32;
+typedef unsigned int u32;
+
+typedef short s16;
+typedef unsigned short u16;
+
+typedef long s64;
+typedef unsigned long u64;

Please get rid of these.

Quoted 48 lines
tools/mkimage.c +21 -1
index c5b593c..9a11071 100644
@@ -24,6 +24,7 @@
 
 #include "mkimage.h"
 #include <image.h>
+#include "kwbimage.h"
 
 extern int errno;
 
@@ -251,7 +252,13 @@ NXTARG:		;
 	 * write dummy header, to be fixed later
 	 */
 	int hdr_size;
-	hdr_size = image_get_header_size ();
+
+	if (opt_type == IH_TYPE_KWBIMAGE) {
+		hdr = kwbimage_get_header_ptr();
+		hdr_size = kwbimage_get_header_size ();
+	} else
+		hdr_size = image_get_header_size ();
+
 	memset (hdr, 0, hdr_size);
 	if (write(ifd, hdr, hdr_size) != hdr_size) {
 		fprintf (stderr, "%s: Write error on %s: %s\n",
@@ -339,6 +346,19 @@ NXTARG:		;
 
 	hdr = (image_header_t *)ptr;
 
+	/* Build new header */
+	if (opt_type == IH_TYPE_KWBIMAGE) {
+		checksum = kwbimage_checksum32((void *)ptr, sbuf.st_size, 0);
+
+		if (write(ifd, &checksum, sizeof(uint32_t))
+					!= sizeof(uint32_t)) {
+			fprintf (stderr, "%s: Checksum wr err on %s: %s\n",
+				cmdname, imagefile, strerror(errno));
+			exit (EXIT_FAILURE);
+		}
+		sbuf.st_size += sizeof(uint32_t);
+		kwbimage_set_header (hdr, &sbuf, addr, ep, name);
+	} else {
 	checksum = crc32 (0,
 			(const char *)(ptr + hdr_size),
 			sbuf.st_size - hdr_size);

tools/mkimage.c NXTARG: ; · line 387

Quoted 7 lines
tools/mkimage.c +1 -0
@@ -361,6 +381,7 @@ NXTARG:		;
 
 	image_print_contents (hdr);
 
+	}
 	(void) munmap((void *)ptr, sbuf.st_size);
 
 	/* We're a bit of paranoid */

Hmm... it seems you add only image creation code. But "mkimage -l" should work on such an image, too. And "imls" in U-Boot should be working, too.

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
"Plan to throw one away. You will anyway."
                              - Fred Brooks, "The Mythical Man Month"
#8 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

Dear Wolfgang
Thanks for your quick feedback

Quoted 48 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Sunday, July 19, 2009 3:33 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Manas Saksena; Ronen Shitrit; Nicolas Pitre; Ashish Karkare; Prabhanjan Sarnaik; Lennert Buijtenhek
Subject: Re: [U-Boot] [PATCH 2/3] tools: mkimage (type=kwbimage) kirkwood boot image support

Dear Prafulla Wadaskar,

In message

Quoted 1 line · <[email protected]> you wrote:

For more details refer docs/README.kwbimage

...

doc/README.kwbimage new

Quoted 1 line
doc/README.kwbimage new renamed from doc/README.kwbimage +0 -0

file mode

doc/README.kwbimage line 5

Quoted 9 lines

100644 index 0000000..b00a053

doc/README.kwbimage new file +5 -0
@@ -0,0 +1,77 @@
+---------------------------------------------
+Kirkwood Boot Image generation using mkimage
+---------------------------------------------
+
+This document describes the U-Boot feature as it is 

implemented for

doc/README.kwbimage line 8

Quoted 3 lines
doc/README.kwbimage new file +3 -0
+the Kirkwood family of SoCs.
+
+The Kirkwood SoC's can boot directly from NAND FLASH, SPI 

FLASH, SATA

doc/README.kwbimage line 11

Quoted 3 lines
doc/README.kwbimage new file +3 -0
+etc. using its internal bootRom support.
+
+for more details refer section 24.2 of Kirkwood functional 

specifications.

doc/README.kwbimage

Quoted 5 lines
doc/README.kwbimage new file +5 -0
+ref: www.marvell.com/products/embedded.../kirkwood/index.jsp
+
+Commad syntax:
+./tools/mkimage -n <board specific configuration file> \
+                -T kwbimage -a <start address> -e 

<execution address>

doc/README.kwbimage

Quoted 5 lines
doc/README.kwbimage new file +5 -0
+-d <input_raw_binary> <output_kwboot_file>
+
+for ex.
+./tools/mkimage -n ./board/Marvell/openrd_base/kwbimage.cfg \
+                -T kwbimage -a 0x00600000 -e 0x00600000 -d 

u-boot.bin

Quoted 8 lines

doc/README.kwbimage line 24

Quoted 3 lines
doc/README.kwbimage new file +3 -0
+u-boot.kwb
+
+kwimage support available with mkimage utility will 

generate kirkwood

doc/README.kwbimage line 25

Quoted 1 line
doc/README.kwbimage new file +1 -0
+boot image that can be flashed on the board nand/spi flash

Maximum line length exceeded. Please fix globally.

Okay I will correct them

Quoted 8 lines

...

doc/README.kwbimage line 77

Quoted 3 lines
doc/README.kwbimage new file +3 -0
+Author: Prafulla Wadaskar <[email protected]>
+------------------------------------------------------
+

Please do not add trailing empty lines.

Okay

Quoted 9 lines

include/image.h index

Quoted 2 lines
include/image.h index renamed from include/image.h +0 -0

f183757..ed94dda

include/image.h line 158

Quoted 5 lines

100644

include/image.h +0 -0
@@ -158,6 +158,7 @@
 #define IH_TYPE_SCRIPT		6	/* Script file	
		*/
Quoted 8 lines

include/image.h line 159

Quoted 1 line
include/image.h +0 -0
 #define IH_TYPE_FILESYSTEM	7	/* Filesystem Image 

(any type) */

include/image.h line 160

Quoted 1 line
include/image.h +0 -0
 #define IH_TYPE_FLATDT		8	/* Binary Flat 

Device Tree Blob */

include/image.h line 161

Quoted 1 line
include/image.h +1 -0
+#define IH_TYPE_KWBIMAGE		9	/* Boot Rom 

Image */

Please s/Boot Rom Image/Kirkwood Boot Rom Image/ or similar.

Okay

Quoted 16 lines

tools/kwbimage.c new file

Quoted 2 lines
tools/kwbimage.c new file renamed from tools/kwbimage.c +0 -0

mode 100644

Quoted 13 lines

index 0000000..06f256e

tools/kwbimage.c new file +9 -0
...
+/*
+ * Generates 32 bit checksum
+ */
+u32 kwbimage_checksum32(void *start, u32 len, u32 csum) {
+	register u32 sum = csum;
+	volatile u32 *startp = (volatile u32 *)start;
+
+	do {
+		sum += *startp;
Quoted 8 lines

tools/kwbimage.c line 66

Quoted 5 lines
tools/kwbimage.c new file +5 -0
+		startp++;
+		len -= sizeof(u32);
+	} while (len > 0);
+	return (sum);
+}

This will fail if start is not 32bit aligned; if you can guarantee that it is always aligned, then please pass a u32 pointer.

Yes the pointer is char *, I will add check for 32bit alligned ptr and use of temp buffer to correct this

Quoted 16 lines
Quoted 2 lines

+void kwdimage_set_ext_header(struct kwb_header *kwbhdr,

char* fname) {

Quoted 13 lines
tools/kwbimage.c new file +13 -0
+	bhr_t *mhdr = &kwbhdr->kwb_hdr;
+	extbhr_t *exthdr = &kwbhdr->kwb_exthdr;
+	int fd = -1;
+	int lineno, i;
+	char *line = NULL;
+	char cmdstr[MAX_KWBCMD_LEN], datastr[MAX_KWBDATA_LEN];
+	size_t len = 0;
+
+	exthdr->dramregsoffs = (u32)&exthdr->rcfg - (u32)mhdr;
+
+	if ((fd = fopen(fname, "r")) == 0) {
+		fprintf (stderr, "Err: Can't open %s: %s\n",
+			fname, strerror(errno));
Quoted 8 lines

tools/kwbimage.c line 97

Quoted 6 lines
tools/kwbimage.c new file +6 -0
+		exit (EXIT_FAILURE);
+	}
+
+	i = lineno = 0;
+	while ((getline(&line, &len, fd)) != -1) {
+		/* skip empty lines and lines staring with # */

s/staring/starting/

Okay

Quoted 9 lines

tools/kwbimage.c line 100

Quoted 4 lines
tools/kwbimage.c new file +3 -0
+		lineno++;
+		if (!(line[0] != '#' && strlen(line) != 1))
+			continue;

This is a bit simple-minded. This will for example fail on DOS-formatted files, and for lines that contain only white space (which still look "empty" to most users and are thus hard to spot).

To take care of Dos formatted file I should use "strlen(line) <= 1" right As explained in doc.README.kwimage,
any other line apart from above will be considered as valid configuration line. This is bare minimal parsing provided here which is sufficient

Quoted 5 lines

tools/kwbimage.c line 103

Quoted 3 lines
tools/kwbimage.c new file +2 -0
+		if (strlen(line) > (MAX_KWBCMD_LEN + MAX_KWBDATA_LEN)) {
+			printf("Err.. %s(line no %d) too long\n",

"Error: %s[%d] Line too long\n" ?

Good one.. I will update this

Quoted 13 lines

tools/kwbimage.h new file

Quoted 2 lines
tools/kwbimage.h new file renamed from tools/kwbimage.h +0 -0

mode 100644

Quoted 10 lines

index 0000000..c54b701

tools/kwbimage.h new file +6 -0
...
+/* typedefs */
+typedef char s8;
+typedef unsigned char u8;
+
+typedef int s32;
+typedef unsigned int u32;
Quoted 8 lines

tools/kwbimage.h line 58

Quoted 6 lines
tools/kwbimage.h new file +6 -0
+
+typedef short s16;
+typedef unsigned short u16;
+
+typedef long s64;
+typedef unsigned long u64;

Please get rid of these.

Okay

Quoted 55 lines

tools/mkimage.c index

Quoted 2 lines
tools/mkimage.c index renamed from tools/mkimage.c +0 -0

c5b593c..9a11071

Quoted 27 lines

100644

tools/mkimage.c +8 -1
@@ -24,6 +24,7 @@
 
 #include "mkimage.h"
 #include <image.h>
+#include "kwbimage.h"
 
 extern int errno;
 
@@ -251,7 +252,13 @@ NXTARG:		;
 	 * write dummy header, to be fixed later
 	 */
 	int hdr_size;
-	hdr_size = image_get_header_size ();
+
+	if (opt_type == IH_TYPE_KWBIMAGE) {
+		hdr = kwbimage_get_header_ptr();
+		hdr_size = kwbimage_get_header_size ();
+	} else
+		hdr_size = image_get_header_size ();
+
 	memset (hdr, 0, hdr_size);
 	if (write(ifd, hdr, hdr_size) != hdr_size) {
 		fprintf (stderr, "%s: Write error on %s: %s\n",

tools/mkimage.c NXTARG: ; · line 351

Quoted 6 lines
tools/mkimage.c +3 -0
@@ -339,6 +346,19 @@ NXTARG:		;
 
 	hdr = (image_header_t *)ptr;
 
+	/* Build new header */
+	if (opt_type == IH_TYPE_KWBIMAGE) {
+		checksum = kwbimage_checksum32((void *)ptr, 

sbuf.st_size, 0);

tools/mkimage.c NXTARG: ;

Quoted 4 lines
tools/mkimage.c +4 -0
+
+		if (write(ifd, &checksum, sizeof(uint32_t))
+					!= sizeof(uint32_t)) {
+			fprintf (stderr, "%s: Checksum wr err 

on %s: %s\n",

Quoted 13 lines
tools/mkimage.c +6 -0
+				cmdname, imagefile, strerror(errno));
+			exit (EXIT_FAILURE);
+		}
+		sbuf.st_size += sizeof(uint32_t);
+		kwbimage_set_header (hdr, &sbuf, addr, ep, name);
+	} else {
 	checksum = crc32 (0,
 			(const char *)(ptr + hdr_size),
 			sbuf.st_size - hdr_size);
@@ -361,6 +381,7 @@ NXTARG:		;
 
 	image_print_contents (hdr);
 
Quoted 8 lines

tools/mkimage.c NXTARG: ; · line 387

Quoted 4 lines
tools/mkimage.c +1 -0
+	}
 	(void) munmap((void *)ptr, sbuf.st_size);
 
 	/* We're a bit of paranoid */

Hmm... it seems you add only image creation code. But "mkimage -l" should work on such an image, too. And "imls" in U-Boot should be working, too.

Well I will disable other generic mkimage options including -l for kwbimage ;-) Can we add this in second part which is not required too?
For me great thing is that we can support kwimage generation through mkimage.

Regards..
Prafulla . .

Quoted 12 lines

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 "Plan to throw one away. You will anyway."
                              - Fred Brooks, "The Mythical Man Month"
#9 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

________________________________________
From: [email protected] [u-boot-bounces at lists.denx.de] On Behalf Of Prafulla Wadaskar [prafulla at marvell.com]
Sent: Sunday, July 19, 2009 10:57 AM
To: Wolfgang Denk
Cc: Manas Saksena; Ronen Shitrit; Nicolas Pitre; u-boot at lists.denx.de; Ashish Karkare; Prabhanjan Sarnaik; Lennert Buijtenhek
Subject: Re: [U-Boot] [PATCH 2/3] tools: mkimage (type=kwbimage) kirkwood boot image support

Dear Wolfgang
Thanks for your quick feedback

Quoted 8 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Sunday, July 19, 2009 3:33 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Manas Saksena; Ronen Shitrit; Nicolas Pitre; Ashish Karkare; Prabhanjan Sarnaik; Lennert Buijtenhek
Subject: Re: [U-Boot] [PATCH 2/3] tools: mkimage (type=kwbimage) kirkwood boot image support

<snip..>

Quoted 12 lines

tools/kwbimage.h new file

Quoted 1 line
tools/kwbimage.h new file renamed from tools/kwbimage.h +0 -0

mode 100644

Quoted 10 lines

index 0000000..c54b701

tools/kwbimage.h new file +6 -0
...
+/* typedefs */
+typedef char s8;
+typedef unsigned char u8;
+
+typedef int s32;
+typedef unsigned int u32;
Quoted 8 lines

tools/kwbimage.h line 58

Quoted 6 lines
tools/kwbimage.h new file +6 -0
+
+typedef short s16;
+typedef unsigned short u16;
+
+typedef long s64;
+typedef unsigned long u64;

Please get rid of these.

Hi Wolfgang
Any suggestions for this?
I could used <linux/types.h> or <asm/types.h> but these typedefs are ifdefed under __KERNEL_STRICT_NAMES and __KERNEL__.
I don't wish to redefine or disturb them for kwbimage support

Regards..
Prafulla . .

Quoted 55 lines

tools/mkimage.c index

Quoted 2 lines
tools/mkimage.c index renamed from tools/mkimage.c +0 -0

c5b593c..9a11071

Quoted 27 lines

100644

tools/mkimage.c +8 -1
@@ -24,6 +24,7 @@
 
 #include "mkimage.h"
 #include <image.h>
+#include "kwbimage.h"
 
 extern int errno;
 
@@ -251,7 +252,13 @@ NXTARG:                ;
     * write dummy header, to be fixed later
     */
    int hdr_size;
-   hdr_size = image_get_header_size ();
+
+   if (opt_type == IH_TYPE_KWBIMAGE) {
+           hdr = kwbimage_get_header_ptr();
+           hdr_size = kwbimage_get_header_size ();
+   } else
+           hdr_size = image_get_header_size ();
+
    memset (hdr, 0, hdr_size);
    if (write(ifd, hdr, hdr_size) != hdr_size) {
            fprintf (stderr, "%s: Write error on %s: %s\n",

tools/mkimage.c NXTARG: ; · line 351

Quoted 6 lines
tools/mkimage.c +3 -0
@@ -339,6 +346,19 @@ NXTARG:                ;
 
    hdr = (image_header_t *)ptr;
 
+   /* Build new header */
+   if (opt_type == IH_TYPE_KWBIMAGE) {
+           checksum = kwbimage_checksum32((void *)ptr,

sbuf.st_size, 0);

tools/mkimage.c NXTARG: ;

Quoted 4 lines
tools/mkimage.c +4 -0
+
+           if (write(ifd, &checksum, sizeof(uint32_t))
+                                   != sizeof(uint32_t)) {
+                   fprintf (stderr, "%s: Checksum wr err

on %s: %s\n",

Quoted 13 lines
tools/mkimage.c +6 -0
+                           cmdname, imagefile, strerror(errno));
+                   exit (EXIT_FAILURE);
+           }
+           sbuf.st_size += sizeof(uint32_t);
+           kwbimage_set_header (hdr, &sbuf, addr, ep, name);
+   } else {
    checksum = crc32 (0,
                    (const char *)(ptr + hdr_size),
                    sbuf.st_size - hdr_size);
@@ -361,6 +381,7 @@ NXTARG:         ;
 
    image_print_contents (hdr);
 
Quoted 8 lines

tools/mkimage.c NXTARG: ; · line 387

Quoted 4 lines
tools/mkimage.c +1 -0
+   }
    (void) munmap((void *)ptr, sbuf.st_size);
 
    /* We're a bit of paranoid */

Hmm... it seems you add only image creation code. But "mkimage -l" should work on such an image, too. And "imls" in U-Boot should be working, too.

Well I will disable other generic mkimage options including -l for kwbimage ;-) Can we add this in second part which is not required too?
For me great thing is that we can support kwimage generation through mkimage.

Regards..
Prafulla . .

Quoted 12 lines

Best regards,

Wolfgang Denk

--
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 "Plan to throw one away. You will anyway."
- Fred Brooks, "The Mythical Man Month"

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#10 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

Dear Prafulla Wadaskar,

Quoted 22 lines · In message <[email protected]>…
Quoted 13 lines

tools/kwbimage.h new file

Quoted 2 lines
tools/kwbimage.h new file renamed from tools/kwbimage.h +0 -0

mode 100644

Quoted 10 lines

index 0000000..c54b701

tools/kwbimage.h new file +6 -0
...
+/* typedefs */
+typedef char s8;
+typedef unsigned char u8;
+
+typedef int s32;
+typedef unsigned int u32;
Quoted 8 lines

tools/kwbimage.h line 58

Quoted 6 lines
tools/kwbimage.h new file +6 -0
+
+typedef short s16;
+typedef unsigned short u16;
+
+typedef long s64;
+typedef unsigned long u64;

Please get rid of these.

Quoted 6 lines

Hi Wolfgang
Any suggestions for this?
I could used <linux/types.h> or <asm/types.h> but these typedefs are ifdefe= d
under __KERNEL_STRICT_NAMES and __KERNEL__.
I don't wish to redefine or disturb them for kwbimage support

This is code running on the host, so please use ISO C99 standard types:
#include <stdint.h> and use int8_t, int16_t, int32_t, int64_t resp. uint8_t, uint16_t, uint32_t, uint64_t.

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
        Ordnung ist die Lust der Vernunft,
        aber Unordnung die Wonne der Phantasie         - Paul Claudel
#11 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

In reply to Prafulla Wadaskar

Dear Prafulla Wadaskar,

Quoted 10 lines · In message <[email protected]>…
Quoted 9 lines

tools/kwbimage.c line 100

Quoted 4 lines
tools/kwbimage.c new file +3 -0
+		lineno++;
+		if (!(line[0] != '#' && strlen(line) != 1))
+			continue;

This is a bit simple-minded. This will for example fail on DOS-formatted files, and for lines that contain only white space (which still look "empty" to most users and are thus hard to spot).

To take care of Dos formatted file I should use "strlen(line) <= 1" right

Hm...

Normally the use of lex (and eventually yacc) is recommended if you need a parser - writing parsers in C is a typical "programming" task (see definition in signature below :-)

If you have an extremely simple syntax, you might for example proceed like this:

1) drop all lines starting with '#' as comment lines.
2) use strtok_r() to split your lines of input into white-space separated tokens.
3) drop all lines with zero tokens (= empty lines)
4) process the rest

[See example in the strtok()/strtok_r() man page).

Quoted 3 lines

As explained in doc.README.kwimage,
any other line apart from above will be considered as valid configuration l> ine. This is bare minimal parsing provided here which is sufficient

...

Quoted 4 lines
Quoted 3 lines

Hmm... it seems you add only image creation code. But "mkimage -l" should work on such an image, too. And "imls" in U-Boot should be working, too.

Well I will disable other generic mkimage options including -l for kwbimage ;-)

This makes little sense to me. When we have one command to build an image, I definitely want to have a command to check and display the contents of an image, too, and/or to verify it's integrity.

Quoted 2 lines

Can we add this in second part which is not required too?
For me great thing is that we can support kwimage generation through mkimage.

I understand your position. I guess you agree that _full_ support (i.e. including the ability to check and list and image, both on the host and on the target) would be even better, and more in line with existing U-Boot code?

Best regards,

Wolfgang Denk

Signature · 7 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
PROGRAM - n.  A magic spell cast over a computer  allowing it to turn
one's input into error messages.
v. tr. - To engage in a pastime similar to banging one's head against
a wall, but with fewer opportunities for reward.
#12 lore raw

PATCH 2/3 tools: mkimage (type=kwbimage) kirkwood boot image support

Quoted 34 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Monday, July 20, 2009 8:27 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Manas Saksena; Ronen Shitrit; Nicolas Pitre; Ashish Karkare; Prabhanjan Sarnaik; Lennert Buijtenhek
Subject: Re: [U-Boot] [PATCH 2/3] tools: mkimage (type=kwbimage) kirkwood boot image support

Dear Prafulla Wadaskar,

In message <[email protected].

Quoted 8 lines · com> you wrote:
Quoted 8 lines

tools/kwbimage.c line 100

Quoted 4 lines
tools/kwbimage.c new file +3 -0
+		lineno++;
+		if (!(line[0] != '#' && strlen(line) != 1))
+			continue;

This is a bit simple-minded. This will for example fail on DOS-formatted files, and for lines that contain only white space (which still look "empty" to most users and are thus hard

to spot).

Quoted 2 lines

To take care of Dos formatted file I should use "strlen(line) <= 1" right

Hm...

Normally the use of lex (and eventually yacc) is recommended if you need a parser - writing parsers in C is a typical "programming" task (see definition in signature below :-)

Quoted 8 lines

If you have an extremely simple syntax, you might for example proceed like this:

1) drop all lines starting with '#' as comment lines.
2) use strtok_r() to split your lines of input into white-space separated tokens.
3) drop all lines with zero tokens (= empty lines)
4) process the rest

Dear Wolfgang
I used strtok_r() since it is extremely simple parser

Quoted 20 lines

[See example in the strtok()/strtok_r() man page).

Quoted 2 lines

As explained in doc.README.kwimage,
any other line apart from above will be considered as valid

configuration l> ine.

Quoted 1 line

This is bare minimal parsing provided here which is sufficient

...

Quoted 5 lines
Quoted 3 lines

Hmm... it seems you add only image creation code. But "mkimage -l" should work on such an image, too. And "imls" in U-Boot should be working, too.

Well I will disable other generic mkimage options including -l for kwbimage ;-)

This makes little sense to me. When we have one command to build an image, I definitely want to have a command to check and display the contents of an image, too, and/or to verify it's integrity.

Quoted 8 lines
Quoted 2 lines

Can we add this in second part which is not required too? For me great thing is that we can support kwimage

generation through mkimage.

I understand your position. I guess you agree that _full_ support (i.e. including the ability to check and list and image, both on the host and on the target) would be even better, and more in line with existing U-Boot code?

I agreed...
I have posted separate patch to support check and list support. Thanks for wishing this to make it complete kwbimage support :-)

Regards..
Prafulla . .

Quoted 14 lines

Best regards,

Wolfgang Denk

Signature · 7 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 PROGRAM - n.  A magic spell cast over a computer  
allowing it to turn one's input into error messages.
v. tr. - To engage in a pastime similar to banging one's head 
against a wall, but with fewer opportunities for reward.
#13 lore raw

PATCH 1/3 tools: mkimage: hdr_size used to facilitate customized support

In reply to Prafulla Wadaskar

Dear Prafulla Wadaskar,

Quoted 4 lines · In message <[email protected]> you wrote:

hdr_size variable is initialized
at the start of image creation algorithm instead of reading it each time. This facilitate to use the common code for other image type implementations for ex. kwbimage

Hm... I have no idea what you are trying to do, or why. You are aware that image_get_header_size() is a static inline, returning just "sizeof (image_header_t)"?

As far as the context of mkimage goes, you could as well consider it a constant.

Quoted 10 lines
---
 tools/mkimage.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
tools/mkimage.c +0 -0
index 967fe9a..c5b593c 100644

tools/mkimage.c NXTARG: ; · line 253

Quoted 7 lines
tools/mkimage.c +1 -3
@@ -250,9 +250,10 @@ NXTARG:		;
 	 *
 	 * write dummy header, to be fixed later
 	 */
-	memset (hdr, 0, image_get_header_size ());
-
-	if (write(ifd, hdr, image_get_header_size ()) != image_get_header_size ()) {
+	int hdr_size;

We don't allow variable declarations in the middle of the code.

Best regards,

Wolfgang Denk

Signature · 4 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
Objects in mirror are closer than they appear.
#14 lore raw

PATCH 1/3 tools: mkimage: hdr_size used to facilitate customized support

Quoted 17 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Sunday, July 19, 2009 3:04 AM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Manas Saksena; Ronen Shitrit; Nicolas Pitre; Ashish Karkare; Prabhanjan Sarnaik; Lennert Buijtenhek
Subject: Re: [U-Boot] [PATCH 1/3] tools: mkimage: hdr_size used to facilitate customized support

Dear Prafulla Wadaskar,

In message

Quoted 2 lines · <[email protected]> you wrote:

hdr_size variable is initialized
at the start of image creation algorithm instead of reading

Quoted 7 lines

it each time.

Quoted 2 lines

This facilitate to use the common code for other image type implementations for ex. kwbimage

Hm... I have no idea what you are trying to do, or why. You are aware that image_get_header_size() is a static inline, returning just "sizeof (image_header_t)"?

Dear Wolfgang

This is what done in image_get_header_size().
I do not want to disturb current mkimage implementation.
whereas for mkbimage creation the image_header size will come form kwbimag.h and not generic one which is used further in image creation part.

In brief, header size will be decided by which kind of image you are creating.

This is a generic change required for kwbimage support.
I have kept this change in separate patch to get some better readability of generic changes for kwbimage support.

Quoted 3 lines

As far as the context of mkimage goes, you could as well consider it a constant.

This will be decided runtime hence can not be considered as constant.
Well I can update the relevant line kwbimage patch to read sizeof() instead of api kwbimage_get_header_size()

Quoted 19 lines

tools/mkimage.c index

Quoted 7 lines
---
 tools/mkimage.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
tools/mkimage.c index renamed from tools/mkimage.c +0 -0

967fe9a..c5b593c

tools/mkimage.c NXTARG: ; · line 255

Quoted 10 lines

100644

tools/mkimage.c +0 -3
@@ -250,9 +250,10 @@ NXTARG:		;
 	 *
 	 * write dummy header, to be fixed later
 	 */
-	memset (hdr, 0, image_get_header_size ());
-
-	if (write(ifd, hdr, image_get_header_size ()) != 

image_get_header_size ()) {

Quoted 3 lines

tools/mkimage.c NXTARG: ; · line 253

Quoted 1 line
tools/mkimage.c +1 -0
+	int hdr_size;

We don't allow variable declarations in the middle of the code.

Okay I will more this up

Thanks and regards..
Prafulla . .