Show message if firmware file has been (potentially) rejected by remote
This commit is contained in:
parent
9f6ed3348a
commit
a7310bf2dd
3 changed files with 22 additions and 2 deletions
14
main.c
14
main.c
|
@ -310,7 +310,19 @@ int main(int argc, char **argv)
|
|||
require_admin();
|
||||
}
|
||||
#endif
|
||||
val = !list ? nmrp_do(&args) : ethsock_list_all();
|
||||
if (list) {
|
||||
val = ethsock_list_all();
|
||||
} else {
|
||||
val = nmrp_do(&args);
|
||||
if (val != 0 && args.maybe_invalid_firmware_file) {
|
||||
fprintf(stderr,
|
||||
"\n"
|
||||
"Firmware file rejected by remote device. Possible causes:\n"
|
||||
"- Wrong firmware file (model number correct?)\n"
|
||||
"- Wrong file format (e.g. .chk vs .trx file)\n"
|
||||
"- Downgrading to a lower version number\n");
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
#ifdef NMRPFLASH_WINDOWS
|
||||
|
|
8
nmrp.c
8
nmrp.c
|
@ -410,6 +410,8 @@ int nmrp_do(struct nmrpd_args *args)
|
|||
struct in_addr ipaddr;
|
||||
struct in_addr ipmask;
|
||||
|
||||
args->maybe_invalid_firmware_file = false;
|
||||
|
||||
if (args->op != NMRP_UPLOAD_FW) {
|
||||
fprintf(stderr, "Operation not implemented.\n");
|
||||
return 1;
|
||||
|
@ -634,6 +636,10 @@ int nmrp_do(struct nmrpd_args *args)
|
|||
if (expect != NMRP_C_NONE && rx.msg.code != expect) {
|
||||
fprintf(stderr, "Received %s while waiting for %s!\n",
|
||||
msg_code_str(rx.msg.code), msg_code_str(expect));
|
||||
|
||||
if (ulreqs && expect == NMRP_C_TFTP_UL_REQ && rx.msg.code == NMRP_C_CONF_REQ) {
|
||||
args->maybe_invalid_firmware_file = true;
|
||||
}
|
||||
}
|
||||
|
||||
msg_init(&tx.msg, NMRP_C_NONE);
|
||||
|
@ -668,6 +674,7 @@ int nmrp_do(struct nmrpd_args *args)
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
args->maybe_invalid_firmware_file = true;
|
||||
if (verbosity) {
|
||||
printf("Ignoring extra upload request.\n");
|
||||
}
|
||||
|
@ -744,6 +751,7 @@ int nmrp_do(struct nmrpd_args *args)
|
|||
// file has been rejected. this feature is only implemented
|
||||
// by some bootloaders.
|
||||
expect = NMRP_C_TFTP_UL_REQ;
|
||||
args->maybe_invalid_firmware_file = true;
|
||||
} else {
|
||||
goto out;
|
||||
}
|
||||
|
|
2
nmrpd.h
2
nmrpd.h
|
@ -116,7 +116,7 @@ struct nmrpd_args {
|
|||
uint16_t port;
|
||||
const char *region;
|
||||
off_t offset;
|
||||
|
||||
bool maybe_invalid_firmware_file;
|
||||
struct ethsock *sock;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue