target: Implemented a global target mass erase command
This commit is contained in:
parent
30e2106e40
commit
c35f65c6c0
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "general.h"
|
||||
#include "target_internal.h"
|
||||
#include "gdb_packet.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
@ -31,6 +32,12 @@ target *target_list = NULL;
|
|||
static int target_flash_write_buffered(struct target_flash *f,
|
||||
target_addr dest, const void *src, size_t len);
|
||||
static int target_flash_done_buffered(struct target_flash *f);
|
||||
static bool target_cmd_mass_erase(target *t, int argc, const char **argv);
|
||||
|
||||
const struct command_s target_cmd_list[] = {
|
||||
{"erase_mass", (cmd_handler)target_cmd_mass_erase, "Erase whole device Flash"},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
static bool nop_function(void)
|
||||
{
|
||||
|
@ -75,6 +82,7 @@ target *target_new(void)
|
|||
|
||||
t->target_storage = NULL;
|
||||
|
||||
target_add_commands(t, target_cmd_list, "Target");
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -510,6 +518,21 @@ int target_breakwatch_clear(target *t,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Target-specific commands */
|
||||
static bool target_cmd_mass_erase(target *const t, const int argc, const char **const argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
if (!t || !t->mass_erase) {
|
||||
gdb_out("Mass erase not implemented for target");
|
||||
return true;
|
||||
}
|
||||
gdb_out("Erasing device Flash: ");
|
||||
const bool result = t->mass_erase(t);
|
||||
gdb_out("done\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Accessor functions */
|
||||
size_t target_regs_size(target *t)
|
||||
{
|
||||
|
|
|
@ -109,6 +109,9 @@ struct target_s {
|
|||
int (*breakwatch_clear)(target *t, struct breakwatch*);
|
||||
struct breakwatch *bw_list;
|
||||
|
||||
/* Recovery functions */
|
||||
bool (*mass_erase)(target *t);
|
||||
|
||||
/* target-defined options */
|
||||
unsigned target_options;
|
||||
uint16_t t_designer;
|
||||
|
|
Loading…
Reference in New Issue