0x00000000, 0x00000005, 0x00000000, 0x00000000
};
-static int JFFS2 = 0x20;
+static int JFFS2 = 0;
int generate_image(char *kname, char *fsname, char *fname, int EHDR)
{
else
write(ffd, header + 2, 0x20);
write(ffd, bk, lenk);
+ if (!JFFS2) JFFS2 = 0x20;
printf("Padding header+kernel - 0x%x + 0x%x = 0x%x\n",
lenk, ((lenk - 1 + JFFS2) / JFFS2) * JFFS2 - lenk,
((lenk - 1 + JFFS2) / JFFS2) * JFFS2);
u32 sum, l0;
u32 MagicS = 0x474d544b;
u32 MagicE = 0x4152524e;
- if (htonl(*((u32 *) buf)) == MagicS) {
+ if (ntohl(*((u32 *) buf)) == MagicS) {
fprintf(stderr,
"Image without extra 8 bytes - Standard header\n");
buf[0x10] = len & 0xff;
lseek(fd, 0x10, SEEK_SET);
write(fd, buf + 0x10, 0x4);
EHDR = 0;
- } else if ((htonl(*((u32 *) (buf + 0x8))) == MagicS)
- && ((htonl(*((u32 *) (buf + 0x4))) == MagicE))) {
+ } else if ((ntohl(*((u32 *) (buf + 0x8))) == MagicS)
+ && ((ntohl(*((u32 *) (buf + 0x4))) == MagicE))) {
fprintf(stderr,
"Image with extra 8 bytes - Extended header\n");
*((u32 *) (buf + 0x18)) = len - 8;
unsigned long sum2 = buf[-0x8] | ((u32)buf[-0x7] << 8) | ((u32)buf[-0x6] << 16) | ((u32)buf[-0x5] << 24);
*((u32 *) & buf[-0x8]) = 0L;
sum = crc32(buf - 0x4, len - 0x4);
- sum = htonl(sum);
printf("CRC32 sum2 - (%x, %x, %x)\n", sum, sum2,
len - 0x4);
lseek(fd, 0, SEEK_SET);
- buf[-0x8] = sum & 0xff;
- buf[-0x7] = (sum >> 8) & 0xff;
- buf[-0x6] = (sum >> 16) & 0xff;
- buf[-0x5] = (sum >> 24) & 0xff;
+ *((u32 *) & buf[-0x8]) = htonl(sum);
write(fd, &buf[-0x8], 0x4);
buf -= 8;
}