diff --git a/src/openocd.c b/src/openocd.c index 2c27fc421..66555e60b 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -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"); diff --git a/src/target/target.c b/src/target/target.c index 4708a1d62..bcd00a1fb 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -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); }