Address some issues that ICEpick JRC support turned up: - If the target is already enabled, don't re-enable it. (Likewise, don't re-disable if it's disabled.)
- Targets need to be examined after they are enabled, in the not-unusual case that they weren't yet examined. Else you can't for example tell them to "halt". Modify the target_examine() routine to accept a TAP parameter, with NULL indicating the current "all TAPs" behavior, and have the TAPENABLE logic use it to trigger (initial) examination of any targets on the TAP that was just enabled. - If the examine() fails, flag the TAP as not-enabled and report the error. And add a couple FIXME notes about sanity missing checks ... we shouldn't assume the TCL event handlers were bug-free, and there are a *LOT* of ways they could have gone wrong. --- src/jtag/tcl.c | 36 +++++++++++++++++++++++++++++++----- src/openocd.c | 2 +- src/target/target.c | 4 +++- src/target/target.h | 2 +- 4 files changed, 36 insertions(+), 8 deletions(-)
Address some issues that ICEpick JRC support turned up: - If the target is already enabled, don't re-enable it. (Likewise, don't re-disable if it's disabled.) - Targets need to be examined after they are enabled, in the not-unusual case that they weren't yet examined. Else you can't for example tell them to "halt". Modify the target_examine() routine to accept a TAP parameter, with NULL indicating the current "all TAPs" behavior, and have the TAPENABLE logic use it to trigger (initial) examination of any targets on the TAP that was just enabled. - If the examine() fails, flag the TAP as not-enabled and report the error. And add a couple FIXME notes about sanity missing checks ... we shouldn't assume the TCL event handlers were bug-free, and there are a *LOT* of ways they could have gone wrong. --- src/jtag/tcl.c | 36 +++++++++++++++++++++++++++++++----- src/openocd.c | 2 +- src/target/target.c | 4 +++- src/target/target.h | 2 +- 4 files changed, 36 insertions(+), 8 deletions(-) --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -588,19 +588,45 @@ static int jim_jtag_command( Jim_Interp if( t == NULL ){ return JIM_ERR; } - switch( n->value ){ + + e = (t->enabled == true); + switch (n->value) { case JTAG_CMD_TAPISENABLED: - e = t->enabled; break; case JTAG_CMD_TAPENABLE: + if (e) + break; jtag_tap_handle_event( t, JTAG_TAP_EVENT_ENABLE); - e = 1; - t->enabled = e; + t->enabled = true; + + /* FIXME add JTAG sanity checks here, like: + * - scan chain is *one* TAP longer + * - IR lengths are as expected + * - IDCODE for this is as expected + */ + + /* examine any targets on this TAP */ + if (target_examine(t) == ERROR_OK) + e = 1; + else { + t->enabled = false; + LOG_ERROR("couldn't enable TAP %s", + t->dotted_name); + } break; case JTAG_CMD_TAPDISABLE: + if (!e) + break; jtag_tap_handle_event( t, JTAG_TAP_EVENT_DISABLE); + t->enabled = false; + + /* FIXME add JTAG sanity checks here, like: + * - scan chain is *one* TAP shorter + * - IR lengths are as expected + * - IDCODEs are as expected + */ + e = 0; - t->enabled = e; break; } Jim_SetResult( goi.interp, Jim_NewIntObj( goi.interp, e ) ); --- a/src/openocd.c +++ b/src/openocd.c @@ -140,7 +140,7 @@ static int handle_init_command(struct co if (jtag_init(cmd_ctx) == ERROR_OK) { LOG_DEBUG("jtag init complete"); - if (target_examine() == ERROR_OK) + if (target_examine(NULL) == ERROR_OK) { LOG_DEBUG("jtag examine complete"); } --- a/src/target/target.c +++ b/src/target/target.c @@ -483,13 +483,15 @@ int target_examine_one(struct target_s * * * XScale */ -int target_examine(void) +int target_examine(jtag_tap_t *tap) { int retval = ERROR_OK; target_t *target; for (target = all_targets; target; target = target->next) { + if (tap && target->tap != tap) + continue; if (!target->tap->enabled) continue; if ((retval = target_examine_one(target)) != ERROR_OK) --- a/src/target/target.h +++ b/src/target/target.h @@ -222,7 +222,7 @@ typedef struct target_timer_callback_s extern int target_register_commands(struct command_context_s *cmd_ctx); extern int target_register_user_commands(struct command_context_s *cmd_ctx); extern int target_init(struct command_context_s *cmd_ctx); -extern int target_examine(void); +extern int target_examine(jtag_tap_t *tap); extern int handle_target(void *priv); extern int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mode reset_mode);
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development