From: Gabor Juhos Date: Fri, 14 Jan 2011 10:37:04 +0000 (+0000) Subject: firmware-utils/wndr3700: allow to specify image magic via command line X-Git-Tag: reboot~17881 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e116785f274c36f53eb355500d69791dff92d85d;p=openwrt%2Fstaging%2Fchunkeey.git firmware-utils/wndr3700: allow to specify image magic via command line SVN-Revision: 24980 --- diff --git a/tools/firmware-utils/src/wndr3700.c b/tools/firmware-utils/src/wndr3700.c index 51e5352cb0..97b5f1d455 100644 --- a/tools/firmware-utils/src/wndr3700.c +++ b/tools/firmware-utils/src/wndr3700.c @@ -37,7 +37,10 @@ #define BPB 8 /* bits/byte */ +#define WNDR3700_MAGIC_LEN 4 + static uint32_t crc32[1< 3) + magic = argv[3]; + + if (strlen(magic) != WNDR3700_MAGIC_LEN) { + fprintf(stderr, "Invalid magic: '%s'\n", magic); + exit(1); + } + // mmap input_file if ((fd = open(argv[1], O_RDONLY)) < 0 || (len = lseek(fd, 0, SEEK_END)) < 0 @@ -110,7 +121,7 @@ int main(int argc, char **argv) // preload header memcpy(&header, input_file, sizeof(header)); - header.magic = htonl(0x33373030); /* 3700 in ascii */ + memcpy(header.magic, magic, WNDR3700_MAGIC_LEN); header.crc = 0; // create a firmware image in memory and copy the input_file to it