]> git.sur5r.net Git - openocd/commitdiff
target: fix init_targets script handling
authorSpencer Oliver <spen@spen-soft.co.uk>
Wed, 23 Nov 2011 23:39:57 +0000 (23:39 +0000)
committerPeter Stuge <peter@stuge.se>
Wed, 23 Nov 2011 23:51:36 +0000 (23:51 +0000)
This fixes an issue when init is called before init_targets has been
executed.

Make sure init_targets is called before init.

Change-Id: Icd5bd4c2a8eea2e399d9de4e331a77560e9672ac
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/235
Tested-by: jenkins
Reviewed-by: Peter Stuge <peter@stuge.se>
src/openocd.c
src/target/target.c

index 2c27fc421465eefd26788c3c9c5d13653f02b124..66555e60b1420ac218993ebb2dd4f7f5b342cf10 100644 (file)
@@ -292,10 +292,6 @@ static int openocd_thread(int argc, char *argv[], struct command_context *cmd_ct
        if (ERROR_OK != ret)
                return EXIT_FAILURE;
 
-       ret = command_run_line(cmd_ctx, "init_targets");
-       if (ERROR_OK != ret)
-               ret = EXIT_FAILURE;
-
        if (init_at_startup)
        {
                ret = command_run_line(cmd_ctx, "init");
index 4708a1d626bb271a4a09826dfdc7cfcc29c21acc..bcd00a1fbe9959224c624ab24c614cf110803383 100644 (file)
@@ -1043,6 +1043,8 @@ static int target_init(struct command_context *cmd_ctx)
 
 COMMAND_HANDLER(handle_target_init_command)
 {
+       int retval;
+
        if (CMD_ARGC != 0)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
@@ -1054,6 +1056,10 @@ COMMAND_HANDLER(handle_target_init_command)
        }
        target_initialized = true;
 
+       retval = command_run_line(CMD_CTX, "init_targets");
+       if (ERROR_OK != retval)
+               return retval;
+
        LOG_DEBUG("Initializing targets...");
        return target_init(CMD_CTX);
 }