aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-07-05 16:25:29 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-07-05 16:25:29 +0000
commita45427bc7970a2747c8b5b58364c8bea3657fa27 (patch)
treed7aca0157a51e41657f35e634b994fec4074bf96
parent7c932579fa099e0c7a8fbdea763b5526170c99fa (diff)
downloadupstream-a45427bc7970a2747c8b5b58364c8bea3657fa27.tar.gz
upstream-a45427bc7970a2747c8b5b58364c8bea3657fa27.tar.bz2
upstream-a45427bc7970a2747c8b5b58364c8bea3657fa27.zip
firmware-utils/mktplinkfw: allow to specify firmware version
SVN-Revision: 32616
-rw-r--r--tools/firmware-utils/src/mktplinkfw.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c
index 6286cff913..fab2081703 100644
--- a/tools/firmware-utils/src/mktplinkfw.c
+++ b/tools/firmware-utils/src/mktplinkfw.c
@@ -79,7 +79,10 @@ struct fw_header {
uint32_t rootfs_len; /* rootfs data length */
uint32_t boot_ofs; /* bootloader data offset */
uint32_t boot_len; /* bootloader data length */
- uint8_t pad[360];
+ uint16_t ver_hi;
+ uint16_t ver_mid;
+ uint16_t ver_lo;
+ uint8_t pad[354];
} __attribute__ ((packed));
struct flash_layout {
@@ -104,6 +107,7 @@ static char *ofname;
static char *progname;
static char *vendor = "TP-LINK Technologies";
static char *version = "ver. 1.0";
+static char *fw_ver = "0.0.0";
static char *board_id;
static struct board_info *board;
@@ -113,6 +117,9 @@ static char *opt_hw_id;
static uint32_t hw_id;
static char *opt_hw_rev;
static uint32_t hw_rev;
+static int fw_ver_lo;
+static int fw_ver_mid;
+static int fw_ver_hi;
static struct file_info kernel_info;
static uint32_t kernel_la = 0;
static uint32_t kernel_ep = 0;
@@ -368,6 +375,7 @@ static void usage(int status)
" -j add jffs2 end-of-filesystem markers\n"
" -N <vendor> set image vendor to <vendor>\n"
" -V <version> set image version to <version>\n"
+" -v <version> set firmware version to <version>\n"
" -i <file> inspect given firmware file <file>\n"
" -x extract kernel and rootfs while inspecting (requires -i)\n"
" -h show this screen\n"
@@ -545,6 +553,12 @@ static int check_options(void)
return -1;
}
+ ret = sscanf(fw_ver, "%d.%d.%d", &fw_ver_hi, &fw_ver_mid, &fw_ver_lo);
+ if (ret != 3) {
+ ERR("invalid firmware version '%s'", fw_ver);
+ return -1;
+ }
+
return 0;
}
@@ -575,6 +589,10 @@ static void fill_header(char *buf, int len)
hdr->rootfs_len = htonl(rootfs_info.file_size);
}
+ hdr->ver_hi = htons(fw_ver_hi);
+ hdr->ver_mid = htons(fw_ver_mid);
+ hdr->ver_lo = htons(fw_ver_lo);
+
get_md5(buf, len, hdr->md5sum1);
}
@@ -926,7 +944,7 @@ int main(int argc, char *argv[])
while ( 1 ) {
int c;
- c = getopt(argc, argv, "a:B:H:E:F:L:V:N:W:ci:k:r:R:o:xhsj");
+ c = getopt(argc, argv, "a:B:H:E:F:L:V:N:W:ci:k:r:R:o:xhsjv:");
if (c == -1)
break;
@@ -955,6 +973,9 @@ int main(int argc, char *argv[])
case 'V':
version = optarg;
break;
+ case 'v':
+ fw_ver = optarg;
+ break;
case 'N':
vendor = optarg;
break;
/a> 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362