extern flash_driver_t ocl_flash;
flash_driver_t *flash_drivers[] = {
- &lpc2000_flash,
- &cfi_flash,
- &at91sam7_flash,
- &at91sam7_old_flash,
- &str7x_flash,
- &str9x_flash,
- &aduc702x_flash,
- &stellaris_flash,
- &str9xpec_flash,
- &stm32x_flash,
- &tms470_flash,
- &ecosflash_flash,
- &lpc288x_flash,
- &ocl_flash,
- NULL,
+ &lpc2000_flash,
+ &cfi_flash,
+ &at91sam7_flash,
+ &at91sam7_old_flash,
+ &str7x_flash,
+ &str9x_flash,
+ &aduc702x_flash,
+ &stellaris_flash,
+ &str9xpec_flash,
+ &stm32x_flash,
+ &tms470_flash,
+ &ecosflash_flash,
+ &lpc288x_flash,
+ &ocl_flash,
+ NULL,
};
-
-
flash_bank_t *flash_banks;
static command_t *flash_cmd;
"erase address range <address> <length>");
register_command(cmd_ctx, flash_cmd, "fillw", handle_flash_fill_command, COMMAND_EXEC,
- "fill with pattern <address> <word_pattern> <count>");
+ "fill with pattern (no autoerase) <address> <word_pattern> <count>");
register_command(cmd_ctx, flash_cmd, "fillh", handle_flash_fill_command, COMMAND_EXEC,
"fill with pattern <address> <halfword_pattern> <count>");
register_command(cmd_ctx, flash_cmd, "fillb", handle_flash_fill_command, COMMAND_EXEC,
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);
}
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);
duration_t duration;
char *duration_text;
- int retval;
+ int retval, retvaltemp;
if (argc < 1)
{
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)",
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;
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 );
+ flash_bank_t *bank;
+ bank = get_flash_bank_by_addr(target, address);
+ if(bank == NULL)
{
- 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)
- {
- err = ERROR_FAIL;
- break;
- }
- err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size);
- wrote += cur_size;
- }
- if (err!=ERROR_OK)
- break;
+ return ERROR_FAIL;
}
+ err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size);
+ if (err!=ERROR_OK)
+ return err;
+ wrote += cur_size;
+ }
+
+ if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ {
+ return retval;
}
- duration_stop_measure(&duration, &duration_text);
if(err == ERROR_OK)
{
duration_t duration;
char *duration_text;
- int retval;
+ int retval, retvaltemp;
flash_bank_t *p;
if (argc != 3)
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)",