* 3: Pause-DR
* 4: Shift-IR
* 5: Pause-IR
+ *
+ * SD->SD and SI->SI have to be caught in interface specific code
*/
u8 tap_move[6][6] =
{
extern jtag_interface_t gw16012_interface;
#endif
+#if BUILD_PRESTO_LIBFTDI == 1 || BUILD_PRESTO_FTD2XX == 1
+ extern jtag_interface_t presto_interface;
+#endif
+
+#if BUILD_USBPROG == 1
+ extern jtag_interface_t usbprog_interface;
+#endif
+
jtag_interface_t *jtag_interfaces[] = {
#if BUILD_PARPORT == 1
&parport_interface,
#endif
#if BUILD_GW16012 == 1
&gw16012_interface,
+#endif
+#if BUILD_PRESTO_LIBFTDI == 1 || BUILD_PRESTO_FTD2XX == 1
+ &presto_interface,
+#endif
+#if BUILD_USBPROG == 1
+ &usbprog_interface,
#endif
NULL,
};
if (compare_failed)
{
- char *captured_char = buf_to_str(captured, (num_bits > 64) ? 64 : num_bits, 16);
- char *in_check_value_char = buf_to_str(cmd->fields[i].in_check_value, (num_bits > 64) ? 64 : num_bits, 16);
-
if (cmd->error_handler)
{
/* ask the error handler if once has been specified if this is a real problem */
*/
if (compare_failed)
{
+ char *captured_char = buf_to_str(captured, (num_bits > 64) ? 64 : num_bits, 16);
+ char *in_check_value_char = buf_to_str(cmd->fields[i].in_check_value, (num_bits > 64) ? 64 : num_bits, 16);
+
if (cmd->fields[i].in_check_mask)
{
char *in_check_mask_char;
{
WARNING("value captured during scan didn't pass the requested check: captured: 0x%s check_value: 0x%s", captured_char, in_check_value_char);
}
+
+ free(captured_char);
+ free(in_check_value_char);
}
- free(captured_char);
- free(in_check_value_char);
}
}
free(captured);
if ((zero_check == 0x00) || (one_check == 0xff))
{
ERROR("JTAG communication failure, check connection, JTAG interface, target power etc.");
- exit(-1);
+ return ERROR_JTAG_INIT_FAILED;
}
for (bit_count = 0; bit_count < (JTAG_MAX_CHAIN_SIZE * 32) - 31;)
part = (idcode & 0xffff000) >> 12;
version = (idcode & 0xf0000000) >> 28;
- DEBUG("JTAG device found: 0x%8.8x (Manufacturer: 0x%3.3x, Part: 0x%4.4x, Version: 0x%1.1x",
+ INFO("JTAG device found: 0x%8.8x (Manufacturer: 0x%3.3x, Part: 0x%4.4x, Version: 0x%1.1x)",
idcode, manufacturer, part, version);
bit_count += 32;
ERROR("number of discovered devices in JTAG chain (%i) doesn't match configuration (%i)",
device_count, jtag_num_devices);
ERROR("check the config file and ensure proper JTAG communication (connections, speed, ...)");
- exit(-1);
+ return ERROR_JTAG_INIT_FAILED;
}
return ERROR_OK;
char *cbuf = buf_to_str(ir_test, total_ir_length, 16);
ERROR("Error validating JTAG scan chain, IR mismatch, scan returned 0x%s", cbuf);
free(cbuf);
- exit(-1);
+ return ERROR_JTAG_INIT_FAILED;
}
chain_pos += device->ir_length;
device = device->next;
char *cbuf = buf_to_str(ir_test, total_ir_length, 16);
ERROR("Error validating JTAG scan chain, IR mismatch, scan returned 0x%s", cbuf);
free(cbuf);
- exit(-1);
+ return ERROR_JTAG_INIT_FAILED;
}
free(ir_test);
int jtag_init(struct command_context_s *cmd_ctx)
{
- int i;
+ int i, validate_tries = 0;
DEBUG("-");
jtag_add_statemove(TAP_TLR);
jtag_execute_queue();
+
+ /* examine chain first, as this could discover the real chain layout */
+ if (jtag_examine_chain() != ERROR_OK)
+ {
+ ERROR("trying to validate configured JTAG chain anyway...");
+ }
- jtag_examine_chain();
-
- jtag_validate_chain();
-
+ while (jtag_validate_chain() != ERROR_OK)
+ {
+ validate_tries++;
+ if (validate_tries > 5)
+ {
+ ERROR("Could not validate JTAG chain, exit");
+ jtag = NULL;
+ return ERROR_JTAG_INVALID_INTERFACE;
+ }
+ usleep(10000);
+ }
+
return ERROR_OK;
}
}
jtag_reset_config = RESET_TRST_AND_SRST;
else
{
- ERROR("invalid reset_config argument");
- exit(-1);
+ ERROR("invalid reset_config argument, defaulting to none");
+ jtag_reset_config = RESET_NONE;
+ return ERROR_INVALID_ARGUMENTS;
}
}
jtag_reset_config &= ~(RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST);
else
{
- ERROR("invalid reset_config argument");
- exit(-1);
+ ERROR("invalid reset_config argument, defaulting to none");
+ jtag_reset_config = RESET_NONE;
+ return ERROR_INVALID_ARGUMENTS;
}
}
jtag_reset_config &= ~RESET_TRST_OPEN_DRAIN;
else
{
- ERROR("invalid reset_config argument");
- exit(-1);
+ ERROR("invalid reset_config argument, defaulting to none");
+ jtag_reset_config = RESET_NONE;
+ return ERROR_INVALID_ARGUMENTS;
}
}
jtag_reset_config &= ~RESET_SRST_PUSH_PULL;
else
{
- ERROR("invalid reset_config argument");
- exit(-1);
+ ERROR("invalid reset_config argument, defaulting to none");
+ jtag_reset_config = RESET_NONE;
+ return ERROR_INVALID_ARGUMENTS;
}
}