- added synchronous wait/resume patch. Thanks Øyvind Harboe
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sat, 9 Feb 2008 11:44:17 +0000 (11:44 +0000)
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sat, 9 Feb 2008 11:44:17 +0000 (11:44 +0000)
- updated docs for halt and wait_halt and resume commands

git-svn-id: svn://svn.berlios.de/openocd/trunk@285 b42882b7-edfa-0310-969c-e2dbd0fdcd60

doc/openocd.texi
src/target/target.c

index 19736ace3042fef4b6a80eb4c6a1f6a6f49cdc7a..7c8bc0c6c0a4ab8fd092fe2d587ab76318663c24 100644 (file)
@@ -651,14 +651,23 @@ Poll the target for its current state. If the target is in debug mode, architect
 specific information about the current state are printed. An optional parameter
 allows continuous polling to be enabled and disabled.
 
 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
 @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.
 
 @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
 
 @item @b{step} [@var{address}]
 @cindex step
index 114832783b4427960d450df0089ae6507f53b320..bafbfb0f6d9a55b9cea7bc7ae0f0e749b1227c95 100644 (file)
@@ -342,7 +342,7 @@ int target_process_reset(struct command_context_s *cmd_ctx)
                gettimeofday(&now, NULL);
                
                target_call_timer_callbacks();
                gettimeofday(&now, NULL);
                
                target_call_timer_callbacks();
-       
+               
                target = targets;
                while (target)
                {
                target = targets;
                while (target)
                {
@@ -370,8 +370,11 @@ int target_process_reset(struct command_context_s *cmd_ctx)
        done:
        
        
        done:
        
        
+       /* We want any events to be processed before the prompt */
+       target_call_timer_callbacks();
+       
        return retval;
        return retval;
-}      
+}
 
 int target_init(struct command_context_s *cmd_ctx)
 {
 
 int target_init(struct command_context_s *cmd_ctx)
 {
@@ -1391,6 +1394,8 @@ int handle_reg_command(struct command_context_s *cmd_ctx, char *cmd, char **args
        return ERROR_OK;
 }
 
        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_poll_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
        target_t *target = get_current_target(cmd_ctx);
@@ -1428,38 +1433,46 @@ int handle_poll_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
 
 int handle_wait_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
 
 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;
 
                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;
                }
        }
 
                        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;
                }
                        break;
                }
-               target_call_timer_callbacks();
                
                gettimeofday(&now, NULL);
                
                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;
                }
        }
                        break;
                }
        }
@@ -1492,8 +1505,7 @@ int handle_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
                }
        }
        
                }
        }
        
-       return ERROR_OK;
-
+       return handle_wait_halt_command(cmd_ctx, cmd, args, argc);
 }
 
 /* what to do on daemon startup */
 }
 
 /* what to do on daemon startup */
@@ -1622,7 +1634,7 @@ int handle_resume_command(struct command_context_s *cmd_ctx, char *cmd, char **a
                }
        }
 
                }
        }
 
-       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)
 }
 
 int handle_step_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
@@ -1835,11 +1847,12 @@ int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char
        for (i = 0; i < image.num_sections; i++)
        {
                buffer = malloc(image.sections[i].size);
        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;
                }
                {
                        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);
                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);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)