Hi all, Unless I accidentally missed something, the attached patches provide the last _functional_ changes in Jeff Williams' J-Link patch; my final task will be to extract and apply the debugging improvements that he made, as it looks like they will then need to be immediately put into use.
These patches do the following: * Add the new tap_get_tms_path_len function which -- when combined with a new state table -- allows drivers to execute correct TAP state paths. * Updates the transition table in tap_get_tms_patch. This will require drivers use the tap_get_tms_path_len function, rather than assume there are always 7 steps. * Switches the J-Link driver over to using the tap_get_tms_path_len function, rather than assuming 7 steps. These patches are _not_ ready to be committed, for reasons so numerous that they need not be mentioned here. Let's just cut to the thick: what's right, what's wrong, and what do we want to do about this? Cheers, Zach
Index: src/jtag/jtag.c =================================================================== --- src/jtag/jtag.c (revision 1507) +++ src/jtag/jtag.c (working copy) @@ -3118,7 +3118,25 @@ return tms_seqs[tap_move_ndx(from)][tap_move_ndx(to)]; } +int tap_get_tms_path_len( tap_state_t from, tap_state_t to ) +{ + /* + * N.B. These values are tightly bound to the table in tap_get_tms_path(). + */ + static const u8 tms_seqs_bit_len[6][6] = + { + { 8, 1, 4, 5, 5, 6}, + { 8, 1, 3, 4, 4, 5}, + { 8, 3, 5, 2, 6, 7}, + { 8, 3, 2, 1, 6, 7}, + { 8, 3, 5, 6, 6, 2}, + { 8, 3, 5, 6, 2, 1} + }; + /* @todo: support other than 7 clocks ? */ + return tms_seqs_bit_len[tap_move_ndx(from)][tap_move_ndx(to)]; +} + bool tap_is_state_stable(tap_state_t astate) { bool is_stable; Index: src/jtag/jtag.h =================================================================== --- src/jtag/jtag.h (revision 1507) +++ src/jtag/jtag.h (working copy) @@ -155,6 +155,24 @@ int tap_get_tms_path(tap_state_t from, tap_state_t to); /** + * Function int tap_get_tms_path_len + * returns the total number of bits that represents a TMS path + * transition as given by the function tap_get_tms_path(). + * + * For at least one interface (JLink) it's not OK to simply "pad" TMS sequences + * to fit a whole byte. (I suspect this is a general TAP problem within OOCD.) + * Padding TMS causes all manner of instability that's not easily + * discovered. Using this routine we can apply EXACTLY the state transitions + * required to make something work - no more - no less. + * + * @param from is the starting state + * @param to is the resultant or final state + * @return int - the total number of bits in a transition. + */ + +int tap_get_tms_path_len(tap_state_t from, tap_state_t to); + +/** * Function tap_move_ndx * when given a stable state, returns an index from 0-5. The index corresponds to a * sequence of stable states which are given in this order: <p>
Index: src/jtag/jlink.c =================================================================== --- src/jtag/jlink.c (revision 1433) +++ src/jtag/jlink.c (working copy) @@ -362,8 +362,9 @@ int i; int tms = 0; u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state()); + u8 tms_scan_bits = tap_get_tms_path_len(tap_get_state(), tap_get_end_state()); - for (i = 0; i < 7; i++) + for (i = 0; i < tms_scan_bits; i++) { tms = (tms_scan >> i) & 1; jlink_tap_append_step(tms, 0);
Index: src/jtag/jtag.c =================================================================== --- src/jtag/jtag.c (revision 1507) +++ src/jtag/jtag.c (working copy) @@ -3093,14 +3093,14 @@ { /* value clocked to TMS to move from one of six stable states to another */ - /* RESET IDLE DRSHIFT DRPAUSE IRSHIFT IRPAUSE */ - { 0x7f, 0x00, 0x17, 0x0a, 0x1b, 0x16 }, /* RESET */ - { 0x7f, 0x00, 0x25, 0x05, 0x2b, 0x0b }, /* IDLE */ - { 0x7f, 0x31, 0x00, 0x01, 0x0f, 0x2f }, /* DRSHIFT */ - { 0x7f, 0x30, 0x20, 0x17, 0x1e, 0x2f }, /* DRPAUSE */ - { 0x7f, 0x31, 0x07, 0x17, 0x00, 0x01 }, /* IRSHIFT */ - { 0x7f, 0x30, 0x1c, 0x17, 0x20, 0x2f } /* IRPAUSE */ - }; + /* RESET IDLE DRSHIFT DRPAUSE IRSHIFT IRPAUSE */ + { B8(11111111),B8(0), B8(0010), B8(01010), B8(00110), B8(010110)}, /* RESET */ + { B8(11111111),B8(0), B8(001), B8(0101), B8(0011), B8(01011)}, /* IDLE */ + { B8(11111111),B8(011), B8(00111),B8(01), B8(001111),B8(0101111)},/* DRSHIFT */ + { B8(11111111),B8(011), B8(01), B8(0), B8(001111),B8(0101111)},/* DRPAUSE */ + { B8(11111111),B8(011), B8(00111),B8(010111), B8(001111),B8(01)}, /* IRSHIFT */ + { B8(11111111),B8(011), B8(00111),B8(010111), B8(01), B8(0)} /* IRPAUSE */ +}; if( !tap_is_state_stable(from) ) { Index: src/jtag/jtag.h =================================================================== --- src/jtag/jtag.h (revision 1507) +++ src/jtag/jtag.h (working copy) @@ -40,6 +40,22 @@ #define DEBUG_JTAG_IOZ 64 #endif +/* + * These macros allow us to specify TMS state transitions by bits rather than hex bytes. + * You still read the transitions LSB-first (right-to-left). + * (This was not necessarily clear in previous code.) + */ +#define HEX__(n) 0x##n##UL +#define B8__(x) \ + ((x & 0x0000000FUL) ? 1 : 0) + \ + ((x & 0x000000F0UL) ? 2 : 0) + \ + ((x & 0x00000F00UL) ? 4 : 0) + \ + ((x & 0x0000F000UL) ? 8 : 0) + \ + ((x & 0x000F0000UL) ? 16 : 0) + \ + ((x & 0x00F00000UL) ? 32 : 0) + \ + ((x & 0x0F000000UL) ? 64 : 0) + \ + ((x & 0xF0000000UL) ? 128 : 0) +#define B8(d) ((unsigned char)B8__(HEX__(d))) /* * Tap states from ARM7TDMI-S Technical reference manual.
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development