Skip to contentSkip to conversation

ARM: kwimage: fix v0 format

PATCH New Gerald Kerma 4 participants 5 messages Oct 31, 2014 – Nov 4, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 ARM: kwimage: fix v0 format

This patch fix the kwimage tools for version 0 fileformat used for kirkwood Tested on sheevaplug

---
 tools/kwbimage.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tools/kwbimage.c +6 -4
index 1120e9b..7e2fb5e 100644
@@ -324,7 +324,7 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params,
 	main_hdr = image;
 
 	/* Fill in the main header */
-	main_hdr->blocksize = payloadsz + sizeof(uint32_t);
+	main_hdr->blocksize = payloadsz + sizeof(uint32_t) - headersz;
 	main_hdr->srcaddr   = headersz;
 	main_hdr->ext       = has_ext;
 	main_hdr->destaddr  = params->addr;
@@ -792,8 +792,8 @@ static void kwbimage_print_header(const void *ptr)
 
 	printf("Image Type:   MVEBU Boot from %s Image\n",
 	       image_boot_mode_name(mhdr->blockid));
-	printf("Data Size:    ");
 	printf("Image version:%d\n", image_version((void *)ptr));
+	printf("Data Size:    ");
 	genimg_print_size(mhdr->blocksize - sizeof(uint32_t));
 	printf("Load Address: %08x\n", mhdr->destaddr);
 	printf("Entry Point:  %08x\n", mhdr->execaddr);
@@ -816,7 +816,8 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size,
 
 	main_hdr = (void *)ptr;
 	checksum = image_checksum8(ptr,
-				   sizeof(struct main_hdr_v0));
+				   sizeof(struct main_hdr_v0)
+				   - sizeof(uint8_t));
 	if (checksum != main_hdr->checksum)
 		return -FDT_ERR_BADSTRUCTURE;
 
@@ -824,7 +825,8 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size,
 	if (image_version((void *)ptr) == 0) {
 		ext_hdr = (void *)ptr + sizeof(struct main_hdr_v0);
 		checksum = image_checksum8(ext_hdr,
-					   sizeof(struct ext_hdr_v0));
+					   sizeof(struct ext_hdr_v0)
+					   - sizeof(uint8_t));
 		if (checksum != ext_hdr->checksum)
 			return -FDT_ERR_BADSTRUCTURE;
 	}
Signature · 1 line
1.9.1
#1 lore raw

PATCH 3/3 ARM: kwimage: fix v0 format

Quoted 65 lines

-----Original Message-----
From: Gerald Kerma [mailto:drEagle at doukki.net]
Sent: 31 October 2014 05:33
To: u-boot at lists.denx.de; Prafulla Wadaskar; sr at denx.de
Cc: albert.u.boot at aribaud.net; luka at openwrt.org; Gerald Kerma
Subject: [PATCH 3/3] ARM: kwimage: fix v0 format

This patch fix the kwimage tools for version 0
fileformat used for kirkwood
Tested on sheevaplug

---
 tools/kwbimage.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tools/kwbimage.c +2 -3
index 1120e9b..7e2fb5e 100644
@@ -324,7 +324,7 @@ static void *image_create_v0(size_t
 *imagesz, struct image_tool_params *params,
 	main_hdr = image;
 
 	/* Fill in the main header */
-	main_hdr->blocksize = payloadsz + sizeof(uint32_t);
+	main_hdr->blocksize = payloadsz + sizeof(uint32_t)
- headersz;
 	main_hdr->srcaddr   = headersz;
 	main_hdr->ext       = has_ext;
 	main_hdr->destaddr  = params->addr;
@@ -792,8 +792,8 @@ static void
 kwbimage_print_header(const void *ptr)
 
 	printf("Image Type:   MVEBU Boot from %s Image\n",
 	       image_boot_mode_name(mhdr->blockid));
-	printf("Data Size:    ");
 	printf("Image version:%d\n", image_version((void
 *)ptr));
+	printf("Data Size:    ");
 	genimg_print_size(mhdr->blocksize -

sizeof(uint32_t));

tools/kwbimage.c +0 -0
 	printf("Load Address: %08x\n", mhdr->destaddr);
 	printf("Entry Point:  %08x\n", mhdr->execaddr);
@@ -816,7 +816,8 @@ static int

kwbimage_verify_header(unsigned char *ptr, int
image_size,

tools/kwbimage.c +2 -1
 	main_hdr = (void *)ptr;
 	checksum = image_checksum8(ptr,
-				   sizeof(struct main_hdr_v0));
+				   sizeof(struct main_hdr_v0)
+				   - sizeof(uint8_t));
 	if (checksum != main_hdr->checksum)
 		return -FDT_ERR_BADSTRUCTURE;
@@ -824,7 +825,8 @@ static int

kwbimage_verify_header(unsigned char *ptr, int
image_size,

tools/kwbimage.c +0 -0
 	if (image_version((void *)ptr) == 0) {
 		ext_hdr = (void *)ptr + sizeof(struct

main_hdr_v0);

tools/kwbimage.c static int kwbimage_verify_header(unsigned char *ptr, int image_size,

Quoted 8 lines
tools/kwbimage.c +2 -2
 		checksum = image_checksum8(ext_hdr,
-					   sizeof(struct ext_hdr_v0));
+					   sizeof(struct ext_hdr_v0)
+					   - sizeof(uint8_t));
 		if (checksum != ext_hdr->checksum)
 			return -FDT_ERR_BADSTRUCTURE;
 	}
--

Thanks Gerald.

Regards...
Prafulla . . .

Quoted 1 line

1.9.1

#3 lore raw

PATCH 3/3 ARM: kwimage: fix v0 format

Quoted 15 lines

-----Original Message-----
From: Stefan Roese [mailto:sr at denx.de]
Sent: 31 October 2014 12:26
To: Gerald Kerma; u-boot at lists.denx.de; Prafulla Wadaskar
Cc: albert.u.boot at aribaud.net; luka at openwrt.org
Subject: Re: [PATCH 3/3] ARM: kwimage: fix v0 format

Quoted 1 line · Gerald Kerma

This patch fix the kwimage tools for version 0

fileformat used for kirkwood

Quoted 2 lines

Tested on sheevaplug

Quoted 8 lines
Quoted 1 line

I tested this on AXP (version 1 instead of version 0) and found no
problems here. So:

Hi Tom,
Since the changes are to the generic tools, may you please pull this patch?

Regards...
Prafulla . . .

#4 lore raw

PATCH 3/3 ARM: kwimage: fix v0 format

In reply to Gerald Kerma
Quoted 4 lines · Gerald Kerma

This patch fix the kwimage tools for version 0 fileformat used for kirkwood Tested on sheevaplug

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141104/ac74613b/attachment.pgp>