X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fflash%2Fflash.c;h=fb9fa698b0b72d25015e86b2139e42777b57f8c9;hb=3884c7505fc262921d618b5e6e19de32d0c44443;hp=a1b64ade898fed1af0cf8c2df98720faa9038e86;hpb=a8c2507dbf6ab7bcabb666b895f0042715ccfa4b;p=openocd.git
diff --git a/src/flash/flash.c b/src/flash/flash.c
index a1b64ade89..fb9fa698b0 100644
--- a/src/flash/flash.c
+++ b/src/flash/flash.c
@@ -67,9 +67,10 @@ flash_bank_t *get_flash_bank_by_addr(target_t *target, u32 addr);
extern flash_driver_t lpc2000_flash;
extern flash_driver_t cfi_flash;
extern flash_driver_t at91sam7_flash;
+extern flash_driver_t at91sam7_old_flash;
extern flash_driver_t str7x_flash;
extern flash_driver_t str9x_flash;
-extern flash_driver_t x7026_flash;
+extern flash_driver_t aduc702x_flash;
extern flash_driver_t stellaris_flash;
extern flash_driver_t str9xpec_flash;
extern flash_driver_t stm32x_flash;
@@ -78,14 +79,14 @@ extern flash_driver_t ecosflash_flash;
extern flash_driver_t lpc288x_flash;
extern flash_driver_t ocl_flash;
-flash_driver_t *flash_drivers[] =
-{
+flash_driver_t *flash_drivers[] = {
&lpc2000_flash,
&cfi_flash,
&at91sam7_flash,
+ &at91sam7_old_flash,
&str7x_flash,
&str9x_flash,
- &x7026_flash,
+ &aduc702x_flash,
&stellaris_flash,
&str9xpec_flash,
&stm32x_flash,
@@ -205,7 +206,7 @@ int flash_init_drivers(struct command_context_s *cmd_ctx)
"erase address range
");
register_command(cmd_ctx, flash_cmd, "fillw", handle_flash_fill_command, COMMAND_EXEC,
- "fill with pattern ");
+ "fill with pattern (no autoerase) ");
register_command(cmd_ctx, flash_cmd, "fillh", handle_flash_fill_command, COMMAND_EXEC,
"fill with pattern ");
register_command(cmd_ctx, flash_cmd, "fillb", handle_flash_fill_command, COMMAND_EXEC,
@@ -379,7 +380,7 @@ int handle_flash_info_command(struct command_context_s *cmd_ctx, char *cmd, char
else
protect_state = "protection state unknown";
- command_print(cmd_ctx, "\t#%i: 0x%8.8x (0x%x %ikB) %s",
+ command_print(cmd_ctx, "\t#%3i: 0x%8.8x (0x%x %ikB) %s",
j, p->sectors[j].offset, p->sectors[j].size, p->sectors[j].size>>10,
protect_state);
}
@@ -466,7 +467,7 @@ int handle_flash_erase_check_command(struct command_context_s *cmd_ctx, char *cm
else
erase_state = "erase state unknown";
- command_print(cmd_ctx, "\t#%i: 0x%8.8x (0x%x %ikB) %s",
+ command_print(cmd_ctx, "\t#%3i: 0x%8.8x (0x%x %ikB) %s",
j, p->sectors[j].offset, p->sectors[j].size, p->sectors[j].size>>10,
erase_state);
}
@@ -513,7 +514,10 @@ int handle_flash_erase_address_command(struct command_context_s *cmd_ctx, char *
if ((retval = flash_erase_address_range(target, address, length)) == ERROR_OK)
{
- duration_stop_measure(&duration, &duration_text);
+ if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ return retval;
+ }
command_print(cmd_ctx, "erased address 0x%8.8x length %i in %s", address, length, duration_text);
free(duration_text);
}
@@ -575,7 +579,10 @@ int handle_flash_erase_command(struct command_context_s *cmd_ctx, char *cmd, cha
if ((retval = flash_driver_erase(p, first, last)) == ERROR_OK)
{
- duration_stop_measure(&duration, &duration_text);
+ if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ return retval;
+ }
command_print(cmd_ctx, "erased sectors %i through %i on flash bank %i in %s", first, last, strtoul(args[0], 0, 0), duration_text);
free(duration_text);
@@ -638,7 +645,7 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm
duration_t duration;
char *duration_text;
- int retval;
+ int retval, retvaltemp;
if (argc < 1)
{
@@ -696,7 +703,11 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm
return retval;
}
- duration_stop_measure(&duration, &duration_text);
+ if ((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ image_close(&image);
+ return retvaltemp;
+ }
if (retval == ERROR_OK)
{
command_print(cmd_ctx, "wrote %u byte from file %s in %s (%f kb/s)",
@@ -712,7 +723,7 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm
int handle_flash_fill_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- int err = ERROR_OK;
+ int err = ERROR_OK, retval;
u32 address;
u32 pattern;
u32 count;
@@ -778,31 +789,30 @@ int handle_flash_fill_command(struct command_context_s *cmd_ctx, char *cmd, char
duration_start_measure(&duration);
- flash_set_dirty();
- err = flash_erase_address_range( target, address, count*wordsize );
- if (err == ERROR_OK)
+ for (wrote=0; wrote<(count*wordsize); wrote+=sizeof(chunk))
{
- for (wrote=0; wrote<(count*wordsize); wrote+=sizeof(chunk))
+ int cur_size = MIN( (count*wordsize - wrote) , 1024 );
+ if (err == ERROR_OK)
{
- int cur_size = MIN( (count*wordsize - wrote) , 1024 );
- if (err == ERROR_OK)
+ flash_bank_t *bank;
+ bank = get_flash_bank_by_addr(target, address);
+ if(bank == NULL)
{
- flash_bank_t *bank;
- bank = get_flash_bank_by_addr(target, address);
- if(bank == NULL)
- {
- err = ERROR_FAIL;
- break;
- }
- err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size);
- wrote += cur_size;
- }
- if (err!=ERROR_OK)
+ err = ERROR_FAIL;
break;
+ }
+ err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size);
+ wrote += cur_size;
}
+ if (err!=ERROR_OK)
+ break;
+ }
+
+ if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ return retval;
}
- duration_stop_measure(&duration, &duration_text);
if(err == ERROR_OK)
{
@@ -828,7 +838,7 @@ int handle_flash_write_bank_command(struct command_context_s *cmd_ctx, char *cmd
duration_t duration;
char *duration_text;
- int retval;
+ int retval, retvaltemp;
flash_bank_t *p;
if (argc != 3)
@@ -864,7 +874,11 @@ int handle_flash_write_bank_command(struct command_context_s *cmd_ctx, char *cmd
free(buffer);
buffer = NULL;
- duration_stop_measure(&duration, &duration_text);
+ if ((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ fileio_close(&fileio);
+ return retvaltemp;
+ }
if (retval!=ERROR_OK)
{
command_print(cmd_ctx, "wrote %"PRIi64" byte from file %s to flash bank %i at offset 0x%8.8x in %s (%f kb/s)",