struct imagetag tag;
struct kernelhdr khdr;
FILE *kernelfile = NULL, *rootfsfile = NULL, *binfile;
- size_t kerneloff, kernellen, rootfsoff, rootfslen, read, imagelen;
+ size_t kerneloff, kernellen, rootfsoff, rootfslen, read, imagelen, rootfsoffpadlen;
uint8_t readbuf[1024];
uint32_t crc = IMAGETAG_CRC_START;
const uint32_t deadcode = htonl(DEADCODE);
rootfslen = getlen(rootfsfile);
rootfslen = (rootfslen % flash_bs) > 0 ? (((rootfslen / flash_bs) + 1) * flash_bs) : rootfslen;
imagelen = rootfsoff + rootfslen - kerneloff + sizeof(deadcode);
+ rootfsoffpadlen = rootfsoff - (kerneloff + kernellen);
/* Seek to the start of the kernel */
fseek(binfile, kerneloff - fwaddr, SEEK_SET);
if (kernelfile) {
sprintf(tag.kernel.address, "%lu", kerneloff);
- sprintf(tag.kernel.len, "%lu", kernellen);
+ sprintf(tag.kernel.len, "%lu", kernellen + rootfsoffpadlen);
}
if (rootfsfile) {