From a0647227439434c4a71470e336ec8715d43d0501 Mon Sep 17 00:00:00 2001 From: oharboe Date: Wed, 9 Apr 2008 05:50:34 +0000 Subject: - added "init" command. "init" and "reset" at end of startup script is equivalent to daemon_startup(still supported). - print warning if srst and trst change state at the same time when srst_and_trst is seperate - reset now performs a trst, examines and validates the jtag chain before targets assert reset - if startup fails to examine and validate the jtag chain, try a reset before trying again git-svn-id: svn://svn.berlios.de/openocd/trunk@552 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/target/arm7_9_common.c | 27 +++++++++++++++++---------- src/target/target.c | 37 ++++--------------------------------- src/target/target.h | 13 +++++-------- src/target/target/lpc2148.cfg | 4 ++++ 4 files changed, 30 insertions(+), 51 deletions(-) (limited to 'src/target') diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index d77f2000..106b95db 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -755,6 +755,14 @@ int arm7_9_assert_reset(target_t *target) if ((target->reset_mode == RESET_HALT) || (target->reset_mode == RESET_INIT)) { + reg_t *dbg_ctrl = &arm7_9->eice_cache->reg_list[EICE_DBG_CTRL]; + + /* program EmbeddedICE Debug Control Register to deassert DBGRQ + * i.e. resume. + */ + buf_set_u32(dbg_ctrl->value, EICE_DBG_CONTROL_DBGRQ, 1, 0); + embeddedice_store_reg(dbg_ctrl); + /* * Some targets do not support communication while SRST is asserted. We need to * set up the reset vector catch here. @@ -777,16 +785,6 @@ int arm7_9_assert_reset(target_t *target) } } - /* we can't know what state the target is in as we might e.g. - * be resetting after a power dropout, so we need to issue a tms/srst - */ - - /* assert SRST and TRST */ - /* system would get ouf sync if we didn't reset test-logic, too */ - jtag_add_reset(1, 1); - - jtag_add_sleep(5000); - /* here we should issue a srst only, but we may have to assert trst as well */ if (jtag_reset_config & RESET_SRST_PULLS_TRST) { @@ -965,6 +963,15 @@ int arm7_9_halt(target_t *target) LOG_ERROR("can't request a halt while in reset if nSRST pulls nTRST"); return ERROR_TARGET_FAILURE; } + else + { + /* we came here in a reset_halt or reset_init sequence + * debug entry was already prepared in arm7_9_prepare_reset_halt() + */ + target->debug_reason = DBG_REASON_DBGRQ; + + return ERROR_OK; + } } if (arm7_9->use_dbgrq) diff --git a/src/target/target.c b/src/target/target.c index bfe0f14a..ce411b45 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -51,7 +51,6 @@ int cli_target_callback_event_handler(struct target_s *target, enum target_event int handle_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_daemon_startup_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_target_script_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); @@ -132,8 +131,6 @@ char *target_endianess_strings[] = "little endian", }; -enum daemon_startup_mode startup_mode = DAEMON_ATTACH; - static int target_continous_poll = 1; /* read a u32 from a buffer in target memory endianness */ @@ -264,6 +261,10 @@ int target_process_reset(struct command_context_s *cmd_ctx) jtag->speed(jtag_speed); + if ((retval = jtag_init_reset(cmd_ctx)) != ERROR_OK) + return retval; + + /* prepare reset_halt where necessary */ target = targets; while (target) @@ -460,14 +461,6 @@ int target_init(struct command_context_s *cmd_ctx) return ERROR_OK; } -int target_init_reset(struct command_context_s *cmd_ctx) -{ - if (startup_mode == DAEMON_RESET) - target_process_reset(cmd_ctx); - - return ERROR_OK; -} - int target_register_event_callback(int (*callback)(struct target_s *target, enum target_event event, void *priv), void *priv) { target_event_callback_t **callbacks_p = &target_event_callbacks; @@ -801,7 +794,6 @@ int target_register_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, NULL, "target", handle_target_command, COMMAND_CONFIG, "target [reset_init default - DEPRECATED] [cpu type specifc args]"); register_command(cmd_ctx, NULL, "targets", handle_targets_command, COMMAND_EXEC, NULL); - register_command(cmd_ctx, NULL, "daemon_startup", handle_daemon_startup_command, COMMAND_CONFIG, NULL); register_command(cmd_ctx, NULL, "target_script", handle_target_script_command, COMMAND_CONFIG, NULL); register_command(cmd_ctx, NULL, "run_and_halt_time", handle_run_and_halt_time_command, COMMAND_CONFIG, " "); register_command(cmd_ctx, NULL, "working_area", handle_working_area_command, COMMAND_ANY, "working_area
<'backup'|'nobackup'> [virtual address]"); @@ -1639,27 +1631,6 @@ int handle_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **arg return handle_wait_halt_command(cmd_ctx, cmd, args, argc); } -/* what to do on daemon startup */ -int handle_daemon_startup_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) -{ - if (argc == 1) - { - if (strcmp(args[0], "attach") == 0) - { - startup_mode = DAEMON_ATTACH; - return ERROR_OK; - } - else if (strcmp(args[0], "reset") == 0) - { - startup_mode = DAEMON_RESET; - return ERROR_OK; - } - } - - LOG_WARNING("invalid daemon_startup configuration directive: %s", args[0]); - return ERROR_OK; - -} int handle_soft_reset_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { diff --git a/src/target/target.h b/src/target/target.h index 6ce8fee9..d95c4aa7 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -54,14 +54,6 @@ enum target_state extern char *target_state_strings[]; -enum daemon_startup_mode -{ - DAEMON_ATTACH, /* simply attach to the target */ - DAEMON_RESET, /* reset target (behaviour defined by reset_mode */ -}; - -extern enum daemon_startup_mode startup_mode; - enum target_reset_mode { RESET_RUN = 0, /* reset and let target run */ @@ -130,6 +122,11 @@ typedef struct target_type_s * assert_reset() can therefore make no assumptions whatsoever about the * state of the target * + * Before assert_reset() for the target is invoked, a TRST/tms and + * chain validation is executed. TRST should not be asserted + * during target assert unless there is no way around it due to + * the way reset's are configured. + * */ int (*assert_reset)(struct target_s *target); int (*deassert_reset)(struct target_s *target); diff --git a/src/target/target/lpc2148.cfg b/src/target/target/lpc2148.cfg index c357662f..ddc8d443 100644 --- a/src/target/target/lpc2148.cfg +++ b/src/target/target/lpc2148.cfg @@ -5,6 +5,10 @@ jtag_ntrst_delay 200 #use combined on interfaces or targets that can't set TRST/SRST separately reset_config trst_and_srst srst_pulls_trst +#LPCs need reset pulled while RTCK is log. 0 to activate JTAG, power-on reset is not enough +jtag_reset 1 1 +jtag_reset 0 0 + #jtag scan chain #format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE) jtag_device 4 0x1 0xf 0xe -- cgit v1.2.3