diff --git a/jtag/ChangeLog b/jtag/ChangeLog index dfc3b0b5..58fab323 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,10 @@ +2008-07-14 Arnim Laeuger + + * include/chain.h, include/tap.h, src/cmd/reset.c, src/tap/detect.c, + src/tap/chain.c, src/tap/tap.c, src/bus/fjmem.c, src/bus/avr32.c: + [ 1873260 ] Command 'reset' does not reset internal states + next round to fix this one + 2008-07-10 Arnim Laeuger * src/tap/usbconn/libftd2xx.c (usbconn_ftd2xx_open): perform device reset diff --git a/jtag/include/chain.h b/jtag/include/chain.h index 474ad653..3ffa5d5b 100644 --- a/jtag/include/chain.h +++ b/jtag/include/chain.h @@ -40,6 +40,7 @@ typedef struct chain_t chain_t; struct chain_t { int state; parts_t *parts; + int total_instr_len; int active_part; cable_t *cable; bsdl_globs_t bsdl; diff --git a/jtag/include/tap.h b/jtag/include/tap.h index 75742d00..fed95475 100644 --- a/jtag/include/tap.h +++ b/jtag/include/tap.h @@ -29,6 +29,7 @@ #include "chain.h" void tap_reset( chain_t *chain ); +void tap_reset_bypass( chain_t *chain ); void tap_capture_dr( chain_t *chain ); void tap_capture_ir( chain_t *chain ); void tap_defer_shift_register( chain_t *chain, const tap_register *in, tap_register *out, int exit ); diff --git a/jtag/src/bus/avr32.c b/jtag/src/bus/avr32.c index b04b4d8a..0f5e4972 100644 --- a/jtag/src/bus/avr32.c +++ b/jtag/src/bus/avr32.c @@ -39,8 +39,7 @@ #include "buses.h" #include "generic_bus.h" #include "data_register.h" - -void jtag_reset (chain_t * chain); +#include "tap.h" typedef struct { unsigned int mode; @@ -271,7 +270,7 @@ nexus_access_start (bus_t * bus) static void nexus_access_end (bus_t * bus) { - jtag_reset (CHAIN); + tap_reset_bypass (CHAIN); } static void diff --git a/jtag/src/bus/fjmem.c b/jtag/src/bus/fjmem.c index bc096df0..763e7e6f 100644 --- a/jtag/src/bus/fjmem.c +++ b/jtag/src/bus/fjmem.c @@ -114,7 +114,7 @@ fjmem_detect_reg_len( chain_t *chain, part_t *part, char *opcode, int len ) -> they're in BYPASS mode now */ chain_set_trst( chain, 0 ); chain_set_trst( chain, 1 ); - tap_reset( chain ); + tap_reset_bypass( chain ); /* flood all BYPASS registers with 0 for the following detection */ register_fill( dr->in, 0); diff --git a/jtag/src/cmd/reset.c b/jtag/src/cmd/reset.c index 2add69b1..4a895925 100644 --- a/jtag/src/cmd/reset.c +++ b/jtag/src/cmd/reset.c @@ -28,11 +28,10 @@ #include #include "jtag.h" +#include "tap.h" #include "cmd.h" -void jtag_reset( chain_t *chain ); - static int cmd_reset_run( chain_t *chain, char *params[] ) { @@ -42,7 +41,7 @@ cmd_reset_run( chain_t *chain, char *params[] ) if (!cmd_test_cable( chain )) return 1; - jtag_reset( chain ); + tap_reset_bypass( chain ); return 1; } diff --git a/jtag/src/tap/chain.c b/jtag/src/tap/chain.c index 8c830d76..ff61b278 100644 --- a/jtag/src/tap/chain.c +++ b/jtag/src/tap/chain.c @@ -42,6 +42,7 @@ chain_alloc( void ) chain->cable = NULL; chain->parts = NULL; + chain->total_instr_len = 0; chain->active_part = 0; BSDL_GLOBS_INIT(chain->bsdl); tap_state_init( chain ); diff --git a/jtag/src/tap/detect.c b/jtag/src/tap/detect.c index cae2ef31..69c68415 100644 --- a/jtag/src/tap/detect.c +++ b/jtag/src/tap/detect.c @@ -203,6 +203,7 @@ detect_parts( chain_t *chain, const char *db_path ) return 0; printf( _("IR length: %d\n"), irlen ); + chain->total_instr_len = irlen; /* Allocate IR */ ir = register_fill( register_alloc( irlen ), 1 ); @@ -211,7 +212,7 @@ detect_parts( chain_t *chain, const char *db_path ) return 0; } - tap_shift_register( chain, ir, NULL, 1 ); + tap_shift_register( chain, ir, NULL, EXITMODE_IDLE ); register_free( ir ); /* Detect chain length */ @@ -253,10 +254,10 @@ detect_parts( chain_t *chain, const char *db_path ) struct id_record idr; char *p; - tap_shift_register( chain, one, br, 0 ); + tap_shift_register( chain, one, br, EXITMODE_SHIFT ); if (register_compare( one, br ) == 0) { /* part with id */ - tap_shift_register( chain, ones, id, 0 ); + tap_shift_register( chain, ones, id, EXITMODE_SHIFT ); register_shift_left( id, 1 ); id->data[0] = 1; did = id; @@ -374,13 +375,13 @@ detect_parts( chain_t *chain, const char *db_path ) } for (i = 0; i < 32; i++) { - tap_shift_register( chain, one, br, 0 ); + tap_shift_register( chain, one, br, EXITMODE_SHIFT ); if (register_compare( one, br ) != 0) { printf( _("Error: Unable to detect JTAG chain end!\n") ); break; } } - tap_shift_register( chain, one, NULL, 1 ); + tap_shift_register( chain, one, NULL, EXITMODE_IDLE ); register_free( one ); register_free( ones ); @@ -460,5 +461,8 @@ int manual_add(chain_t *chain, int instr_len) return 0; } + /* update total instruction register length of chain */ + chain->total_instr_len += instr_len; + return chain->parts->len; } diff --git a/jtag/src/tap/tap.c b/jtag/src/tap/tap.c index f4147014..6af66656 100644 --- a/jtag/src/tap/tap.c +++ b/jtag/src/tap/tap.c @@ -36,10 +36,30 @@ tap_reset( chain_t *chain ) { tap_state_reset( chain ); - chain_defer_clock( chain, 1, 0, 5 ); /* Test-Logic-Reset */ - chain_defer_clock( chain, 0, 0, 1 ); /* Run-Test/Idle */ + chain_clock( chain, 1, 0, 5 ); /* Test-Logic-Reset */ + chain_clock( chain, 0, 0, 1 ); /* Run-Test/Idle */ +} - parts_set_instruction( chain->parts, "BYPASS" ); +void +tap_reset_bypass( chain_t *chain ) +{ + tap_reset( chain ); + + /* set all parts in the chain to BYPASS instruction if the total + instruction register length of the chain is already known */ + if (chain->total_instr_len > 0) { + tap_register *ir = register_fill( register_alloc( chain->total_instr_len ), 1 ); + if (!ir) { + printf( _("out of memory\n") ); + return; + } + + tap_capture_ir( chain ); + tap_shift_register( chain, ir, NULL, EXITMODE_IDLE ); + register_free( ir ); + + parts_set_instruction( chain->parts, "BYPASS" ); + } } void