Modified erase command to allow mass and segment erase.
This commit is contained in:
parent
b9e5db63d5
commit
0dade4228e
6
cmddb.c
6
cmddb.c
|
@ -124,8 +124,10 @@ const struct cmddb_record commands[] = {
|
||||||
.name = "erase",
|
.name = "erase",
|
||||||
.func = cmd_erase,
|
.func = cmd_erase,
|
||||||
.help =
|
.help =
|
||||||
"erase\n"
|
"erase [all|segment] [address]\n"
|
||||||
" Erase the device under test.\n"
|
" Erase the device under test. With no arguments, erases all of main\n"
|
||||||
|
" memory. Specify arguments to perform a mass erase, or to erase\n"
|
||||||
|
" individual segments.\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "step",
|
.name = "step",
|
||||||
|
|
29
devcmd.c
29
devcmd.c
|
@ -138,11 +138,38 @@ int cmd_reset(char **arg)
|
||||||
|
|
||||||
int cmd_erase(char **arg)
|
int cmd_erase(char **arg)
|
||||||
{
|
{
|
||||||
|
const char *type_text = get_arg(arg);
|
||||||
|
const char *seg_text = get_arg(arg);
|
||||||
|
device_erase_type_t type = DEVICE_ERASE_MAIN;
|
||||||
|
address_t segment = 0;
|
||||||
|
|
||||||
|
if (seg_text && expr_eval(stab_default, seg_text, &segment) < 0) {
|
||||||
|
printc_err("erase: invalid expression: %s\n", seg_text);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type_text) {
|
||||||
|
if (!strcasecmp(type_text, "all")) {
|
||||||
|
type = DEVICE_ERASE_ALL;
|
||||||
|
} else if (!strcasecmp(type_text, "segment")) {
|
||||||
|
type = DEVICE_ERASE_SEGMENT;
|
||||||
|
if (!seg_text) {
|
||||||
|
printc_err("erase: expected segment "
|
||||||
|
"address\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printc_err("erase: unknown erase type: %s\n",
|
||||||
|
type_text);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (device_default->ctl(device_default, DEVICE_CTL_HALT) < 0)
|
if (device_default->ctl(device_default, DEVICE_CTL_HALT) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
printc("Erasing...\n");
|
printc("Erasing...\n");
|
||||||
return device_default->erase(device_default, DEVICE_ERASE_MAIN, 0);
|
return device_default->erase(device_default, type, segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_step(char **arg)
|
int cmd_step(char **arg)
|
||||||
|
|
11
mspdebug.man
11
mspdebug.man
|
@ -168,9 +168,14 @@ length (64 bytes) is disassembled and shown.
|
||||||
|
|
||||||
If symbols are available, then all addresses used as operands are
|
If symbols are available, then all addresses used as operands are
|
||||||
translated into \fIsymbol\fR+\fIoffset\fR form.
|
translated into \fIsymbol\fR+\fIoffset\fR form.
|
||||||
.IP "\fBerase\fR"
|
.IP "\fBerase\fR [\fIall\fR|\fIsegment\fR] [\fIaddress\fR]"
|
||||||
Erase the device under test. All code memory is erased (but not
|
Erase the device under test. With no arguments, all code memory is erased
|
||||||
information or boot memory).
|
(but not information or boot memory). With the argument "all", a mass
|
||||||
|
erase is performed (the results may depend on the state of the LOCKA
|
||||||
|
bit in the flash memory controller).
|
||||||
|
|
||||||
|
Specify "segment" and a memory address to erase an individual flash
|
||||||
|
segment.
|
||||||
.IP "\fBgdb\fR [\fIport\fR]"
|
.IP "\fBgdb\fR [\fIport\fR]"
|
||||||
Start a GDB remote stub, optionally specifying a TCP port to listen on.
|
Start a GDB remote stub, optionally specifying a TCP port to listen on.
|
||||||
If no port is given, the default port is 2000.
|
If no port is given, the default port is 2000.
|
||||||
|
|
2
sim.c
2
sim.c
|
@ -530,7 +530,7 @@ static int sim_erase(device_t dev_base, device_erase_type_t type,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEVICE_ERASE_ALL:
|
case DEVICE_ERASE_ALL:
|
||||||
memset(dev->memory + 0x1000, 0xff, 256);
|
memset(dev->memory, 0xff, MEM_SIZE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEVICE_ERASE_SEGMENT:
|
case DEVICE_ERASE_SEGMENT:
|
||||||
|
|
Loading…
Reference in New Issue