" -t <timeout> Timeout (in milliseconds) for regular messages\n"
" -T <timeout> Time (seconds) to wait after successfull TFTP upload\n"
" -p <port> Port to use for TFTP upload\n"
+#ifdef NMRPFLASH_SET_REGION
+ " -R <region> Set device region\n"
+#endif
#ifdef NMRPFLASH_TFTP_TEST
" -U Test TFTP upload\n"
#endif
opterr = 0;
- while ((c = getopt(argc, argv, "a:c:f:F:i:m:M:p:t:T:hLVvU")) != -1) {
+ while ((c = getopt(argc, argv, "a:c:f:F:i:m:M:p:R:t:T:hLVvU")) != -1) {
max = 0x7fffffff;
switch (c) {
case 'a':
args.ipmask = optarg;
break;
case 'p':
- max = 0xffff;
+#ifdef NMRPFLASH_SET_REGION
+ case 'R':
+#endif
case 'T':
case 't':
+ if (c == 'p') {
+ max = 0xffff;
+ } else if (c == 'R') {
+ max = 0x0009;
+ }
+
val = atoi(optarg);
if (val <= 0 || val > max) {
fprintf(stderr, "Invalid numeric value for -%c.\n", c);
args.port = val;
} else if (c == 't') {
args.rx_timeout = val;
- } else {
+ } else if (c == 'T') {
args.ul_timeout = val * 1000;
+ } else if (c == 'R') {
+ args.region = val;
}
break;
uint16_t len;
union {
uint8_t magic[4];
+ uint16_t region;
struct {
uint8_t addr[4];
uint8_t mask[4];
tx.msg.opts[1].type = NMRP_O_FW_UP;
tx.msg.opts[1].len = NMRP_OPT_LEN;
+#ifdef NMRPFLASH_SET_REGION
+ tx.msg.num_opts = 3;
+
+ tx.msg.opts[2].type = NMRP_O_DEV_REGION;
+ tx.msg.opts[2].len = NMRP_OPT_LEN + 2;
+ tx.msg.opts[2].val.region = args->region;
+#endif
+
expect = NMRP_C_TFTP_UL_REQ;
printf("Received configuration request from %s.\n",