specific information about the current state are printed. An optional parameter
allows continuous polling to be enabled and disabled.
-@item @b{halt}
+@item @b{halt} [@option{ms}]
@cindex halt
-Send a halt request to the target. The debugger signals the debug request,
-and waits for the target to enter debug mode.
+Send a halt request to the target and waits for it to halt for [@option{ms}].
+Default [@option{ms}] is 5 seconds if no arg given.
+Optional arg @option{ms} is a timeout in milliseconds. Using 0 as the [@option{ms}]
+will stop openocd from waiting.
+
+@item @b{wait_halt} [@option{ms}]
+@cindex wait_halt
+Wait for the target to enter debug mode. Optional [@option{ms}] is
+a timeout in milliseconds. Default [@option{ms}] is 5 seconds if no
+arg given.
@item @b{resume} [@var{address}]
@cindex resume
Resume the target at its current code position, or at an optional address.
+Openocd will wait 5 seconds for the target to resume.
@item @b{step} [@var{address}]
@cindex step
gettimeofday(&now, NULL);
target_call_timer_callbacks();
-
+
target = targets;
while (target)
{
done:
+ /* We want any events to be processed before the prompt */
+ target_call_timer_callbacks();
+
return retval;
-}
+}
int target_init(struct command_context_s *cmd_ctx)
{
return ERROR_OK;
}
+static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_state state, int ms);
+
int handle_poll_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
target_t *target = get_current_target(cmd_ctx);
int handle_wait_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- target_t *target = get_current_target(cmd_ctx);
- struct timeval timeout, now;
+ int ms = 5000;
- gettimeofday(&timeout, NULL);
- if (!argc)
- timeval_add_time(&timeout, 5, 0);
- else {
+ if (argc > 0)
+ {
char *end;
- timeval_add_time(&timeout, strtoul(args[0], &end, 0), 0);
- if (*end) {
- command_print(cmd_ctx, "usage: wait_halt [seconds]");
+ ms = strtoul(args[0], &end, 0) * 1000;
+ if (*end)
+ {
+ command_print(cmd_ctx, "usage: %s [seconds]", cmd);
return ERROR_OK;
}
}
- command_print(cmd_ctx, "waiting for target halted...");
+ return wait_state(cmd_ctx, cmd, TARGET_HALTED, ms);
+}
- while(target->type->poll(target))
+static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_state state, int ms)
+{
+ struct timeval timeout, now;
+
+ gettimeofday(&timeout, NULL);
+ timeval_add_time(&timeout, 0, ms * 1000);
+ command_print(cmd_ctx, "waiting for target %s...", target_state_strings[state]);
+
+ target_t *target = get_current_target(cmd_ctx);
+ while (target->type->poll(target))
{
- if (target->state == TARGET_HALTED)
+ target_call_timer_callbacks();
+ if (target->state == state)
{
- command_print(cmd_ctx, "target halted");
+ command_print(cmd_ctx, "target %s", target_state_strings[state]);
break;
}
- target_call_timer_callbacks();
gettimeofday(&now, NULL);
- if ((now.tv_sec >= timeout.tv_sec) && (now.tv_usec >= timeout.tv_usec))
+ if ((now.tv_sec > timeout.tv_sec) || ((now.tv_sec == timeout.tv_sec) && (now.tv_usec >= timeout.tv_usec)))
{
- command_print(cmd_ctx, "timed out while waiting for target halt");
- ERROR("timed out while waiting for target halt");
+ command_print(cmd_ctx, "timed out while waiting for target %s", target_state_strings[state]);
+ ERROR("timed out while waiting for target %s", target_state_strings[state]);
break;
}
}
}
}
- return ERROR_OK;
-
+ return handle_wait_halt_command(cmd_ctx, cmd, args, argc);
}
/* what to do on daemon startup */
}
}
- return ERROR_OK;
+ return wait_state(cmd_ctx, cmd, TARGET_RUNNING, 5000);
}
int handle_step_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
for (i = 0; i < image.num_sections; i++)
{
buffer = malloc(image.sections[i].size);
- if (buffer==NULL)
+ if (buffer == NULL)
{
command_print(cmd_ctx, "error allocating buffer for section (%d bytes)", image.sections[i].size);
break;
}
+
if ((retval = image_read_section(&image, i, 0x0, image.sections[i].size, buffer, &buf_cnt)) != ERROR_OK)
{
ERROR("image_read_section failed with error code: %i", retval);