diff options
-rw-r--r-- | src/jtag/jtag.c | 42 | ||||
-rw-r--r-- | src/jtag/jtag.h | 56 | ||||
-rw-r--r-- | src/pld/virtex2.c | 4 | ||||
-rw-r--r-- | src/target/event/xba_revA3.script | 3 | ||||
-rw-r--r-- | src/target/target/wi-9c.cfg | 2 | ||||
-rw-r--r-- | src/xsvf/xsvf.c | 53 |
6 files changed, 90 insertions, 70 deletions
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c index 8f55ea0..671c7ac 100644 --- a/src/jtag/jtag.c +++ b/src/jtag/jtag.c @@ -222,7 +222,6 @@ int jtag_speed_post_reset = 0; /* forward declarations */ -void jtag_add_statemove(enum tap_state endstate); void jtag_add_pathmove(int num_states, enum tap_state *path); void jtag_add_runtest(int num_cycles, enum tap_state endstate); void jtag_add_reset(int trst, int srst); @@ -245,7 +244,6 @@ int handle_scan_chain_command(struct command_context_s *cmd_ctx, char *cmd, char int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_statemove_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_drscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); @@ -777,18 +775,20 @@ int MINIDRIVER(interface_jtag_add_plain_dr_scan)(int num_fields, scan_field_t *f return ERROR_OK; } -void jtag_add_statemove(enum tap_state state) -{ - jtag_prelude(state); +void jtag_add_tms() +{ + jtag_prelude(TAP_TLR); + int retval; - retval=interface_jtag_add_statemove(cmd_queue_end_state); + retval=interface_jtag_add_tms(); if (retval!=ERROR_OK) jtag_error=retval; } -int MINIDRIVER(interface_jtag_add_statemove)(enum tap_state state) +int MINIDRIVER(interface_jtag_add_tms)() { + enum tap_state state = TAP_TLR; jtag_command_t **last_cmd = jtag_get_last_command_p(); /* allocate memory for a new list member */ @@ -943,7 +943,7 @@ void jtag_add_reset(int req_trst, int req_srst) { LOG_DEBUG("JTAG reset with tms instead of TRST"); jtag_add_end_state(TAP_TLR); - jtag_add_statemove(TAP_TLR); + jtag_add_tms(); jtag_call_event_callbacks(JTAG_TRST_ASSERTED); return; } @@ -1429,8 +1429,6 @@ int jtag_register_commands(struct command_context_s *cmd_ctx) COMMAND_EXEC, "toggle reset lines <trst> <srst>"); register_command(cmd_ctx, NULL, "runtest", handle_runtest_command, COMMAND_EXEC, "move to Run-Test/Idle, and execute <num_cycles>"); - register_command(cmd_ctx, NULL, "statemove", handle_statemove_command, - COMMAND_EXEC, "move to current endstate or [tap_state]"); register_command(cmd_ctx, NULL, "irscan", handle_irscan_command, COMMAND_EXEC, "execute IR scan <device> <instr> [dev2] [instr2] ..."); register_command(cmd_ctx, NULL, "drscan", handle_drscan_command, @@ -1477,7 +1475,7 @@ int jtag_init(struct command_context_s *cmd_ctx) device = device->next; } - jtag_add_statemove(TAP_TLR); + jtag_add_tms(); jtag_execute_queue(); /* examine chain first, as this could discover the real chain layout */ @@ -1837,28 +1835,6 @@ int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char ** } -int handle_statemove_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) -{ - enum tap_state state; - - state = -1; - if (argc == 1) - { - for (state = 0; state < 16; state++) - { - if (strcmp(args[0], tap_state_strings[state]) == 0) - { - break; - } - } - } - - jtag_add_statemove(state); - jtag_execute_queue(); - - return ERROR_OK; - -} int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 4d482f0..2c186e9 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -248,7 +248,14 @@ extern int jtag_register_commands(struct command_context_s *cmd_ctx); /* JTAG interface, can be implemented with a software or hardware fifo * * TAP_SD and TAP_SI are illegal end states. TAP_SD/SI as end states - * can be emulated by using a larger scan. + * can be emulated by using a larger scan. + * + * Code that is relatively insensitive to the path(as long + * as it is JTAG compliant) taken through state machine can use + * endstate for jtag_add_xxx_scan(). Otherwise the pause state must be + * specified as end state and a subsequent jtag_add_pathmove() must + * be issued. + * */ extern void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate); extern int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate); @@ -258,30 +265,24 @@ extern void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum ta extern int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate); extern void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate); extern int interface_jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate); -/* execute a state transition within the JTAG standard, but the exact path - * path that is taken is undefined. Many implementations use precisely - * 7 clocks to perform a transition, but it could be more or less - * than that. - * - * The following assertions are made about certain common state moves: - * - * - A state move from Pause-[ID]R to Pause-[ID]R should always go through - * Update-[ID]R and Capture-[ID]R before returning to Pause-[ID]R, otherwise - * there's no way force a register update, if you can't go to Run-Test/Idle for - * some reason. +/* run a TAP_TLR reset. End state is TAP_TLR, regardless + * of start state. + */ +extern void jtag_add_tms(); +extern int interface_jtag_add_tms(); +/* Do not use jtag_add_pathmove() unless you need to, but do use it + * if you have to. * - * - A state move from Pause-[ID]R to Shift-[ID]R must not go through - * Update-[ID]R. + * DANGER! If the target is dependent upon a particular sequence + * of transitions for things to work correctly(e.g. as a workaround + * for an errata that contradicts the JTAG standard), then pathmove + * must be used, even if some jtag interfaces happen to use the + * desired path. Worse, the jtag interface used for testing a + * particular implementation, could happen to use the "desired" + * path when transitioning to/from end + * state. * - * - Run-Test/Idle must not be entered unless requested, because R-T/I may have - * side effects. - * - * NB! a jtag_add_statemove() to the current state is not - * a no-operation. - */ -extern void jtag_add_statemove(enum tap_state endstate); -extern int interface_jtag_add_statemove(enum tap_state endstate); -/* A list of unambigious single clock state transitions, not + * A list of unambigious single clock state transitions, not * all drivers can support this, but it is required for e.g. * XScale and Xilinx support * @@ -289,6 +290,15 @@ extern int interface_jtag_add_statemove(enum tap_state endstate); * * Note that the first on the list must be reachable * via a single transition from the current state. + * + * All drivers are required to implement jtag_add_pathmove(). + * However, if the pathmove sequence can not be precisely + * executed, an interface_jtag_add_pathmove() or jtag_execute_queue() + * must return an error. It is legal, but not recommended, that + * a driver returns an error in all cases for a pathmove if it + * can only implement a few transitions and therefore + * a partial implementation of pathmove would have little practical + * application. */ extern void jtag_add_pathmove(int num_states, enum tap_state *path); extern int interface_jtag_add_pathmove(int num_states, enum tap_state *path); diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index 45c39ae..997f60d 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -137,7 +137,7 @@ int virtex2_read_stat(struct pld_device_s *pld_device, u32 *status) { u32 data[5]; - jtag_add_statemove(TAP_TLR); + jtag_add_tms(); data[0] = 0xaa995566; /* synch word */ data[1] = 0x2800E001; /* Type 1, read, address 7, 1 word */ @@ -192,7 +192,7 @@ int virtex2_load(struct pld_device_s *pld_device, char *filename) jtag_add_dr_scan(1, &field, TAP_PD); jtag_execute_queue(); - jtag_add_statemove(TAP_TLR); + jtag_add_tms(); jtag_add_end_state(TAP_RTI); virtex2_set_instr(virtex2_info->chain_pos, 0xc); /* JSTART */ diff --git a/src/target/event/xba_revA3.script b/src/target/event/xba_revA3.script index b58c7a2..3d01101 100644 --- a/src/target/event/xba_revA3.script +++ b/src/target/event/xba_revA3.script @@ -34,6 +34,9 @@ mww 0xCC000008 1 # Mode Select CL3 #mww 0xc4000020 0xffffee # CFG0: remove expansion bus boot flash
#mirror at 0x00000000
+#big endian
+reg XSCALE_CTRL 0xF8
+
#
# detect flash
#
diff --git a/src/target/target/wi-9c.cfg b/src/target/target/wi-9c.cfg index f18b1e0..2bc7d93 100644 --- a/src/target/target/wi-9c.cfg +++ b/src/target/target/wi-9c.cfg @@ -15,7 +15,7 @@ jtag_ntrst_delay 0 ######################
#target <type> <endianess> <reset mode> <JTAG pos> <variant>
-target arm926ejs little reset_init 0 arm926ejs
+target arm926ejs big reset_init 0 arm926ejs
target_script 0 reset event/wi-9c_reset.script
run_and_halt_time 0 30
diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index d9b6316..09736af 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -66,6 +66,37 @@ int tap_to_xsvf[] = 0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x1, 0x9, 0xa, 0xb, 0xc, 0xe, 0xf }; + +/* xsvf has it's own definition of a statemove. This needs + * to be handled according to the specs, which has nothing + * to do with the JTAG spec or OpenOCD as such. + * + * Implemented via jtag_add_pathmove(). + */ +void xsvf_add_statemove(enum tap_state state) +{ + enum tap_state moves[7]; /* max # of transitions */ + int i; + enum tap_state curstate=cmd_queue_cur_state; + u8 move=tap_move[cmd_queue_cur_state][state]; + + if ((state!=TAP_TLR)&&(state==cmd_queue_cur_state)) + return; + for (i=0; i<7; i++) + { + int j=(move>>i)&1; + if (j) + { + curstate=tap_transitions[curstate].high; + } else + { + curstate=tap_transitions[curstate].low; + } + moves[i]=curstate; + } + jtag_add_pathmove(7, moves); +} + int xsvf_register_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, NULL, "xsvf", handle_xsvf_command, @@ -203,13 +234,13 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg jtag_add_runtest(xruntest, xsvf_to_tap[xendir]); else { - jtag_add_statemove(TAP_RTI); + xsvf_add_statemove(TAP_RTI); jtag_add_sleep(xruntest); - jtag_add_statemove(xsvf_to_tap[xendir]); + xsvf_add_statemove(xsvf_to_tap[xendir]); } } else if (xendir != 0xd) /* Pause-IR */ - jtag_add_statemove(xsvf_to_tap[xendir]); + xsvf_add_statemove(xsvf_to_tap[xendir]); } free(ir_buf); } @@ -242,13 +273,13 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg jtag_add_runtest(xruntest, xsvf_to_tap[xenddr]); else { - jtag_add_statemove(TAP_RTI); + xsvf_add_statemove(TAP_RTI); jtag_add_sleep(xruntest); - jtag_add_statemove(xsvf_to_tap[xenddr]); + xsvf_add_statemove(xsvf_to_tap[xenddr]); } } else if (xendir != 0x6) /* Pause-DR */ - jtag_add_statemove(xsvf_to_tap[xenddr]); + xsvf_add_statemove(xsvf_to_tap[xenddr]); } break; case 0x04: /* XRUNTEST */ @@ -316,13 +347,13 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg jtag_add_runtest(xruntest, xsvf_to_tap[xenddr]); else { - jtag_add_statemove(TAP_RTI); + xsvf_add_statemove(TAP_RTI); jtag_add_sleep(xruntest); - jtag_add_statemove(xsvf_to_tap[xenddr]); + xsvf_add_statemove(xsvf_to_tap[xenddr]); } } else if (xendir != 0x6) /* Pause-DR */ - jtag_add_statemove(xsvf_to_tap[xenddr]); + xsvf_add_statemove(xsvf_to_tap[xenddr]); } } break; @@ -451,10 +482,10 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg do_abort = 1; else { - jtag_add_statemove(xsvf_to_tap[uc]); + xsvf_add_statemove(xsvf_to_tap[uc]); ui = be_to_h_u32(buf4); jtag_add_sleep(ui); - jtag_add_statemove(xsvf_to_tap[uc2]); + xsvf_add_statemove(xsvf_to_tap[uc2]); } break; default: |