diff --git a/jtag/ChangeLog b/jtag/ChangeLog index bb8cbaeb..8807bbdb 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,21 @@ +2003-08-11 Marcel Telka + + * configure.ac (AC_INIT): Changed version number to 0.5. + + * include/chain.h (chain_t): Added active_part. + * src/tap/chain.c (chain_alloc): Added active_part initialization. + * include/part.h (parts_print): Removed 'header' parameter. + * src/part/part.c (parts_print): Removed header printing. + * src/cmd/print.c (cmd_print_run): Added header printg. Added new parameter 'chain' for print command. + (cmd_print_help): Added new parameter 'chain'. + * src/cmd/dr.c (cmd_dr_run, cmd_dr_help): Removed PART parameter. + * src/cmd/get.c (cmd_get_run, cmd_get_help): Ditto. + * src/cmd/instruction.c (cmd_instruction_run, cmd_instruction_help): Ditto. + * src/cmd/set.c (cmd_set_run, cmd_set_help): Ditto. + * src/cmd/Makefile.am (libcmd_a_SOURCES): Adde part.c. + * src/cmd/part.c: New file. + * src/cmd/cmd.c (cmds): Added cmd_part. + 2003-07-25 Marcel Telka * data/Makefile.am (nobase_dist_pkgdata_DATA): Added broadcom/bcm3310/STEPPINGS and diff --git a/jtag/NEWS b/jtag/NEWS index ec8599c3..d8dc3004 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -2,6 +2,8 @@ $Id$ See libbrux/NEWS for more news. +jtag-0.5: + * Fixed bug with SELECT, AUTOFD, and STROBE signals handling (bug 745824). * Added new commands 'peek' and 'poke' (patch 747447, Matan Ziv-Av). * Fixed bugs in SH7727 bus driver (thanks to Rainer Dörken). @@ -12,6 +14,8 @@ See libbrux/NEWS for more news. - removed explicit JTAG chain length detection (patch 753298, Matan Ziv-Av) - simplified output messages - removed support for report results to file + * Added new command 'part', syntax changes for 'set', 'get', 'dr', 'instruction', and + 'print' commands. * Added initial JTAG declarations for Broadcom BCM3310 (see support request 770145 for more info, thanks to Ramses VI). * Fixed invalid memory allocation size (core dump) in jtag_parse_line() function. diff --git a/jtag/README b/jtag/README index ed166d0f..ae0738c3 100644 --- a/jtag/README +++ b/jtag/README @@ -149,10 +149,10 @@ jtag> ===> Fourth task: Sample device pin status. -jtag> instruction 0 SAMPLE/PRELOAD +jtag> instruction SAMPLE/PRELOAD jtag> shift ir jtag> shift dr -jtag> dr 0 +jtag> dr 10001100100000100001100101111111111111111110011011100000111011111111111111111111 11111111111111111111111111111111111111111111101111111101100000100010101000000000 00011111000000111010111111100000100001100100000000000000000111000011100000000000 @@ -163,7 +163,7 @@ jtag> print No. Manufacturer Part Stepping Instruction Register ---------------------------------------------------------------------------------------- 0 Intel PXA250 C0 SAMPLE/PRELOAD BSR -jtag> get signal 0 BOOT_SEL[0] +jtag> get signal BOOT_SEL[0] BOOT_SEL[0] = 0 jtag> diff --git a/jtag/configure.ac b/jtag/configure.ac index 211af10f..d488148e 100644 --- a/jtag/configure.ac +++ b/jtag/configure.ac @@ -21,7 +21,7 @@ # Written by Marcel Telka , 2002, 2003. # -AC_INIT(jtag,0.4) +AC_INIT(jtag,0.5) AC_PREREQ(2.54) AC_COPYRIGHT([Copyright (C) 2002, 2003 ETC s.r.o.]) diff --git a/jtag/include/chain.h b/jtag/include/chain.h index 5c9452f0..ee01f411 100644 --- a/jtag/include/chain.h +++ b/jtag/include/chain.h @@ -34,6 +34,7 @@ typedef struct chain_t chain_t; struct chain_t { int state; parts_t *parts; + int active_part; cable_t *cable; }; diff --git a/jtag/include/part.h b/jtag/include/part.h index 4e919732..7eba83c2 100644 --- a/jtag/include/part.h +++ b/jtag/include/part.h @@ -73,6 +73,6 @@ parts_t *parts_alloc( void ); void parts_free( parts_t *ps ); int parts_add_part( parts_t *ps, part_t *p ); void parts_set_instruction( parts_t *ps, const char *iname ); -void parts_print( parts_t *ps, int header ); +void parts_print( parts_t *ps ); #endif /* PART_H */ diff --git a/jtag/src/cmd/Makefile.am b/jtag/src/cmd/Makefile.am index 2568c7ea..e8f4e3ac 100644 --- a/jtag/src/cmd/Makefile.am +++ b/jtag/src/cmd/Makefile.am @@ -31,6 +31,7 @@ libcmd_a_SOURCES = \ discovery.c \ detect.c \ print.c \ + part.c \ instruction.c \ shift.c \ dr.c \ diff --git a/jtag/src/cmd/cmd.c b/jtag/src/cmd/cmd.c index 5509b445..d4c16aad 100644 --- a/jtag/src/cmd/cmd.c +++ b/jtag/src/cmd/cmd.c @@ -38,6 +38,7 @@ extern cmd_t cmd_cable; extern cmd_t cmd_discovery; extern cmd_t cmd_detect; extern cmd_t cmd_print; +extern cmd_t cmd_part; extern cmd_t cmd_instruction; extern cmd_t cmd_shift; extern cmd_t cmd_dr; @@ -59,6 +60,7 @@ const cmd_t *cmds[] = { &cmd_discovery, &cmd_detect, &cmd_print, + &cmd_part, &cmd_instruction, &cmd_shift, &cmd_dr, diff --git a/jtag/src/cmd/dr.c b/jtag/src/cmd/dr.c index dd333d59..cab608e4 100644 --- a/jtag/src/cmd/dr.c +++ b/jtag/src/cmd/dr.c @@ -35,11 +35,10 @@ static int cmd_dr_run( char *params[] ) { - unsigned int n; int dir = 1; tap_register *r; - if (cmd_params( params ) < 2 || cmd_params( params ) > 3) + if (cmd_params( params ) < 1 || cmd_params( params ) > 2) return -1; if (!cmd_test_cable()) @@ -50,27 +49,24 @@ cmd_dr_run( char *params[] ) return 1; } - if (cmd_get_number( params[1], &n )) - return -1; - - if (n >= chain->parts->len) { - printf( _("%s: invalid part number\n"), "dr" ); + if (chain->active_part >= chain->parts->len) { + printf( _("%s: no active part\n"), "part" ); return 1; } - if (params[2]) { - if (strcmp( params[2], "in" ) == 0) + if (params[1]) { + if (strcmp( params[1], "in" ) == 0) dir = 0; - else if (strcmp( params[2], "out" ) == 0) + else if (strcmp( params[1], "out" ) == 0) dir = 1; else return -1; } if (dir) - r = chain->parts->parts[n]->active_instruction->data_register->out; + r = chain->parts->parts[chain->active_part]->active_instruction->data_register->out; else - r = chain->parts->parts[n]->active_instruction->data_register->in; + r = chain->parts->parts[chain->active_part]->active_instruction->data_register->in; printf( _("%s\n"), register_get_string( r ) ); return 1; @@ -80,10 +76,9 @@ static void cmd_dr_help( void ) { printf( _( - "Usage: %s PART [DIR]\n" + "Usage: %s [DIR]\n" "Display input or output data register content.\n" "\n" - "PART part number (see print command)\n" "DIR requested data register; possible values: 'in' for\n" " input and 'out' for output; default is 'out'\n" ), "dr" ); diff --git a/jtag/src/cmd/get.c b/jtag/src/cmd/get.c index f76305d2..3878d7cc 100644 --- a/jtag/src/cmd/get.c +++ b/jtag/src/cmd/get.c @@ -36,19 +36,15 @@ static int cmd_get_run( char *params[] ) { - unsigned int n; int data; signal_t *s; - if (cmd_params( params ) != 4) + if (cmd_params( params ) != 3) return -1; if (strcmp( params[1], "signal") != 0) return -1; - if (cmd_get_number( params[2], &n )) - return -1; - if (!cmd_test_cable()) return 1; @@ -57,19 +53,19 @@ cmd_get_run( char *params[] ) return 1; } - if (n >= chain->parts->len) { - printf( _("%s: invalid part number\n"), "get" ); + if (chain->active_part >= chain->parts->len) { + printf( _("%s: no active part\n"), "get" ); return 1; } - s = part_find_signal( chain->parts->parts[n], params[3] ); + s = part_find_signal( chain->parts->parts[chain->active_part], params[2] ); if (!s) { - printf( _("signal '%s' not found\n"), params[3] ); + printf( _("signal '%s' not found\n"), params[2] ); return 1; } - data = part_get_signal( chain->parts->parts[n], s ); + data = part_get_signal( chain->parts->parts[chain->active_part], s ); if (data != -1) - printf( _("%s = %d\n"), params[3], data ); + printf( _("%s = %d\n"), params[2], data ); return 1; } @@ -78,10 +74,9 @@ static void cmd_get_help( void ) { printf( _( - "Usage: %s PART SIGNAL\n" + "Usage: %s SIGNAL\n" "Get signal state from output BSR (Boundary Scan Register).\n" "\n" - "PART part number (see print command)\n" "SIGNAL signal name (from JTAG declaration file)\n" ), "get signal" ); } diff --git a/jtag/src/cmd/instruction.c b/jtag/src/cmd/instruction.c index aae49df0..5f1047f0 100644 --- a/jtag/src/cmd/instruction.c +++ b/jtag/src/cmd/instruction.c @@ -34,9 +34,7 @@ static int cmd_instruction_run( char *params[] ) { - unsigned int n; - - if (cmd_params( params ) != 3) + if (cmd_params( params ) != 2) return -1; if (!cmd_test_cable()) @@ -47,17 +45,14 @@ cmd_instruction_run( char *params[] ) return 1; } - if (cmd_get_number( params[1], &n )) - return -1; - - if (n >= chain->parts->len) { - printf( _("%s: invalid part number\n"), "instruction" ); + if (chain->active_part >= chain->parts->len) { + printf( _("%s: no active part\n"), "instruction" ); return 1; } - part_set_instruction( chain->parts->parts[n], params[2] ); - if (chain->parts->parts[n]->active_instruction == NULL) - printf( _("%s: unknown instruction '%s'\n"), "instruction", params[2] ); + part_set_instruction( chain->parts->parts[chain->active_part], params[1] ); + if (chain->parts->parts[chain->active_part]->active_instruction == NULL) + printf( _("%s: unknown instruction '%s'\n"), "instruction", params[1] ); return 1; } @@ -66,10 +61,9 @@ static void cmd_instruction_help( void ) { printf( _( - "Usage: %s PART INSTRUCTION\n" + "Usage: %s INSTRUCTION\n" "Change active INSTRUCTION for a PART.\n" "\n" - "PART part number (see print command)\n" "INSTRUCTION instruction name (e.g. BYPASS)\n" ), "instruction" ); } diff --git a/jtag/src/cmd/part.c b/jtag/src/cmd/part.c new file mode 100644 index 00000000..401ddd04 --- /dev/null +++ b/jtag/src/cmd/part.c @@ -0,0 +1,79 @@ +/* + * $Id$ + * + * Copyright (C) 2003 ETC s.r.o. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by Marcel Telka , 2003. + * + */ + +#include + +#include +#include + +#include "jtag.h" + +#include "cmd.h" + +static int +cmd_part_run( char *params[] ) +{ + unsigned int n; + + if (cmd_params( params ) != 2) + return -1; + + if (!cmd_test_cable()) + return 1; + + if (!chain->parts) { + printf( _("Run \"detect\" first.\n") ); + return 1; + } + + if (cmd_get_number( params[1], &n )) + return -1; + + if (n >= chain->parts->len) { + printf( _("%s: invalid part number\n"), "part" ); + return 1; + } + + chain->active_part = n; + + return 1; +} + +static void +cmd_part_help( void ) +{ + printf( _( + "Usage: %s PART\n" + "Change active part for current JTAG chain.\n" + "\n" + "PART part number\n" + ), "part" ); +} + +cmd_t cmd_part = { + "part", + N_("change active part for current JTAG chain"), + cmd_part_help, + cmd_part_run +}; diff --git a/jtag/src/cmd/print.c b/jtag/src/cmd/print.c index 4d77d16e..ceaf9b78 100644 --- a/jtag/src/cmd/print.c +++ b/jtag/src/cmd/print.c @@ -25,6 +25,7 @@ #include #include +#include #include "part.h" #include "jtag.h" @@ -34,13 +35,42 @@ static int cmd_print_run( char *params[] ) { - if (cmd_params( params ) != 1) + char format[100]; + char header[100]; + int i; + + if (cmd_params( params ) > 2) return -1; if (!cmd_test_cable()) return 1; - parts_print( chain->parts, 1 ); + if (!chain->parts) { + printf( _("Run \"detect\" first.\n") ); + return 1; + } + + snprintf( format, 100, _(" No. %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds\n"), MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING, + MAXLEN_INSTRUCTION, MAXLEN_DATA_REGISTER ); + snprintf( header, 100, format, _("Manufacturer"), _("Part"), _("Stepping"), _("Instruction"), _("Register") ); + printf( header ); + + for (i = 0; i < strlen( header ); i++ ) + putchar( '-' ); + putchar( '\n' ); + + if (cmd_params( params ) == 1) { + if (chain->parts->len > chain->active_part) { + printf( _(" %3d "), chain->active_part ); + part_print( chain->parts->parts[chain->active_part] ); + } + return 1; + } + + if (strcmp( params[1], "chain" ) != 0) + return -1; + + parts_print( chain->parts ); return 1; } @@ -49,7 +79,7 @@ static void cmd_print_help( void ) { printf( _( - "Usage: %s\n" + "Usage: %s [chain]\n" "Display JTAG chain status.\n" "\n" "Display list of the parts connected to the JTAG chain including\n" diff --git a/jtag/src/cmd/set.c b/jtag/src/cmd/set.c index 7b371030..2adede9e 100644 --- a/jtag/src/cmd/set.c +++ b/jtag/src/cmd/set.c @@ -36,20 +36,16 @@ static int cmd_set_run( char *params[] ) { - unsigned int n; int dir; unsigned int data = 0; signal_t *s; - if (cmd_params( params ) < 5 || cmd_params( params ) > 6) + if (cmd_params( params ) < 4 || cmd_params( params ) > 5) return -1; if (strcmp( params[1], "signal" ) != 0) return -1; - if (cmd_get_number( params[2], &n )) - return -1; - if (!cmd_test_cable()) return 1; @@ -58,30 +54,30 @@ cmd_set_run( char *params[] ) return 1; } - if (n >= chain->parts->len) { - printf( _("%s: invalid part number\n"), "set" ); + if (chain->active_part >= chain->parts->len) { + printf( _("%s: no active part\n"), "set" ); return 1; } /* direction */ - if (strcmp( params[4], "in" ) != 0 && strcmp( params[4], "out" ) != 0) + if (strcmp( params[3], "in" ) != 0 && strcmp( params[3], "out" ) != 0) return -1; - dir = (strcmp( params[4], "in" ) == 0) ? 0 : 1; + dir = (strcmp( params[3], "in" ) == 0) ? 0 : 1; if (dir) { - if (cmd_get_number( params[5], &data )) + if (cmd_get_number( params[4], &data )) return -1; if (data > 1) return -1; } - s = part_find_signal( chain->parts->parts[n], params[3] ); + s = part_find_signal( chain->parts->parts[chain->active_part], params[2] ); if (!s) { - printf( _("signal '%s' not found\n"), params[3] ); + printf( _("signal '%s' not found\n"), params[2] ); return 1; } - part_set_signal( chain->parts->parts[n], s, dir, data ); + part_set_signal( chain->parts->parts[chain->active_part], s, dir, data ); return 1; } @@ -90,10 +86,9 @@ static void cmd_set_help( void ) { printf( _( - "Usage: %s PART SIGNAL DIR [DATA]\n" + "Usage: %s SIGNAL DIR [DATA]\n" "Set signal state in input BSR (Boundary Scan Register).\n" "\n" - "PART part number (see print command)\n" "SIGNAL signal name (from JTAG declaration file)\n" "DIR requested signal direction; possible values: 'in' or 'out'\n" "DATA desired output signal value ('0' or '1'); used only if DIR\n" diff --git a/jtag/src/part/part.c b/jtag/src/part/part.c index f9cb12df..306468f2 100644 --- a/jtag/src/part/part.c +++ b/jtag/src/part/part.c @@ -287,24 +287,10 @@ parts_set_instruction( parts_t *ps, const char *iname ) } void -parts_print( parts_t *ps, int header ) +parts_print( parts_t *ps ) { int i; - if (header) { - char format[100]; - char header[100]; - - snprintf( format, 100, _(" No. %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds\n"), MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING, - MAXLEN_INSTRUCTION, MAXLEN_DATA_REGISTER ); - snprintf( header, 100, format, _("Manufacturer"), _("Part"), _("Stepping"), _("Instruction"), _("Register") ); - printf( header ); - - for (i = 0; i < strlen( header ); i++ ) - putchar( '-' ); - putchar( '\n' ); - } - if (!ps) return; diff --git a/jtag/src/tap/chain.c b/jtag/src/tap/chain.c index 6d28a8a2..c6367ee8 100644 --- a/jtag/src/tap/chain.c +++ b/jtag/src/tap/chain.c @@ -39,6 +39,7 @@ chain_alloc( void ) chain->cable = NULL; chain->parts = NULL; + chain->active_part = 0; tap_state_init( chain ); return chain;