if ((retval = target->type->resume(target, current, address, handle_breakpoints, debug_execution)) != ERROR_OK)
return retval;
- /* Invalidate any cached protect/erase/... flash status, since
- * almost all targets will now be able modify the flash by
- * themselves. We want flash drivers and infrastructure to
- * be able to rely on (non-invalidated) cached state.
- *
- * For now we require that algorithms provided by OpenOCD are
- * used only by code which properly maintains that cached state.
- * state
- *
- * REVISIT do the same for NAND ; maybe other flash flavors too...
- */
- if (!target->running_alg)
- nor_resume(target);
return retval;
}
if (CMD_ARGC == 1)
{
- unsigned wait;
- retval = parse_uint(CMD_ARGV[0], &wait);
+ unsigned wait_local;
+ retval = parse_uint(CMD_ARGV[0], &wait_local);
if (ERROR_OK != retval)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (!wait)
+ if (!wait_local)
return ERROR_OK;
}
{
current = chunk_size;
}
- int retval = fn(target, address + x * data_size, data_size, current, target_buf);
+ retval = fn(target, address + x * data_size, data_size, current, target_buf);
if (retval != ERROR_OK)
{
break;
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK))
{
command_print(CMD_CTX, "downloaded %" PRIu32 " bytes "
- "in %fs (%0.3f kb/s)", image_size,
+ "in %fs (%0.3f KiB/s)", image_size,
duration_elapsed(&bench), duration_kbps(&bench, image_size));
}
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK))
{
command_print(CMD_CTX,
- "dumped %ld bytes in %fs (%0.3f kb/s)", (long)fileio.size,
+ "dumped %ld bytes in %fs (%0.3f KiB/s)", (long)fileio.size,
duration_elapsed(&bench), duration_kbps(&bench, fileio.size));
}
}
image_size = 0x0;
+ int diffs = 0;
retval = ERROR_OK;
for (i = 0; i < image.num_sections; i++)
{
/* failed crc checksum, fall back to a binary compare */
uint8_t *data;
- command_print(CMD_CTX, "checksum mismatch - attempting binary compare");
+ if (diffs == 0)
+ {
+ LOG_ERROR("checksum mismatch - attempting binary compare");
+ }
data = (uint8_t*)malloc(buf_cnt);
if (data[t] != buffer[t])
{
command_print(CMD_CTX,
- "Verify operation failed address 0x%08x. Was 0x%02x instead of 0x%02x\n",
+ "diff %d address 0x%08x. Was 0x%02x instead of 0x%02x",
+ diffs,
(unsigned)(t + image.sections[i].base_address),
data[t],
buffer[t]);
- free(data);
- free(buffer);
- retval = ERROR_FAIL;
- goto done;
- }
- if ((t%16384) == 0)
- {
- keep_alive();
+ if (diffs++ >= 127)
+ {
+ command_print(CMD_CTX, "More than 128 errors, the rest are not printed.");
+ free(data);
+ free(buffer);
+ goto done;
+ }
}
+ keep_alive();
}
}
-
free(data);
}
} else
image_size += buf_cnt;
}
done:
+ if (diffs > 0)
+ {
+ retval = ERROR_FAIL;
+ }
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK))
{
command_print(CMD_CTX, "verified %" PRIu32 " bytes "
- "in %fs (%0.3f kb/s)", image_size,
+ "in %fs (%0.3f KiB/s)", image_size,
duration_elapsed(&bench), duration_kbps(&bench, image_size));
}
long long a = address-min;
long long b = length-1;
long long c = addressSpace-1;
- int index = (a*b)/c; /* danger!!!! int32 overflows */
- buckets[index]++;
+ int index_t = (a*b)/c; /* danger!!!! int32 overflows */
+ buckets[index_t]++;
}
/* append binary memory gmon.out &profile_hist_hdr ((char*)&profile_hist_hdr + sizeof(struct gmon_hist_hdr)) */
struct command_context *context;
struct target *target;
- context = Jim_GetAssocData(interp, "context");
- if (context == NULL)
- {
- LOG_ERROR("mem2array: no command context");
- return JIM_ERR;
- }
+ context = current_command_context(interp);
+ assert (context != NULL);
+
target = get_current_target(context);
if (target == NULL)
{
struct command_context *context;
struct target *target;
- context = Jim_GetAssocData(interp, "context");
- if (context == NULL) {
- LOG_ERROR("array2mem: no command context");
- return JIM_ERR;
- }
+ context = current_command_context(interp);
+ assert (context != NULL);
+
target = get_current_target(context);
if (target == NULL) {
LOG_ERROR("array2mem: no current target");
break;
case TCFG_CHAIN_POSITION:
if (goi->isconfigure) {
- Jim_Obj *o;
+ Jim_Obj *o_t;
struct jtag_tap *tap;
target_free_all_working_areas(target);
- e = Jim_GetOpt_Obj(goi, &o);
+ e = Jim_GetOpt_Obj(goi, &o_t);
if (e != JIM_OK) {
return e;
}
- tap = jtag_tap_by_jim_obj(goi->interp, o);
+ tap = jtag_tap_by_jim_obj(goi->interp, o_t);
if (tap == NULL) {
return JIM_ERR;
}
Jim_GetOptInfo goi;
Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
- /* danger! goi.argc will be modified below! */
- argc = goi.argc;
-
- if (argc != 2 && argc != 3)
+ if (goi.argc < 2 || goi.argc > 4)
{
Jim_SetResult_sprintf(goi.interp,
- "usage: %s <address> <data> [<count>]", cmd_name);
+ "usage: %s [phys] <address> <data> [<count>]", cmd_name);
return JIM_ERR;
}
+ target_write_fn fn;
+ fn = target_write_memory_fast;
+
+ int e;
+ if (strcmp(Jim_GetString(argv[1], NULL), "phys") == 0)
+ {
+ /* consume it */
+ struct Jim_Obj *obj;
+ e = Jim_GetOpt_Obj(&goi, &obj);
+ if (e != JIM_OK)
+ return e;
+
+ fn = target_write_phys_memory;
+ }
jim_wide a;
- int e = Jim_GetOpt_Wide(&goi, &a);
+ e = Jim_GetOpt_Wide(&goi, &a);
if (e != JIM_OK)
return e;
return e;
jim_wide c = 1;
- if (argc == 3)
+ if (goi.argc == 1)
{
e = Jim_GetOpt_Wide(&goi, &c);
if (e != JIM_OK)
return e;
}
+ /* all args must be consumed */
+ if (goi.argc != 0)
+ {
+ return JIM_ERR;
+ }
+
struct target *target = Jim_CmdPrivData(goi.interp);
unsigned data_size;
if (strcasecmp(cmd_name, "mww") == 0) {
return JIM_ERR;
}
- return (target_fill_mem(target, a, target_write_memory_fast, data_size, b, c) == ERROR_OK) ? JIM_OK : JIM_ERR;
+ return (target_fill_mem(target, a, fn, data_size, b, c) == ERROR_OK) ? JIM_OK : JIM_ERR;
}
static int jim_target_md(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Jim_GetOptInfo goi;
Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
- /* danger! goi.argc will be modified below! */
- argc = goi.argc;
-
- if ((argc != 1) && (argc != 2))
+ if ((goi.argc < 1) || (goi.argc > 3))
{
Jim_SetResult_sprintf(goi.interp,
- "usage: %s <address> [<count>]", cmd_name);
+ "usage: %s [phys] <address> [<count>]", cmd_name);
return JIM_ERR;
}
+ int (*fn)(struct target *target,
+ uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
+ fn=target_read_memory;
+
+ int e;
+ if (strcmp(Jim_GetString(argv[1], NULL), "phys") == 0)
+ {
+ /* consume it */
+ struct Jim_Obj *obj;
+ e = Jim_GetOpt_Obj(&goi, &obj);
+ if (e != JIM_OK)
+ return e;
+
+ fn=target_read_phys_memory;
+ }
+
jim_wide a;
- int e = Jim_GetOpt_Wide(&goi, &a);
+ e = Jim_GetOpt_Wide(&goi, &a);
if (e != JIM_OK) {
return JIM_ERR;
}
jim_wide c;
- if (argc == 2) {
+ if (goi.argc == 1) {
e = Jim_GetOpt_Wide(&goi, &c);
if (e != JIM_OK) {
return JIM_ERR;
} else {
c = 1;
}
+
+ /* all args must be consumed */
+ if (goi.argc != 0)
+ {
+ return JIM_ERR;
+ }
+
jim_wide b = 1; /* shut up gcc */
if (strcasecmp(cmd_name, "mdw") == 0)
b = 4;
if (y > 16) {
y = 16;
}
- e = target_read_memory(target, a, b, y / b, target_buf);
+ e = fn(target, a, b, y / b, target_buf);
if (e != ERROR_OK) {
Jim_SetResult_sprintf(interp, "error reading target @ 0x%08lx", (int)(a));
return JIM_ERR;
*/
static int jim_target_event_list(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
- struct command_context *cmd_ctx = Jim_GetAssocData(interp, "context");
+ struct command_context *cmd_ctx = current_command_context(interp);
+ assert (cmd_ctx != NULL);
+
struct target *target = Jim_CmdPrivData(interp);
struct target_event_action *teap = target->event_action;
command_print(cmd_ctx, "Event actions for target (%d) %s\n",
struct target *target;
struct command_context *cmd_ctx;
- cmd_ctx = Jim_GetAssocData(goi->interp, "context");
+ cmd_ctx = current_command_context(goi->interp);
+ assert (cmd_ctx != NULL);
+
if (goi->argc < 3) {
Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ?type? ..options...");
return JIM_ERR;
Jim_WrongNumArgs(interp, 1, argv, "Too many parameters");
return JIM_ERR;
}
- struct command_context *cmd_ctx = Jim_GetAssocData(interp, "context");
+ struct command_context *cmd_ctx = current_command_context(interp);
+ assert (cmd_ctx != NULL);
+
Jim_SetResultString(interp, get_current_target(cmd_ctx)->cmd_name, -1);
return JIM_OK;
}
if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK))
{
command_print(CMD_CTX, "Loaded %" PRIu32 " bytes "
- "in %fs (%0.3f kb/s)", image_size,
+ "in %fs (%0.3f KiB/s)", image_size,
duration_elapsed(&bench), duration_kbps(&bench, image_size));
command_print(CMD_CTX,