summaryrefslogtreecommitdiff
path: root/src/flash/nor/tcl.c
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-05-05 15:08:34 +0200
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-05-05 15:24:25 +0200
commit737c9b6258c6e68714ae264ff36126eb5d382d6a (patch)
tree508ba9ecd384a3f4d2fda13231d5fe53161e8c78 /src/flash/nor/tcl.c
parentf7e0f3c285e9b1578184da886792e02d253ea687 (diff)
downloadopenocd+libswd-737c9b6258c6e68714ae264ff36126eb5d382d6a.tar.gz
openocd+libswd-737c9b6258c6e68714ae264ff36126eb5d382d6a.tar.bz2
openocd+libswd-737c9b6258c6e68714ae264ff36126eb5d382d6a.tar.xz
openocd+libswd-737c9b6258c6e68714ae264ff36126eb5d382d6a.zip
flash: stop caching protection state
There are a million reasons why cached protection state might be stale: power cycling of target, reset, code executing on the target, etc. The "flash protect_check" command is now gone. This is *always* executed when running a "flash info". As a bonus for more a more robust approach, lots of code could be deleted. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/flash/nor/tcl.c')
-rw-r--r--src/flash/nor/tcl.c39
1 files changed, 5 insertions, 34 deletions
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index 947fd046..17c6e910 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -70,6 +70,11 @@ COMMAND_HANDLER(handle_flash_info_command)
if ((retval = p->driver->auto_probe(p)) != ERROR_OK)
return retval;
+ /* We must query the hardware to avoid printing stale information! */
+ retval = p->driver->protect_check(p);
+ if (retval != ERROR_OK)
+ return retval;
+
command_print(CMD_CTX,
"#%" PRIi32 " : %s at 0x%8.8" PRIx32 ", size 0x%8.8" PRIx32 ", buswidth %i, chipwidth %i",
i,
@@ -266,32 +271,6 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
return retval;
}
-COMMAND_HANDLER(handle_flash_protect_check_command)
-{
- if (CMD_ARGC != 1)
- return ERROR_COMMAND_SYNTAX_ERROR;
-
- struct flash_bank *p;
- int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &p);
- if (ERROR_OK != retval)
- return retval;
-
- if ((retval = p->driver->protect_check(p)) == ERROR_OK)
- {
- command_print(CMD_CTX, "successfully checked protect state");
- }
- else if (retval == ERROR_FLASH_OPERATION_FAILED)
- {
- command_print(CMD_CTX, "checking protection state failed (possibly unsupported) by flash #%s at 0x%8.8" PRIx32, CMD_ARGV[0], p->base);
- }
- else
- {
- command_print(CMD_CTX, "unknown error when checking protection state of flash bank '#%s' at 0x%8.8" PRIx32, CMD_ARGV[0], p->base);
- }
-
- return ERROR_OK;
-}
-
static int flash_check_sector_parameters(struct command_context *cmd_ctx,
uint32_t first, uint32_t last, uint32_t num_sectors)
{
@@ -707,14 +686,6 @@ static const struct command_registration flash_exec_command_handlers[] = {
"flash bank.",
},
{
- .name = "protect_check",
- .handler = handle_flash_protect_check_command,
- .mode = COMMAND_EXEC,
- .usage = "bank_id",
- .help = "Check protection state of all blocks in a "
- "flash bank.",
- },
- {
.name = "erase_sector",
.handler = handle_flash_erase_command,
.mode = COMMAND_EXEC,