X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fjtag%2Fcore.c;h=854236f3d15346d31b5d3bba24e89c4803ff34ea;hb=39b57471bfd92ef0d9a3aceb69f40c1335f5b62f;hp=6177c1dc824513bb0a16c205420cc02aba3ad4c6;hpb=e4de4251fe6e1fdefb4b10f4178bb7973248e0d2;p=openocd.git diff --git a/src/jtag/core.c b/src/jtag/core.c index 6177c1dc82..854236f3d1 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1,16 +1,16 @@ /*************************************************************************** - * Copyright (C) 2005 by Dominic Rath * - * Dominic.Rath@gmx.de * + * Copyright (C) 2009 Zachary T Welch * + * zw@superlucidity.net * * * - * Copyright (C) 2007,2008 Øyvind Harboe * + * Copyright (C) 2007,2008,2009 Øyvind Harboe * * oyvind.harboe@zylin.com * * * * Copyright (C) 2009 SoftPLC Corporation * * http://softplc.com * * dick@softplc.com * * * - * Copyright (C) 2009 Zachary T Welch * - * zw@superlucidity.net * + * Copyright (C) 2005 by Dominic Rath * + * Dominic.Rath@gmx.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -61,8 +61,8 @@ static int jtag_error = ERROR_OK; static const char *jtag_event_strings[] = { [JTAG_TRST_ASSERTED] = "TAP reset", + [JTAG_TAP_EVENT_SETUP] = "TAP setup", [JTAG_TAP_EVENT_ENABLE] = "TAP enabled", - [JTAG_TAP_EVENT_POST_RESET] = "TAP post reset", [JTAG_TAP_EVENT_DISABLE] = "TAP disabled", }; @@ -489,7 +489,7 @@ void jtag_add_tlr(void) /* NOTE: order here matches TRST path in jtag_add_reset() */ jtag_call_event_callbacks(JTAG_TRST_ASSERTED); - jtag_notify_reset(); + jtag_notify_event(JTAG_TRST_ASSERTED); } void jtag_add_pathmove(int num_states, const tap_state_t *path) @@ -704,7 +704,7 @@ void jtag_add_reset(int req_tlr_or_trst, int req_srst) * sequence must match jtag_add_tlr(). */ jtag_call_event_callbacks(JTAG_TRST_ASSERTED); - jtag_notify_reset(); + jtag_notify_event(JTAG_TRST_ASSERTED); } } } @@ -1068,6 +1068,7 @@ static int jtag_validate_ircapture(void) int total_ir_length = 0; uint8_t *ir_test = NULL; scan_field_t field; + int val; int chain_pos = 0; int retval; @@ -1100,7 +1101,7 @@ static int jtag_validate_ircapture(void) tap = NULL; chain_pos = 0; - int val; + for (;;) { tap = jtag_tap_next_enabled(tap); if (tap == NULL) { @@ -1111,17 +1112,18 @@ static int jtag_validate_ircapture(void) * REVISIT we might be able to verify some MSBs too, using * ircapture/irmask attributes. */ - val = buf_get_u32(ir_test, chain_pos, 2); - if (val != 1) { - char *cbuf = buf_to_str(ir_test, total_ir_length, 16); + val = buf_get_u32(ir_test, chain_pos, tap->ir_length); + if ((val & 0x3) != 1) { + LOG_ERROR("%s: IR capture error; saw 0x%0*x not 0x..1", + jtag_tap_name(tap), + (tap->ir_length + 7) / tap->ir_length, + val); - LOG_ERROR("%s: IR capture error; saw 0x%s not 0x..1", - jtag_tap_name(tap), cbuf); - - free(cbuf); retval = ERROR_JTAG_INIT_FAILED; goto done; } + LOG_DEBUG("%s: IR capture 0x%0*x", jtag_tap_name(tap), + (tap->ir_length + 7) / tap->ir_length, val); chain_pos += tap->ir_length; } @@ -1228,10 +1230,11 @@ int jtag_interface_init(struct command_context_s *cmd_ctx) return ERROR_OK; } -static int jtag_init_inner(struct command_context_s *cmd_ctx) +int jtag_init_inner(struct command_context_s *cmd_ctx) { jtag_tap_t *tap; int retval; + bool issue_setup = true; LOG_DEBUG("Init JTAG chain"); @@ -1249,13 +1252,21 @@ static int jtag_init_inner(struct command_context_s *cmd_ctx) if (jtag_examine_chain() != ERROR_OK) { LOG_ERROR("Trying to use configured scan chain anyway..."); + issue_setup = false; } if (jtag_validate_ircapture() != ERROR_OK) { LOG_WARNING("Errors during IR capture, continuing anyway..."); + issue_setup = false; } + if (issue_setup) + jtag_notify_event(JTAG_TAP_EVENT_SETUP); + else + LOG_WARNING("Bypassing JTAG setup events due to errors"); + + return ERROR_OK; } @@ -1323,11 +1334,11 @@ int jtag_init(struct command_context_s *cmd_ctx) int retval; if ((retval = jtag_interface_init(cmd_ctx)) != ERROR_OK) return retval; - if (jtag_init_inner(cmd_ctx) == ERROR_OK) - { - return ERROR_OK; - } - return jtag_init_reset(cmd_ctx); + + if (Jim_Eval_Named(interp, "jtag_init", __FILE__, __LINE__) != JIM_OK) + return ERROR_FAIL; + + return ERROR_OK; } unsigned jtag_get_speed_khz(void)