Added "verify" command.
This commit is contained in:
parent
5584136b69
commit
65d15ef680
|
@ -488,6 +488,10 @@ Rename symbols by searching for those matching the given regular
|
||||||
expression and substituting the given string for the matched portion. The
|
expression and substituting the given string for the matched portion. The
|
||||||
symbols renamed are displayed, as well as a total count of all symbols
|
symbols renamed are displayed, as well as a total count of all symbols
|
||||||
renamed.
|
renamed.
|
||||||
|
.IP "\fBverify \fIfilename\fR"
|
||||||
|
Compare the contents of the given binary file to the chip memory. If any
|
||||||
|
differences are found, a message is printed for the first mismatched
|
||||||
|
byte.
|
||||||
.SH SUPPORTED CHIPS
|
.SH SUPPORTED CHIPS
|
||||||
The following chips are supported when using FET-compatible drivers:
|
The following chips are supported when using FET-compatible drivers:
|
||||||
.PP
|
.PP
|
||||||
|
|
|
@ -120,6 +120,13 @@ const struct cmddb_record commands[] = {
|
||||||
"load <filename>\n"
|
"load <filename>\n"
|
||||||
" Flash the data contained in a binary file. Does not load symbols\n"
|
" Flash the data contained in a binary file. Does not load symbols\n"
|
||||||
" or erase the device.\n"
|
" or erase the device.\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "verify",
|
||||||
|
.func = cmd_verify,
|
||||||
|
.help =
|
||||||
|
"verify <filename>\n"
|
||||||
|
" Compare the contents of the given binary file to the device memory.\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "md",
|
.name = "md",
|
||||||
|
|
10
ui/devcmd.c
10
ui/devcmd.c
|
@ -534,7 +534,8 @@ static int do_cmd_prog(char **arg, int prog_flags)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prog_flags && (binfile_info(in) & BINFILE_HAS_SYMS)) {
|
if ((prog_flags & PROG_WANT_ERASE) &&
|
||||||
|
(binfile_info(in) & BINFILE_HAS_SYMS)) {
|
||||||
stab_clear();
|
stab_clear();
|
||||||
binfile_syms(in);
|
binfile_syms(in);
|
||||||
}
|
}
|
||||||
|
@ -544,7 +545,7 @@ static int do_cmd_prog(char **arg, int prog_flags)
|
||||||
if (prog_flush(&prog) < 0)
|
if (prog_flush(&prog) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
printc("Done, %d bytes written\n", prog.total_written);
|
printc("Done, %d bytes total\n", prog.total_written);
|
||||||
|
|
||||||
if (device_ctl(DEVICE_CTL_RESET) < 0)
|
if (device_ctl(DEVICE_CTL_RESET) < 0)
|
||||||
printc_err("warning: prog: "
|
printc_err("warning: prog: "
|
||||||
|
@ -564,6 +565,11 @@ int cmd_load(char **arg)
|
||||||
return do_cmd_prog(arg, 0);
|
return do_cmd_prog(arg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cmd_verify(char **arg)
|
||||||
|
{
|
||||||
|
return do_cmd_prog(arg, PROG_VERIFY);
|
||||||
|
}
|
||||||
|
|
||||||
static int do_setbreak(device_bptype_t type, char **arg)
|
static int do_setbreak(device_bptype_t type, char **arg)
|
||||||
{
|
{
|
||||||
char *addr_text = get_arg(arg);
|
char *addr_text = get_arg(arg);
|
||||||
|
|
|
@ -31,6 +31,7 @@ int cmd_dis(char **arg);
|
||||||
int cmd_hexout(char **arg);
|
int cmd_hexout(char **arg);
|
||||||
int cmd_prog(char **arg);
|
int cmd_prog(char **arg);
|
||||||
int cmd_load(char **arg);
|
int cmd_load(char **arg);
|
||||||
|
int cmd_verify(char **arg);
|
||||||
int cmd_setbreak(char **arg);
|
int cmd_setbreak(char **arg);
|
||||||
int cmd_setwatch(char **arg);
|
int cmd_setwatch(char **arg);
|
||||||
int cmd_setwatch_r(char **arg);
|
int cmd_setwatch_r(char **arg);
|
||||||
|
|
22
util/prog.c
22
util/prog.c
|
@ -41,13 +41,33 @@ int prog_flush(struct prog_data *prog)
|
||||||
prog->have_erased = 1;
|
prog->have_erased = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printc_dbg("Writing %4d bytes to %04x", prog->len, prog->addr);
|
printc_dbg("%s %4d bytes at %04x",
|
||||||
|
(prog->flags & PROG_VERIFY) ? "Verifying" : "Writing",
|
||||||
|
prog->len, prog->addr);
|
||||||
if (prog->section[0])
|
if (prog->section[0])
|
||||||
printc_dbg(" [section: %s]", prog->section);
|
printc_dbg(" [section: %s]", prog->section);
|
||||||
printc_dbg("...\n");
|
printc_dbg("...\n");
|
||||||
|
|
||||||
|
if (prog->flags & PROG_VERIFY) {
|
||||||
|
uint8_t cmp_buf[PROG_BUFSIZE];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (device_readmem(prog->addr, cmp_buf, prog->len) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i < prog->len; i++)
|
||||||
|
if (cmp_buf[i] != prog->buf[i]) {
|
||||||
|
printc("\x1b[1mERROR:\x1b[0m "
|
||||||
|
"mismatch at %04x (read %02x, "
|
||||||
|
"expected %02x)\n",
|
||||||
|
prog->addr + i,
|
||||||
|
cmp_buf[i], prog->buf[i]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (device_writemem(prog->addr, prog->buf, prog->len) < 0)
|
if (device_writemem(prog->addr, prog->buf, prog->len) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
prog->total_written += prog->len;
|
prog->total_written += prog->len;
|
||||||
prog->addr += prog->len;
|
prog->addr += prog->len;
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct prog_data {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PROG_WANT_ERASE 0x01
|
#define PROG_WANT_ERASE 0x01
|
||||||
|
#define PROG_VERIFY 0x02
|
||||||
|
|
||||||
void prog_init(struct prog_data *data, int flags);
|
void prog_init(struct prog_data *data, int flags);
|
||||||
int prog_feed(struct prog_data *data, const struct binfile_chunk *ch);
|
int prog_feed(struct prog_data *data, const struct binfile_chunk *ch);
|
||||||
|
|
Loading…
Reference in New Issue