flash/nor/tcl: Distinguish between sectors and blocks in status messages
Use the right word in flash protect command status messages based on whether the target bank defines num_prot_blocks. Minor message style tidy-up. Change-Id: I5f40fb5627422536ce737f242fbf80feafe7a1fc Signed-off-by: Dominik Peklo <dom.peklo@gmail.com> Reviewed-on: http://openocd.zylin.com/4573 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Christopher Head <chead@zaber.com>
This commit is contained in:
parent
e36c2f2da4
commit
3a5b2b66db
|
@ -288,24 +288,6 @@ COMMAND_HANDLER(handle_flash_erase_address_command)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int flash_check_sector_parameters(struct command_context *cmd_ctx,
|
|
||||||
uint32_t first, uint32_t last, uint32_t num_sectors)
|
|
||||||
{
|
|
||||||
if (!(first <= last)) {
|
|
||||||
command_print(cmd_ctx, "ERROR: "
|
|
||||||
"first sector must be <= last sector");
|
|
||||||
return ERROR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(last <= (num_sectors - 1))) {
|
|
||||||
command_print(cmd_ctx, "ERROR: last sector must be <= %" PRIu32,
|
|
||||||
num_sectors - 1);
|
|
||||||
return ERROR_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ERROR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
COMMAND_HANDLER(handle_flash_erase_command)
|
COMMAND_HANDLER(handle_flash_erase_command)
|
||||||
{
|
{
|
||||||
if (CMD_ARGC != 3)
|
if (CMD_ARGC != 3)
|
||||||
|
@ -327,9 +309,18 @@ COMMAND_HANDLER(handle_flash_erase_command)
|
||||||
else
|
else
|
||||||
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last);
|
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last);
|
||||||
|
|
||||||
retval = flash_check_sector_parameters(CMD_CTX, first, last, p->num_sectors);
|
if (!(first <= last)) {
|
||||||
if (retval != ERROR_OK)
|
command_print(CMD_CTX, "ERROR: "
|
||||||
return retval;
|
"first sector must be <= last");
|
||||||
|
return ERROR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(last <= (uint32_t)(p->num_sectors - 1))) {
|
||||||
|
command_print(CMD_CTX, "ERROR: "
|
||||||
|
"last sector must be <= %" PRIu32,
|
||||||
|
p->num_sectors - 1);
|
||||||
|
return ERROR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
struct duration bench;
|
struct duration bench;
|
||||||
duration_start(&bench);
|
duration_start(&bench);
|
||||||
|
@ -375,15 +366,28 @@ COMMAND_HANDLER(handle_flash_protect_command)
|
||||||
bool set;
|
bool set;
|
||||||
COMMAND_PARSE_ON_OFF(CMD_ARGV[3], set);
|
COMMAND_PARSE_ON_OFF(CMD_ARGV[3], set);
|
||||||
|
|
||||||
retval = flash_check_sector_parameters(CMD_CTX, first, last, num_blocks);
|
if (!(first <= last)) {
|
||||||
if (retval != ERROR_OK)
|
command_print(CMD_CTX, "ERROR: "
|
||||||
return retval;
|
"first %s must be <= last",
|
||||||
|
(p->num_prot_blocks) ? "block" : "sector");
|
||||||
|
return ERROR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(last <= (uint32_t)(num_blocks - 1))) {
|
||||||
|
command_print(CMD_CTX, "ERROR: "
|
||||||
|
"last %s must be <= %" PRIu32,
|
||||||
|
(p->num_prot_blocks) ? "block" : "sector",
|
||||||
|
num_blocks - 1);
|
||||||
|
return ERROR_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
retval = flash_driver_protect(p, set, first, last);
|
retval = flash_driver_protect(p, set, first, last);
|
||||||
if (retval == ERROR_OK) {
|
if (retval == ERROR_OK) {
|
||||||
command_print(CMD_CTX, "%s protection for sectors %" PRIu32
|
command_print(CMD_CTX, "%s protection for %s %" PRIu32
|
||||||
" through %" PRIu32 " on flash bank %d",
|
" through %" PRIu32 " on flash bank %d",
|
||||||
(set) ? "set" : "cleared", first, last, p->bank_number);
|
(set) ? "set" : "cleared",
|
||||||
|
(p->num_prot_blocks) ? "blocks" : "sectors",
|
||||||
|
first, last, p->bank_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
Loading…
Reference in New Issue