#include "command.h"
#include "log.h"
#include "target.h"
+#include "time_support.h"
#include <string.h>
#include <unistd.h>
extern flash_driver_t cfi_flash;
extern flash_driver_t at91sam7_flash;
extern flash_driver_t str7x_flash;
+extern flash_driver_t str9x_flash;
flash_driver_t *flash_drivers[] =
{
&cfi_flash,
&at91sam7_flash,
&str7x_flash,
+ &str9x_flash,
NULL,
};
int last = strtoul(args[2], NULL, 0);
int retval;
flash_bank_t *p = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
+ struct timeval start, end, duration;
+
+ gettimeofday(&start, NULL);
+
if (!p)
{
command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
command_print(cmd_ctx, "unknown error");
}
}
+ else
+ {
+ gettimeofday(&end, NULL);
+ timeval_subtract(&duration, &end, &start);
+
+ command_print(cmd_ctx, "erased sectors %i through %i on flash bank %i in %is %ius", first, last, strtoul(args[0], 0, 0), duration.tv_sec, duration.tv_usec);
+ }
}
else
{
if ((retval = p->driver->write(p, buffer, offset, buf_cnt)) != ERROR_OK)
{
+ command_print(cmd_ctx, "failed writing file %s to flash bank %i at offset 0x%8.8x",
+ args[1], strtoul(args[0], NULL, 0), strtoul(args[2], NULL, 0));
switch (retval)
{
case ERROR_TARGET_NOT_HALTED:
command_print(cmd_ctx, "unknown error");
}
}
+ else
+ {
+ gettimeofday(&end, NULL);
+ timeval_subtract(&duration, &end, &start);
+
+ command_print(cmd_ctx, "wrote file %s to flash bank %i at offset 0x%8.8x in %is %ius", args[1], strtoul(args[0], NULL, 0), strtoul(args[2], NULL, 0), duration.tv_sec, duration.tv_usec);
+ }
+
free(buffer);
fclose(binary);
- gettimeofday(&end, NULL);
- timeval_subtract(&duration, &end, &start);
-
- command_print(cmd_ctx, "wrote file %s to flash bank %i at offset 0x%8.8x in %is %ius", args[1], strtoul(args[0], NULL, 0), strtoul(args[2], NULL, 0), duration.tv_sec, duration.tv_usec);
-
return ERROR_OK;
-
}