Merge branch 'master' of ssh://dbrownell@openocd.git.sourceforge.net/gitroot/openocd/openocd

This commit is contained in:
David Brownell 2009-11-06 15:01:46 -08:00
commit fb50efc6e7
3 changed files with 536 additions and 573 deletions

View File

@ -177,8 +177,9 @@ int flash_init_drivers(struct command_context_s *cmd_ctx)
{
register_jim(cmd_ctx, "ocd_flash_banks", jim_flash_banks, "return information about the flash banks");
if (flash_banks)
{
if (!flash_banks)
return ERROR_OK;
register_command(cmd_ctx, flash_cmd, "info", handle_flash_info_command, COMMAND_EXEC,
"print info about flash bank <num>");
register_command(cmd_ctx, flash_cmd, "probe", handle_flash_probe_command, COMMAND_EXEC,
@ -205,7 +206,6 @@ int flash_init_drivers(struct command_context_s *cmd_ctx)
"write_image [erase] [unlock] <file> [offset] [type]");
register_command(cmd_ctx, flash_cmd, "protect", handle_flash_protect_command, COMMAND_EXEC,
"set protection of sectors at <bank> <first> <last> <on | off>");
}
return ERROR_OK;
}
@ -292,8 +292,9 @@ static int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cm
for (i = 0; flash_drivers[i]; i++)
{
if (strcmp(args[0], flash_drivers[i]->name) == 0)
{
if (strcmp(args[0], flash_drivers[i]->name) != 0)
continue;
flash_bank_t *p, *c;
/* register flash specific commands */
@ -340,7 +341,6 @@ static int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cm
found = 1;
}
}
/* no matching flash driver found */
if (!found)
@ -367,8 +367,9 @@ static int handle_flash_info_command(struct command_context_s *cmd_ctx, char *cm
for (p = flash_banks; p; p = p->next, i++)
{
if (i == bank_nr)
{
if (i != bank_nr)
continue;
char buf[1024];
/* attempt auto probe */
@ -409,7 +410,6 @@ static int handle_flash_info_command(struct command_context_s *cmd_ctx, char *cm
if (retval != ERROR_OK)
LOG_ERROR("error retrieving flash info (%d)", retval);
}
}
return ERROR_OK;
}
@ -463,8 +463,6 @@ static int handle_flash_erase_check_command(struct command_context_s *cmd_ctx, c
if (ERROR_OK != retval)
return retval;
if (p)
{
int j;
if ((retval = p->driver->erase_check(p)) == ERROR_OK)
{
@ -495,7 +493,6 @@ static int handle_flash_erase_check_command(struct command_context_s *cmd_ctx, c
p->sectors[j].size >> 10,
erase_state);
}
}
return ERROR_OK;
}
@ -556,9 +553,6 @@ static int handle_flash_protect_check_command(struct command_context_s *cmd_ctx,
if (ERROR_OK != retval)
return retval;
if (p)
{
int retval;
if ((retval = p->driver->protect_check(p)) == ERROR_OK)
{
command_print(cmd_ctx, "successfully checked protect state");
@ -571,7 +565,6 @@ static int handle_flash_protect_check_command(struct command_context_s *cmd_ctx,
{
command_print(cmd_ctx, "unknown error when checking protection state of flash bank '#%s' at 0x%8.8" PRIx32, args[0], p->base);
}
}
return ERROR_OK;
}
@ -597,8 +590,9 @@ static int flash_check_sector_parameters(struct command_context_s *cmd_ctx,
static int handle_flash_erase_command(struct command_context_s *cmd_ctx,
char *cmd, char **args, int argc)
{
if (argc > 2)
{
if (argc != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t bank_nr;
uint32_t first;
uint32_t last;
@ -633,9 +627,6 @@ static int handle_flash_erase_command(struct command_context_s *cmd_ctx,
duration_text);
free(duration_text);
}
}
else
return ERROR_COMMAND_SYNTAX_ERROR;
return ERROR_OK;
}
@ -643,8 +634,9 @@ static int handle_flash_erase_command(struct command_context_s *cmd_ctx,
static int handle_flash_protect_command(struct command_context_s *cmd_ctx,
char *cmd, char **args, int argc)
{
if (argc > 3)
{
if (argc != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t bank_nr;
uint32_t first;
uint32_t last;
@ -680,9 +672,6 @@ static int handle_flash_protect_command(struct command_context_s *cmd_ctx,
(set) ? "set" : "cleared", (int) first,
(int) last, (int) bank_nr);
}
}
else
return ERROR_COMMAND_SYNTAX_ERROR;
return ERROR_OK;
}

View File

@ -1135,10 +1135,12 @@ static int handle_nand_info_command(struct command_context_s *cmd_ctx, char *cmd
break;
}
if (p)
{
if (p->device)
if (NULL == p->device)
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
return ERROR_OK;
}
if (first >= p->num_blocks)
first = p->num_blocks - 1;
@ -1174,12 +1176,6 @@ static int handle_nand_info_command(struct command_context_s *cmd_ctx, char *cmd
erase_state,
bad_state);
}
}
else
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
return ERROR_OK;
}
@ -1196,8 +1192,6 @@ static int handle_nand_probe_command(struct command_context_s *cmd_ctx, char *cm
if (ERROR_OK != retval)
return retval;
if (p)
{
if ((retval = nand_probe(p)) == ERROR_OK)
{
command_print(cmd_ctx, "NAND flash device '%s' found", p->device->name);
@ -1210,7 +1204,6 @@ static int handle_nand_probe_command(struct command_context_s *cmd_ctx, char *cm
{
command_print(cmd_ctx, "unknown error when probing NAND flash device");
}
}
return ERROR_OK;
}
@ -1228,8 +1221,6 @@ static int handle_nand_erase_command(struct command_context_s *cmd_ctx, char *cm
if (ERROR_OK != retval)
return retval;
if (p)
{
unsigned long offset;
unsigned long length;
@ -1269,7 +1260,6 @@ static int handle_nand_erase_command(struct command_context_s *cmd_ctx, char *cm
{
command_print(cmd_ctx, "unknown error when erasing NAND flash device");
}
}
return ERROR_OK;
}
@ -1353,8 +1343,6 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm
if (ERROR_OK != retval)
return retval;
if (p)
{
uint8_t *page = NULL;
uint32_t page_size = 0;
uint8_t *oob = NULL;
@ -1495,7 +1483,6 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm
args[1], args[0], offset, duration_text);
free(duration_text);
duration_text = NULL;
}
return ERROR_OK;
}
@ -1512,14 +1499,15 @@ static int handle_nand_dump_command(struct command_context_s *cmd_ctx, char *cmd
if (ERROR_OK != retval)
return retval;
if (p)
{
if (p->device)
if (NULL == p->device)
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
return ERROR_OK;
}
fileio_t fileio;
duration_t duration;
char *duration_text;
int retval;
uint8_t *page = NULL;
uint32_t page_size = 0;
@ -1612,12 +1600,6 @@ static int handle_nand_dump_command(struct command_context_s *cmd_ctx, char *cmd
command_print(cmd_ctx, "dumped %lld byte in %s", fileio.size, duration_text);
free(duration_text);
duration_text = NULL;
}
else
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
return ERROR_OK;
}
@ -1634,33 +1616,24 @@ static int handle_nand_raw_access_command(struct command_context_s *cmd_ctx, cha
if (ERROR_OK != retval)
return retval;
if (p)
{
if (p->device)
if (NULL == p->device)
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
return ERROR_OK;
}
if (argc == 2)
{
if (strcmp("enable", args[1]) == 0)
{
p->use_raw = 1;
}
else if (strcmp("disable", args[1]) == 0)
{
p->use_raw = 0;
}
else
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
}
command_print(cmd_ctx, "raw access is %s", (p->use_raw) ? "enabled" : "disabled");
}
else
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
const char *msg = p->use_raw ? "enabled" : "disabled";
command_print(cmd_ctx, "raw access is %s", msg);
return ERROR_OK;
}

View File

@ -2065,6 +2065,7 @@ int arm11_handle_vcr(struct command_context_s *cmd_ctx, char *cmd, char **args,
break;
case 1:
COMMAND_PARSE_NUMBER(u32, args[0], arm11_vcr);
break;
default:
return ERROR_COMMAND_SYNTAX_ERROR;
}