char* jtag_event_strings[] =
{
- "JTAG controller reset(tms or TRST)"
+ "JTAG controller reset (TLR or TRST)"
};
/* kludge!!!! these are just global variables that the
#if BUILD_PARPORT == 1
extern jtag_interface_t parport_interface;
#endif
-
+
+#if BUILD_DUMMY == 1
+ extern jtag_interface_t dummy_interface;
+#endif
+
#if BUILD_FT2232_FTD2XX == 1
extern jtag_interface_t ft2232_interface;
#endif
extern jtag_interface_t usbprog_interface;
#endif
+#if BUILD_JLINK == 1
+ extern jtag_interface_t jlink_interface;
+#endif
+
jtag_interface_t *jtag_interfaces[] = {
#if BUILD_ECOSBOARD == 1
&eCosBoard_interface,
#if BUILD_PARPORT == 1
&parport_interface,
#endif
+#if BUILD_DUMMY == 1
+ &dummy_interface,
+#endif
#if BUILD_FT2232_FTD2XX == 1
&ft2232_interface,
#endif
#endif
#if BUILD_USBPROG == 1
&usbprog_interface,
+#endif
+#if BUILD_JLINK == 1
+ &jlink_interface,
#endif
NULL,
};
void MINIDRIVER(interface_jtag_add_dr_out)(int device_num,
int num_fields,
- int *num_bits,
- u32 *value,
+ const int *num_bits,
+ const u32 *value,
enum tap_state end_state)
{
int i;
/* FIX!!! there are *many* different cases here. A better
* approach is needed for legal combinations of transitions...
- */
+ */
if ((jtag_reset_config & RESET_HAS_SRST)&&
(jtag_reset_config & RESET_HAS_TRST)&&
- ((jtag_reset_config & RESET_SRST_PULLS_TRST)==0)&&
- ((jtag_reset_config & RESET_TRST_PULLS_SRST)==0))
+ ((jtag_reset_config & RESET_SRST_PULLS_TRST)==0))
{
if (((req_tlr_or_trst&&!jtag_trst)||
(!req_tlr_or_trst&&jtag_trst))&&
((req_srst&&!jtag_srst)||
(!req_srst&&jtag_srst)))
{
- LOG_ERROR("BUG: transition of req_tlr_or_trst and req_srst in the same jtag_add_reset() call is undefined");
+ /* FIX!!! srst_pulls_trst allows 1,1 => 0,0 transition.... */
+ //LOG_ERROR("BUG: transition of req_tlr_or_trst and req_srst in the same jtag_add_reset() call is undefined");
}
}
if (trst_with_tlr)
{
- LOG_DEBUG("JTAG reset with tms instead of TRST");
+ LOG_DEBUG("JTAG reset with TLR instead of TRST");
jtag_add_end_state(TAP_TLR);
jtag_add_tlr();
jtag_call_event_callbacks(JTAG_TRST_ASSERTED);
field->in_handler = jtag_check_value;
else
field->in_handler = NULL; /* No check, e.g. embeddedice uses value==NULL to indicate no check */
- field->in_handler_priv = NULL; /* this will be filled in at the invocation site to point to the field duplicate */
+ field->in_handler_priv = NULL;
field->in_check_value = value;
field->in_check_mask = mask;
}
int MINIDRIVER(interface_jtag_execute_queue)(void)
{
int retval;
-
+
+ if (jtag==NULL)
+ {
+ LOG_ERROR("No JTAG interface configured yet. Issue 'init' command in startup scripts before communicating with targets.");
+ return ERROR_FAIL;
+ }
+
retval = jtag->execute_queue();
cmd_queue_free();
int jtag_interface_init(struct command_context_s *cmd_ctx)
{
+ if (jtag)
+ return ERROR_OK;
+
if (!jtag_interface)
{
/* nothing was previously specified by "interface" command */
if(hasKHz)
{
/*stay on "reset speed"*/
- if (jtag_interface->khz(speed1, &speed1) == ERROR_OK)
- jtag_speed = speed1;
- if (jtag_interface->khz(speed2, &speed2) == ERROR_OK)
- jtag_speed_post_reset = speed2;
+ jtag_interface->khz(speed1, &jtag_speed);
+ jtag_interface->khz(speed2, &jtag_speed_post_reset);
hasKHz = 0;
}
{
int validate_tries = 0;
jtag_device_t *device;
+ int retval;
- LOG_DEBUG("-");
+ LOG_DEBUG("Init JTAG chain");
- if (!jtag && jtag_interface_init(cmd_ctx) != ERROR_OK)
- return ERROR_JTAG_INIT_FAILED;
-
device = jtag_devices;
jtag_ir_scan_size = 0;
jtag_num_devices = 0;
}
jtag_add_tlr();
- jtag_execute_queue();
+ if ((retval=jtag_execute_queue())!=ERROR_OK)
+ return retval;
/* examine chain first, as this could discover the real chain layout */
if (jtag_examine_chain() != ERROR_OK)
int jtag_init_reset(struct command_context_s *cmd_ctx)
{
int retval;
- LOG_DEBUG("Trying to bring the JTAG controller to life by asserting TRST / tms");
+
+ if ((retval=jtag_interface_init(cmd_ctx)) != ERROR_OK)
+ return retval;
+
+ LOG_DEBUG("Trying to bring the JTAG controller to life by asserting TRST / TLR");
/* Reset can happen after a power cycle.
*
- * Ideally we would only assert TRST or run tms before the target reset.
+ * Ideally we would only assert TRST or run TLR before the target reset.
*
* However w/srst_pulls_trst, trst is asserted together with the target
* reset whether we want it or not.
* NB! order matters!!!! srst *can* disconnect JTAG circuitry
*
*/
- jtag_add_reset(1, 0); /* TMS or TRST */
+ jtag_add_reset(1, 0); /* TLR or TRST */
if (jtag_reset_config & RESET_HAS_SRST)
{
jtag_add_reset(1, 1);
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 ERROR_FAIL;
}
+static int default_speed_div(int speed, int *khz)
+{
+ return ERROR_FAIL;
+}
+
int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
int i;
{
jtag_interface->khz = default_khz;
}
+ if (jtag_interface->speed_div == NULL)
+ {
+ jtag_interface->speed_div = default_speed_div;
+ }
return ERROR_OK;
}
}
/* this command can be called during CONFIG,
* in which case jtag isn't initialized */
if (jtag)
+ {
+ jtag->speed_div(jtag_speed, &speed1);
+ jtag->speed_div(jtag_speed_post_reset, &speed2);
jtag->speed(cur_speed);
+ }
}
command_print(cmd_ctx, "jtag_speed: %d, %d", jtag_speed, jtag_speed_post_reset);
{
LOG_DEBUG("handle jtag khz");
- if ((argc<1) || (argc>2))
+ if (argc>2)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc >= 1)
- speed1 = speed2 = strtoul(args[0], NULL, 0);
- if (argc == 2)
- speed2 = strtoul(args[1], NULL, 0);
-
- if (jtag != NULL)
+ if(argc != 0)
{
- int cur_speed = 0;
- LOG_DEBUG("have interface set up");
- int speed_div1, speed_div2;
- if (jtag->khz(speed1, &speed_div1)!=ERROR_OK)
- return ERROR_OK;
- if (jtag->khz(speed2, &speed_div2)!=ERROR_OK)
- return ERROR_OK;
-
+
if (argc >= 1)
- cur_speed = jtag_speed = jtag_speed_post_reset = speed_div1;
+ speed1 = speed2 = strtoul(args[0], NULL, 0);
if (argc == 2)
- cur_speed = jtag_speed_post_reset = speed_div2;
-
- jtag->speed(cur_speed);
- } else
- {
- hasKHz = 1;
+ speed2 = strtoul(args[1], NULL, 0);
+
+ if (jtag != NULL)
+ {
+ int cur_speed = 0;
+ LOG_DEBUG("have interface set up");
+ int speed_div1, speed_div2;
+ if (jtag->khz(speed1, &speed_div1)!=ERROR_OK)
+ {
+ speed1 = speed2 = 0;
+ return ERROR_OK;
+ }
+ if (jtag->khz(speed2, &speed_div2)!=ERROR_OK)
+ {
+ speed1 = speed2 = 0;
+ return ERROR_OK;
+ }
+
+ if (argc >= 1)
+ cur_speed = jtag_speed = jtag_speed_post_reset = speed_div1;
+ if (argc == 2)
+ cur_speed = jtag_speed_post_reset = speed_div2;
+
+ jtag->speed(cur_speed);
+ } else
+ {
+ hasKHz = 1;
+ }
}
+ command_print(cmd_ctx, "jtag_khz: %d, %d", speed1, speed2);
return ERROR_OK;
}
return ERROR_COMMAND_SYNTAX_ERROR;
}
- if (!jtag && jtag_interface_init(cmd_ctx) != ERROR_OK)
+ if (jtag_interface_init(cmd_ctx) != ERROR_OK)
return ERROR_JTAG_INIT_FAILED;
jtag_add_reset(trst, srst);