* xsvf.patch:
This simplifies XSTATE handling, and protects against illegal state
transitions that might be in an SVF file. Previous code was vulnerable
to a bad path. They are now handled through a robust use of the
tms_seq[] table. With this patch and my xsvf_tools, I was able to work
with the lattice XP fpga as part of a two tap chain. svf2xsvf.py
converted any of three svf files and they all passed through the xsvf
command to the part. When using this combo, pay attention to the
"plain" argument, and use it when your (x)svf file has knowledge of all
taps in the chain.
Mr. Harboe: there is a revised static void
xsvf_add_statemove(tap_state_t goal_state) in here, different than the
one I offered you Friday. I think this one can work in both places.
* ft2232_additional.patch:
This is an adder to the one I submitted Friday. It removes a redundant
LOG_DEBUG() and improves error handling and logging a little, not earth
shattering. I predicted I would have to tweak this again after getting
into the xsvf.c again.
Out,
Dick
diff -r 7061e44e8237 src/jtag/ft2232.c
--- a/src/jtag/ft2232.c Sat May 02 22:37:19 2009 -0500
+++ b/src/jtag/ft2232.c Tue May 05 15:57:09 2009 -0500
@@ -1638,9 +1638,8 @@
static int ft2232_execute_statemove(jtag_command_t *cmd)
{
- int retval;
- int predicted_size = 0;
- retval = ERROR_OK;
+ int predicted_size = 0;
+ int retval = ERROR_OK;
DEBUG_JTAG_IO("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state));
@@ -1658,9 +1657,12 @@
ft2232_end_state(cmd->cmd.statemove->end_state);
/* move to end state */
- move_to_state( tap_get_end_state() );
+ if ( tap_get_state() != tap_get_end_state() )
+ {
+ move_to_state( tap_get_end_state() );
+ require_send = 1;
+ }
- require_send = 1;
return retval;
}
@@ -1673,7 +1675,10 @@
tap_state_t* path = cmd->cmd.pathmove->path;
int num_states = cmd->cmd.pathmove->num_states;
- DEBUG_JTAG_IO("pathmove: %i states, end in %s", num_states, tap_state_name(path[num_states-1]));
+ DEBUG_JTAG_IO("pathmove: %i states, current: %s end: %s", num_states,
+ tap_state_name( tap_get_state() ),
+ tap_state_name( path[num_states-1] )
+ );
/* only send the maximum buffer size that FT2232C can handle */
predicted_size = 3 * CEIL(num_states, 7);
@@ -1689,9 +1694,6 @@
ft2232_add_pathmove( path, num_states );
require_send = 1;
-#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG( "pathmove: %i states, end in %s", num_states, tap_state_name(path[num_states-1]) );
-#endif
return retval;
}
@@ -2194,6 +2196,8 @@
}
ft2232_buffer_size = 0;
+
+ assert( ft2232_buffer==NULL );
ft2232_buffer = malloc(FT2232_BUFFER_SIZE);
if (layout->init() != ERROR_OK)
@@ -2202,6 +2206,8 @@
return ERROR_JTAG_INIT_FAILED;
}
+
+ ft2232_purge();
ft2232_speed(jtag_speed);
@@ -2215,8 +2221,6 @@
}
ft2232_is_open = true;
-
- ft2232_purge();
return ERROR_OK;
}
@@ -2802,11 +2806,16 @@
{
#if BUILD_FT2232_FTD2XX == 1
+
+
// FT_STATUS status =
FT_Close(ftdih);
#elif BUILD_FT2232_LIBFTDI == 1
+
ftdi_disable_bitbang(&ftdic);
+
+ ftdi_usb_reset(&ftdic);
ftdi_usb_close(&ftdic);
diff -r 7061e44e8237 src/xsvf/xsvf.c
--- a/src/xsvf/xsvf.c Sat May 02 22:37:19 2009 -0500
+++ b/src/xsvf/xsvf.c Tue May 05 15:57:41 2009 -0500
@@ -187,25 +187,26 @@
tap_state_t moves[8];
tap_state_t cur_state = cmd_queue_cur_state;
int i;
+ int tms_bits;
+ int tms_count;
- int tms_bits = tap_get_tms_path(cur_state, goal_state);
- int tms_count = tap_get_tms_path_len(cur_state, goal_state);
+ LOG_DEBUG( "cur_state=%s goal_state=%s",
+ tap_state_name(cur_state),
+ tap_state_name(goal_state) );
- LOG_DEBUG( "cur_state=%s goal_state=%s tms_bits=%02x tms_count=%d",
- tap_state_name(cur_state), tap_state_name(goal_state),
- tms_bits, tms_count );
-
- assert( (unsigned) tms_count < DIM(moves) );
-
- if (goal_state != TAP_RESET && goal_state==cur_state)
+ if (goal_state==cur_state )
return;
- if( cur_state==TAP_RESET )
+ if( goal_state==TAP_RESET )
{
jtag_add_tlr();
return;
}
+ tms_bits = tap_get_tms_path(cur_state, goal_state);
+ tms_count = tap_get_tms_path_len(cur_state, goal_state);
+
+ assert( (unsigned) tms_count < DIM(moves) );
for (i=0; i<tms_count; i++, tms_bits>>=1)
{
@@ -237,38 +238,6 @@
if (read(fd, buf + num_bytes - 1, 1) < 0)
return ERROR_XSVF_EOF;
}
-
- return ERROR_OK;
-}
-
-
-static int xsvf_read_xstates(int fd, tap_state_t *path, int max_path, int *path_len)
-{
- char c;
- u8 uc;
-
- while ((read(fd, &c, 1) > 0) && (c == XSTATE))
- {
- tap_state_t mystate;
-
- if (*path_len > max_path)
- {
- LOG_WARNING("XSTATE path longer than max_path");
- break;
- }
- if (read(fd, &uc, 1) < 0)
- {
- return ERROR_XSVF_EOF;
- }
-
- mystate = xsvf_to_tap(uc);
-
- LOG_DEBUG("XSTATE %02X %s", uc, tap_state_name(mystate) );
-
- path[(*path_len)++] = mystate;
- }
-
- lseek(fd, -1, SEEK_CUR);
return ERROR_OK;
}
@@ -576,8 +545,7 @@
case XSTATE:
{
tap_state_t mystate;
- tap_state_t* path;
- int path_len;
+ u8 uc;
if (read(xsvf_fd, &uc, 1) < 0)
{
@@ -589,38 +557,7 @@
LOG_DEBUG("XSTATE 0x%02X %s", uc, tap_state_name(mystate) );
- path = calloc(XSTATE_MAX_PATH, 4);
- path_len = 1;
-
- path[0] = mystate;
- if (xsvf_read_xstates(xsvf_fd, path, XSTATE_MAX_PATH, &path_len) != ERROR_OK)
- do_abort = 1;
- else
- {
- int i,lasti;
-
- /* here the trick is that jtag_add_pathmove() must end in a stable
- * state, so we must only invoke jtag_add_tlr() when we absolutely
- * have to
- */
- for(i=0,lasti=0; i<path_len; i++)
- {
- if(path[i]==TAP_RESET)
- {
- if(i>lasti)
- {
- jtag_add_pathmove(i-lasti,path+lasti);
- }
- lasti=i+1;
- jtag_add_tlr();
- }
- }
- if(i>=lasti)
- {
- jtag_add_pathmove(i-lasti, path+lasti);
- }
- }
- free(path);
+ xsvf_add_statemove( mystate );
}
break;
@@ -767,7 +704,7 @@
comment[sizeof(comment)-1] = 0; /* regardless, terminate */
if (verbose)
- LOG_USER("%s", comment);
+ LOG_USER("\"# %s\"", comment);
}
break;
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development