]> git.sur5r.net Git - openocd/commitdiff
wait 500ms for target to halt upon connect.
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 24 Jul 2008 06:07:55 +0000 (06:07 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 24 Jul 2008 06:07:55 +0000 (06:07 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@865 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/server/gdb_server.c
src/target/target.c
src/target/target.h

index cea5ad0db0046e8e4086dc66f84a6760e378ef2c..bbcff58c58b381b95ec350cfa08ade2595e05658 100644 (file)
@@ -509,6 +509,7 @@ int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
                                my_checksum += character & 0xff;
                                buffer[count++] = character & 0xff;
                        }
+
                }
 
                *len = count;
@@ -678,6 +679,12 @@ int gdb_new_connection(connection_t *connection)
         * connect. 
         */
        target_halt(gdb_service->target);
+       /* FIX!!!! could extended-remote work better here?
+        * 
+        *  wait a tiny bit for halted state or we just continue. The
+        * GDB register packet will then contain garbage 
+        */
+       target_wait_state(gdb_service->target, TARGET_HALTED, 500);
        
        /* remove the initial ACK from the incoming buffer */
        if ((retval = gdb_get_char(connection, &initial_ack)) != ERROR_OK)
index 506a5d78bd998d8d49ecef7605c4c6bc524f70b8..e1341a0a3e8ae42bb0ca2dfec515742a8bb5e3fe 100644 (file)
@@ -1683,7 +1683,6 @@ int handle_reg_command(struct command_context_s *cmd_ctx, char *cmd, char **args
        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)
 {
@@ -1729,11 +1728,12 @@ int handle_wait_halt_command(struct command_context_s *cmd_ctx, char *cmd, char
                        return ERROR_OK;
                }
        }
+       target_t *target = get_current_target(cmd_ctx);
 
-       return wait_state(cmd_ctx, cmd, TARGET_HALTED, ms); 
+       return target_wait_state(target, TARGET_HALTED, ms); 
 }
 
-static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_state state, int ms)
+int target_wait_state(target_t *target, enum target_state state, int ms)
 {
        int retval;
        struct timeval timeout, now;
@@ -1741,7 +1741,6 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
        gettimeofday(&timeout, NULL);
        timeval_add_time(&timeout, 0, ms * 1000);
        
-       target_t *target = get_current_target(cmd_ctx);
        for (;;)
        {
                if ((retval=target_poll(target))!=ERROR_OK)
@@ -1754,7 +1753,7 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
                if (once)
                {
                        once=0;
-                       command_print(cmd_ctx, "waiting for target %s...", target_state_strings[state]);
+                       LOG_USER("waiting for target %s...", target_state_strings[state]);
                }
                
                gettimeofday(&now, NULL);
index f1c61e3bf33ea0c628f58ed4528e6d197846d1be..05dbbb91cf3674e1dd19f5ecd8e6e1db063190fe 100644 (file)
@@ -280,6 +280,7 @@ extern int target_write_buffer(struct target_s *target, u32 address, u32 size, u
 extern int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer);
 extern int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32* crc);
 extern int target_blank_check_memory(struct target_s *target, u32 address, u32 size, u32* blank);
+extern int target_wait_state(target_t *target, enum target_state state, int ms);
 
 /* DANGER!!!!!
  *