It has come to my attention that there is a bug with this tool on 64-bit machines. Basically I was a lazy boy and copied the definition of struct chk_header, which is fine if a unsigned long is 4 bytes (32-bit machines), but totally wrong where its 8 bytes. I will flog myself later! Anyway until I upload a new version here is the patch...
--- mkchkimg.c.orig 2008-11-14 14:00:30.000000000 +0000
+++ mkchkimg.c 2008-11-14 14:06:43.000000000 +0000
@@ -32,15 +32,15 @@
#define MAX_BOARD_ID_LEN (64)
struct chk_header {
- unsigned long magic;
- unsigned long header_len;
- unsigned char reserved[8];
- unsigned long kernel_chksum;
- unsigned long rootfs_chksum;
- unsigned long kernel_len;
- unsigned long rootfs_len;
- unsigned long image_chksum;
- unsigned long header_chksum;
+ uint32_t magic;
+ uint32_t header_len;
+ uint8_t reserved[8];
+ uint32_t kernel_chksum;
+ uint32_t rootfs_chksum;
+ uint32_t kernel_len;
+ uint32_t rootfs_len;
+ uint32_t image_chksum;
+ uint32_t header_chksum;
/* char board_id[] - upto MAX_BOARD_ID_LEN */
};
@@ -76,8 +76,8 @@
}
struct ngr_checksum {
- unsigned long c0;
- unsigned long c1;
+ uint32_t c0;
+ uint32_t c1;
};
static inline void
@@ -100,7 +100,7 @@
static inline unsigned long
netgear_checksum_fini (struct ngr_checksum * c)
{
- unsigned long b, checksum;
+ uint32_t b, checksum;
b = (c->c0 & 65535) + ((c->c0 >> 16) & 65535);
c->c0 = ((b >> 16) + b) & 65535;
@@ -272,8 +272,8 @@
netgear_checksum_add (&chk_whole, (unsigned char *)buf, len);
}
hdr->kernel_chksum = netgear_checksum_fini (&chk_part);
- message (" Kernel Len: %lu", hdr->kernel_len);
- message ("Kernel Checksum: 0x%08lx", hdr->kernel_chksum);
+ message (" Kernel Len: %u", hdr->kernel_len);
+ message ("Kernel Checksum: 0x%08x", hdr->kernel_chksum);
hdr->kernel_len = htonl (hdr->kernel_len);
hdr->kernel_chksum = htonl (hdr->kernel_chksum);
@@ -293,15 +293,15 @@
netgear_checksum_add (&chk_whole, (unsigned char *)buf, len);
}
hdr->rootfs_chksum = (netgear_checksum_fini (&chk_part));
- message (" Rootfs Len: %lu", hdr->rootfs_len);
- message ("Rootfs Checksum: 0x%08lx", hdr->rootfs_chksum);
+ message (" Rootfs Len: %u", hdr->rootfs_len);
+ message ("Rootfs Checksum: 0x%08x", hdr->rootfs_chksum);
hdr->rootfs_len = htonl (hdr->rootfs_len);
hdr->rootfs_chksum = htonl (hdr->rootfs_chksum);
}
/* Calcautate the image checksum */
hdr->image_chksum = netgear_checksum_fini (&chk_whole);
- message (" Image Checksum: 0x%08lx", hdr->image_chksum);
+ message (" Image Checksum: 0x%08x", hdr->image_chksum);
hdr->image_chksum = htonl (hdr->image_chksum);
/* Calculate the header checksum */

RSS


The above patch has been included in version 0.2