brcm47xx: fix error when build firmware on x86_64 host (closes #7672)
SVN-Revision: 25472
This commit is contained in:
parent
8dbb2ee6f2
commit
e08740c747
@ -23,7 +23,7 @@ struct trx_header {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define EDIMAX_PS16 0x36315350
|
#define EDIMAX_PS16 0x36315350 /* "PS16" */
|
||||||
#define EDIMAX_HDR_LEN 0xc
|
#define EDIMAX_HDR_LEN 0xc
|
||||||
|
|
||||||
|
|
||||||
@ -113,9 +113,10 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "Unable to open %s\n", argv[1]);
|
fprintf(stderr, "Unable to open %s\n", argv[1]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
/* compute the length of the file */
|
||||||
fseek(fpIn, 0, SEEK_END);
|
fseek(fpIn, 0, SEEK_END);
|
||||||
length = ftell(fpIn);
|
length = ftell(fpIn);
|
||||||
|
/* alloc enough memory to store the file */
|
||||||
buf = (char *)malloc(length);
|
buf = (char *)malloc(length);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
fprintf(stderr, "malloc of buffers failed\n");
|
fprintf(stderr, "malloc of buffers failed\n");
|
||||||
@ -123,6 +124,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
rewind(fpIn);
|
rewind(fpIn);
|
||||||
|
/* read the whole file*/
|
||||||
res = fread(buf, 1, length, fpIn);
|
res = fread(buf, 1, length, fpIn);
|
||||||
|
|
||||||
p = (struct trx_header *)buf;
|
p = (struct trx_header *)buf;
|
||||||
@ -140,11 +142,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
/* make the 3 partition beeing 12 bytes closer from the header */
|
/* make the 3 partition beeing 12 bytes closer from the header */
|
||||||
memcpy(buf + p->offsets[2] - EDIMAX_HDR_LEN, buf + p->offsets[2], length - p->offsets[2]);
|
memcpy(buf + p->offsets[2] - EDIMAX_HDR_LEN, buf + p->offsets[2], length - p->offsets[2]);
|
||||||
|
/* recompute the crc32 check */
|
||||||
p->crc32 = crc32buf((char *) &p->flag_version, length - offsetof(struct trx_header, flag_version));
|
p->crc32 = crc32buf((char *) &p->flag_version, length - offsetof(struct trx_header, flag_version));
|
||||||
|
/* write the modified file */
|
||||||
fwrite(&sign, sizeof(long), 1, fpOut);
|
fwrite(&sign, sizeof(uint32_t), 1, fpOut);
|
||||||
fwrite(&length, sizeof(long), 1, fpOut);
|
fwrite(&length, sizeof(uint32_t), 1, fpOut);
|
||||||
fwrite(&start_addr, sizeof(long), 1, fpOut);
|
fwrite(&start_addr, sizeof(uint32_t), 1, fpOut);
|
||||||
fwrite(buf, sizeof(char), length, fpOut);
|
fwrite(buf, sizeof(char), length, fpOut);
|
||||||
fclose(fpOut);
|
fclose(fpOut);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user