2003-05-20 Marcel Telka <marcel@telka.sk>

* configure.ac (AC_CONFIG_FILES): Added src/cmd/Makefile.
	* include/Makefile.am (noinst_HEADERS): Added jtag.h.
	* include/jtag.h: New file.
	* po/POTFILES.in: Updated.
	* src/Makefile.am (SUBDIRS): Added cmd.
	(jtag_SOURCES): Removed jtag.h and help.c.
	(jtag_DEPENDENCIES): Added cmd/libcmd.a.
	(jtag_LDADD): Added libcmd.
	(INCLUDES): Removed JTAG_DATA_DIR.
	* src/help.c: File removed.
	* src/jtag.h: Ditto.
	* src/jtag.c (jtag_parse_line): Removed command parsing and moved it to cmd directory.
	(jtag_parse_file): Function is no longer static.
	* src/cmd/Makefile.am: New file.
	* src/cmd/cable.c: Ditto.
	* src/cmd/cmd.c: Ditto.
	* src/cmd/cmd.h: Ditto.
	* src/cmd/detect.c: Ditto.
	* src/cmd/detectflash.c: Ditto.
	* src/cmd/discovery.c: Ditto.
	* src/cmd/dr.c: Ditto.
	* src/cmd/flashmem.c: Ditto.
	* src/cmd/frequency.c: Ditto.
	* src/cmd/get.c: Ditto.
	* src/cmd/help.c: Ditto.
	* src/cmd/instruction.c: Ditto.
	* src/cmd/print.c: Ditto.
	* src/cmd/quit.c: Ditto.
	* src/cmd/readmem.c: Ditto.
	* src/cmd/script.c: Ditto.
	* src/cmd/set.c: Ditto.
	* src/cmd/shift.c: Ditto.

	* src/part/part.c (parts_print): Fixed header printing.


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@434 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 22 years ago
parent 30ce7bb80f
commit bdac1de201

@ -1,3 +1,40 @@
2003-05-20 Marcel Telka <marcel@telka.sk>
* configure.ac (AC_CONFIG_FILES): Added src/cmd/Makefile.
* include/Makefile.am (noinst_HEADERS): Added jtag.h.
* include/jtag.h: New file.
* po/POTFILES.in: Updated.
* src/Makefile.am (SUBDIRS): Added cmd.
(jtag_SOURCES): Removed jtag.h and help.c.
(jtag_DEPENDENCIES): Added cmd/libcmd.a.
(jtag_LDADD): Added libcmd.
(INCLUDES): Removed JTAG_DATA_DIR.
* src/help.c: File removed.
* src/jtag.h: Ditto.
* src/jtag.c (jtag_parse_line): Removed command parsing and moved it to cmd directory.
(jtag_parse_file): Function is no longer static.
* src/cmd/Makefile.am: New file.
* src/cmd/cable.c: Ditto.
* src/cmd/cmd.c: Ditto.
* src/cmd/cmd.h: Ditto.
* src/cmd/detect.c: Ditto.
* src/cmd/detectflash.c: Ditto.
* src/cmd/discovery.c: Ditto.
* src/cmd/dr.c: Ditto.
* src/cmd/flashmem.c: Ditto.
* src/cmd/frequency.c: Ditto.
* src/cmd/get.c: Ditto.
* src/cmd/help.c: Ditto.
* src/cmd/instruction.c: Ditto.
* src/cmd/print.c: Ditto.
* src/cmd/quit.c: Ditto.
* src/cmd/readmem.c: Ditto.
* src/cmd/script.c: Ditto.
* src/cmd/set.c: Ditto.
* src/cmd/shift.c: Ditto.
* src/part/part.c (parts_print): Fixed header printing.
2003-05-20 Marcel Telka <marcel@telka.sk>
* src/part/data_register.c: Added l10n support. Marked messages for translation.

@ -42,6 +42,7 @@ AC_CONFIG_FILES(
src/part/Makefile
src/bus/Makefile
src/flash/Makefile
src/cmd/Makefile
po/Makefile.in
)

@ -36,4 +36,5 @@ noinst_HEADERS = \
register.h \
signal.h \
state.h \
jtag.h \
tap.h

@ -25,23 +25,26 @@
#ifndef JTAG_H
#define JTAG_H
#include <stdint.h>
#include <stdio.h>
#include <stdint.h>
#include <flash/cfi.h>
#include "part.h"
#include "chain.h"
#include "bus.h"
#include "part.h"
parts_t *detect_parts( chain_t* chain, char *db_path );
void detectflash( bus_t *bus );
void readmem( bus_t *bus, FILE *f, uint32_t addr, uint32_t len );
void flashmem( bus_t *bus, FILE *f, uint32_t addr );
void flashmsbin( bus_t *bus, FILE *f );
extern chain_t *chain;
extern bus_t *bus;
void help( const char *cmd );
int jtag_parse_file( const char *filename );
parts_t *detect_parts( chain_t *chain, char *db_path );
void discovery( chain_t *chain, const char *filename );
void readmem( bus_t *bus, FILE *f, uint32_t addr, uint32_t len );
void detectflash( bus_t *bus );
void flashmem( bus_t *bus, FILE *f, uint32_t addr );
void flashmsbin( bus_t *bus, FILE *f );
#endif /* JTAG_H */

@ -1,8 +1,24 @@
# $Id$
src/help.c
src/jtag.c
src/readmem.c
src/cmd/cmd.c
src/cmd/frequency.c
src/cmd/help.c
src/cmd/quit.c
src/cmd/cable.c
src/cmd/detect.c
src/cmd/discovery.c
src/cmd/detectflash.c
src/cmd/dr.c
src/cmd/flashmem.c
src/cmd/instruction.c
src/cmd/print.c
src/cmd/readmem.c
src/cmd/shift.c
src/cmd/get.c
src/cmd/script.c
src/cmd/set.c
src/part/data_register.c
src/part/instruction.c
src/part/parse.c

@ -26,7 +26,8 @@ SUBDIRS = \
tap \
part \
bus \
flash
flash \
cmd
bin_PROGRAMS = \
jtag \
@ -34,19 +35,30 @@ bin_PROGRAMS = \
jtag_SOURCES = \
jtag.c \
jtag.h \
detect.c \
discovery.c \
readmem.c \
flash.c \
help.c
flash.c
bsdl2jtag_SOURCES = \
bsdl2jtag.c
jtag_DEPENDENCIES = lib/libjtaglib.a tap/libtap.a part/libpart.a bus/libbus.a flash/libflash.a
jtag_DEPENDENCIES = \
lib/libjtaglib.a \
tap/libtap.a \
part/libpart.a \
bus/libbus.a \
flash/libflash.a \
cmd/libcmd.a
jtag_LDADD = -Ltap -ltap -Lpart -lpart -Llib -ljtaglib -Lbus -lbus -Lflash -lflash @LIBINTL@
jtag_LDADD = \
-Ltap -ltap \
-Lpart -lpart \
-Llib -ljtaglib \
-Lflash -lflash \
-Lcmd -lcmd \
-Lbus -lbus \
@LIBINTL@
localedir = $(datadir)/locale
INCLUDES = -DLOCALEDIR=\"$(localedir)\" -DJTAG_DATA_DIR=\"$(pkgdatadir)\"
INCLUDES = -DLOCALEDIR=\"$(localedir)\"

@ -0,0 +1,3 @@
.deps
Makefile
Makefile.in

@ -0,0 +1,46 @@
#
# $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 <marcel@telka.sk>, 2003.
#
noinst_LIBRARIES = libcmd.a
libcmd_a_SOURCES = \
cmd.h \
quit.c \
help.c \
frequency.c \
cable.c \
discovery.c \
detect.c \
print.c \
instruction.c \
shift.c \
dr.c \
get.c \
set.c \
readmem.c \
detectflash.c \
flashmem.c \
script.c \
cmd.c
INCLUDES = -DJTAG_DATA_DIR=\"$(pkgdatadir)\"

@ -0,0 +1,109 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "parport.h"
#include "tap.h"
#include "cable.h"
#include "chain.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_cable_run( char *params[] )
{
int i;
/* we need at least one parameter for 'cable' command */
if (cmd_params( params ) < 2)
return -1;
/* search connection type driver */
for (i = 0; parport_drivers[i]; i++)
if (strcmp( params[1], parport_drivers[i]->type ) == 0)
break;
if (!parport_drivers[i]) {
printf( _("Unknown connection type: %s\n"), params[1] );
return 1;
}
chain_disconnect( chain );
chain->cable = parport_drivers[i]->connect( (const char **) &params[2], cmd_params( params ) - 2 );
if (!chain->cable) {
printf( _("Error: Cable connection failed!\n") );
return 1;
}
if (cable_init( chain->cable )) {
printf( _("Error: Cable initialization failed!\n") );
chain_disconnect( chain );
return 1;
}
chain_set_trst( chain, 0 );
chain_set_trst( chain, 1 );
tap_reset( chain );
return 1;
}
static void
cmd_cable_help( void )
{
int i;
printf( _(
"Usage: %s PORTADDR CABLE\n"
"Usage: %s DEV CABLE\n"
"Select JTAG cable connected to parallel port.\n"
"\n"
"PORTADDR parallel port address (e.g. 0x378)\n"
"CABLE cable type\n"
"DEV ppdev device (e.g. /dev/parport0)\n"
"\n"
"List of supported cables:\n"
"%-13s No cable connected\n"
), "cable parallel", "cable ppdev", "none" );
for (i = 0; cable_drivers[i]; i++)
printf( _("%-13s %s\n"), cable_drivers[i]->name, _(cable_drivers[i]->description) );
}
cmd_t cmd_cable = {
"cable",
N_("select JTAG cable"),
cmd_cable_help,
cmd_cable_run
};

@ -0,0 +1,138 @@
/*
* $Id$
*
* Copyright (C) 2002, 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 <marcel@telka.sk>, 2002, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "jtag.h"
#include "cmd.h"
extern cmd_t cmd_quit;
extern cmd_t cmd_help;
extern cmd_t cmd_frequency;
extern cmd_t cmd_cable;
extern cmd_t cmd_discovery;
extern cmd_t cmd_detect;
extern cmd_t cmd_print;
extern cmd_t cmd_instruction;
extern cmd_t cmd_shift;
extern cmd_t cmd_dr;
extern cmd_t cmd_get;
extern cmd_t cmd_set;
extern cmd_t cmd_readmem;
extern cmd_t cmd_detectflash;
extern cmd_t cmd_flashmem;
extern cmd_t cmd_script;
const cmd_t *cmds[] = {
&cmd_quit,
&cmd_help,
&cmd_frequency,
&cmd_cable,
&cmd_discovery,
&cmd_detect,
&cmd_print,
&cmd_instruction,
&cmd_shift,
&cmd_dr,
&cmd_get,
&cmd_set,
&cmd_readmem,
&cmd_detectflash,
&cmd_flashmem,
&cmd_script,
NULL /* last must be NULL */
};
int
cmd_run( char *params[] )
{
int i;
if (!params[0])
return 1;
for (i = 0; cmds[i]; i++)
if (strcmp( cmds[i]->name, params[0] ) == 0) {
int r = cmds[i]->run( params );
if (r < 0)
printf( _("%s: syntax error!\n"), params[0] );
return r;
}
printf( _("%s: unknown command\n"), params[0] );
return 1;
}
int
cmd_params( char *params[] )
{
int i = 0;
while (params[i])
i++;
return i;
}
int
cmd_get_number( char *s, unsigned int *i )
{
int n;
int r;
int l;
if (!s || !i)
return -1;
l = strlen( s );
r = sscanf( s, "0x%x%n", i, &n);
if (r == 1 && n == l)
return 0;
r = sscanf( s, "%u%n", i, &n );
if (r == 1 && n == l)
return 0;
return -1;
}
int
cmd_test_cable( void )
{
if (chain->cable)
return 1;
printf( _("Error: Cable not configured. Please use '%s' command first!\n"), "cable" );
return 0;
}

@ -0,0 +1,40 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifndef CMD_H
#define CMD_H
typedef struct {
char *name;
char *desc;
void (*help)( void );
int (*run)( char *params[] );
} cmd_t;
int cmd_run( char *params[] );
int cmd_params( char *params[] );
int cmd_get_number( char *s, unsigned int *i );
int cmd_test_cable( void );
#endif /* CMD_H */

@ -0,0 +1,95 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "jtag.h"
#include "chain.h"
#include "bus.h"
#include "cmd.h"
static int
cmd_detect_run( char *params[] )
{
if (cmd_params( params ) != 1)
return -1;
if (!cmd_test_cable())
return 1;
if (bus) {
bus->free( bus );
bus = NULL;
}
parts_free( chain->parts );
chain->parts = detect_parts( chain, JTAG_DATA_DIR );
if (!chain->parts->len) {
parts_free( chain->parts );
chain->parts = NULL;
return 1;
}
parts_set_instruction( chain->parts, "SAMPLE/PRELOAD" );
chain_shift_instructions( chain );
chain_shift_data_registers( chain );
parts_set_instruction( chain->parts, "BYPASS" );
chain_shift_instructions( chain );
if (strcmp( chain->parts->parts[0]->part, "SA1110" ) == 0)
bus = new_sa1110_bus( chain, 0 );
if (strcmp( chain->parts->parts[0]->part, "PXA250" ) == 0)
bus = new_pxa250_bus( chain, 0 );
if (strcmp( chain->parts->parts[0]->part, "IXP425" ) == 0)
bus = new_ixp425_bus( chain, 0 );
return 1;
}
static void
cmd_detect_help( void )
{
printf( _(
"Usage: %s\n"
"Detect parts on the JTAG chain.\n"
"\n"
"Output from this command is a list of the detected parts.\n"
"If no parts are detected other commands may not work properly.\n"
), "detect" );
}
cmd_t cmd_detect = {
"detect",
N_("detect parts on the JTAG chain"),
cmd_detect_help,
cmd_detect_run
};

@ -0,0 +1,76 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include "jtag.h"
#include "cmd.h"
static int
cmd_detectflash_run( char *params[] )
{
if (cmd_params( params ) != 1)
return -1;
if (!cmd_test_cable())
return 1;
if (!bus) {
printf( _("Error: Bus driver missing.\n") );
return 1;
}
detectflash( bus );
return 1;
}
static void
cmd_detectflash_help( void )
{
printf( _(
"Usage: %s\n"
"Detect flash memory type connected to part.\n"
"\n"
"Only detects flash connected to part 0. Part 0 must support\n"
"bus operations.\n"
), "detectflash" );
}
cmd_t cmd_detectflash = {
"detectflash",
N_("detect parameters of flash chips attached to a part"),
cmd_detectflash_help,
cmd_detectflash_run
};

@ -0,0 +1,78 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include "jtag.h"
#include "cmd.h"
static int
cmd_discovery_run( char *params[] )
{
if (cmd_params( params ) != 2)
return -1;
if (!cmd_test_cable())
return 1;
discovery( chain, params[1] );
return 1;
}
static void
cmd_discovery_help( void )
{
printf( _(
"Usage: %s FILENAME\n"
"Discovery unknown parts in the JTAG chain.\n"
"\n"
"Detail output (report) is directed to the FILENAME.\n"
"'%s' attempts to detect these parameters of an unknown JTAG\n"
"chain:\n"
" 1. JTAG chain size (number of parts in the chain)\n"
" 2. IR (instruction register) length\n"
" 3. DR (data register) length for all possible instructions\n"
"\n"
"Warning: This may be dangerous for some parts (especially, if the\n"
"part doesn't have TRST signal).\n"
), "discovery", "discovery" );
}
cmd_t cmd_discovery = {
"discovery",
N_("discovery unknown parts in the JTAG chain"),
cmd_discovery_help,
cmd_discovery_run
};

@ -0,0 +1,104 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "register.h"
#include "jtag.h"
#include "cmd.h"
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)
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"), "dr" );
return 1;
}
if (params[2]) {
if (strcmp( params[2], "in" ) == 0)
dir = 0;
else if (strcmp( params[2], "out" ) == 0)
dir = 1;
else
return -1;
}
if (dir)
r = chain->parts->parts[n]->active_instruction->data_register->out;
else
r = chain->parts->parts[n]->active_instruction->data_register->in;
printf( _("%s\n"), register_get_string( r ) );
return 1;
}
static void
cmd_dr_help( void )
{
printf( _(
"Usage: %s PART [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" );
}
cmd_t cmd_dr = {
"dr",
N_("display active data register for a part"),
cmd_dr_help,
cmd_dr_run
};

@ -0,0 +1,109 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "jtag.h"
#include "flash.h"
#include "cmd.h"
static int
cmd_flashmem_run( char *params[] )
{
int msbin;
uint32_t adr = 0;
FILE *f;
if (cmd_params( params ) != 3)
return -1;
if (!cmd_test_cable())
return 1;
if (!bus) {
printf( _("Error: Bus driver missing.\n") );
return 1;
}
msbin = strcmp( "msbin", params[1] ) == 0;
if (!msbin && cmd_get_number( params[1], &adr ))
return -1;
f = fopen( params[2], "r" );
if (!f) {
printf( _("Unable to open file `%s'!\n"), params[2] );
return 1;
}
if (msbin)
flashmsbin( bus, f );
else
flashmem( bus, f, adr );
fclose( f );
return 1;
}
static void
cmd_flashmem_help( void )
{
int i;
printf( _(
"Usage: %s ADDR FILENAME\n"
"Usage: %s FILENAME\n"
"Program FILENAME content to flash memory.\n"
"\n"
"ADDR target addres for raw binary image\n"
"FILENAME name of the input file\n"
"%-10s FILENAME is in MS .bin format (for WinCE)\n"
"\n"
"ADDR could be in decimal or hexadecimal (prefixed with 0x) form.\n"
"\n"
"`%s' command works only with part 0. Part 0 must support bus operations.\n"
"\n"
"Supported Flash Memories:\n"
), "flashmem", "flashmem msbin", "msbin", "flashmem" );
for (i = 0; flash_drivers[i]; i++)
printf( _("%s\n %s\n"), _(flash_drivers[i]->name), _(flash_drivers[i]->description) );
}
cmd_t cmd_flashmem = {
"flashmem",
N_("burn flash memory with data from a file"),
cmd_flashmem_help,
cmd_flashmem_run
};

@ -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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include "cable.h"
#include "cmd.h"
static int
cmd_frequency_run( char *params[] )
{
unsigned int freq;
if (cmd_params( params ) != 2)
return -1;
if (cmd_get_number( params[1], &freq ))
return -1;
printf( _("Setting TCK frequency to %u Hz\n"), freq );
frequency = freq;
return 1;
}
static void
cmd_frequency_help( void )
{
printf( _(
"Usage: %s FREQ\n"
"Change TCK frequency to FREQ.\n"
"\n"
"FREQ is in hertz. It's a maximum TCK frequency for JTAG interface.\n"
"In some cases the TCK frequency is less than FREQ, but the frequency\n"
"is never more than FREQ. Maximum supported frequency depends on JTAG\n"
"adapter.\n"
"\n"
"FREQ must be an unsigned integer. Minimum allowed frequency is 1 Hz.\n"
"Use 0 for FREQ to disable frequency limit.\n"
), "frequency" );
}
cmd_t cmd_frequency = {
"frequency",
N_("setup JTAG frequency"),
cmd_frequency_help,
cmd_frequency_run
};

@ -0,0 +1,94 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "part.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_get_run( char *params[] )
{
unsigned int n;
int data;
if (cmd_params( params ) != 4)
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;
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
if (n >= chain->parts->len) {
printf( _("%s: invalid part number\n"), "get" );
return 1;
}
data = part_get_signal( chain->parts->parts[n], params[3] );
if (data != -1)
printf( _("%s = %d\n"), params[3], data );
return 1;
}
static void
cmd_get_help( void )
{
printf( _(
"Usage: %s PART 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" );
}
cmd_t cmd_get = {
"get",
N_("get external signal value"),
cmd_get_help,
cmd_get_run
};

@ -0,0 +1,86 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "cmd.h"
extern cmd_t *cmds[];
static int
cmd_help_run( char *params[] )
{
int i;
/* short description generation */
if (!params[1]) {
int i;
printf( _("Command list:\n\n") );
for (i = 0; cmds[i]; i++)
printf( _("%-13s %s\n"), cmds[i]->name, cmds[i]->desc ? _(cmds[i]->desc) : _("(no description available)") );
printf( _("\nType \"help COMMAND\" for details about particular command.\n") );
return 1;
}
if (params[2])
return -1;
/* search and print help for particular command */
for (i = 0; cmds[i]; i++)
if (strcmp( cmds[i]->name, params[1] ) == 0) {
if (cmds[i]->help)
cmds[i]->help();
return 1;
}
printf( _("%s: unknown command\n"), params[1] );
return 1;
}
static void
cmd_help_help( void )
{
printf( _(
"Usage: %s [COMMAND]\n"
"Print short help for COMMAND, or list of available commands.\n"
), "help" );
}
cmd_t cmd_help = {
"help",
N_("display this help"),
cmd_help_help,
cmd_help_run
};

@ -0,0 +1,89 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include "part.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_instruction_run( char *params[] )
{
unsigned int n;
if (cmd_params( params ) != 3)
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"), "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] );
return 1;
}
static void
cmd_instruction_help( void )
{
printf( _(
"Usage: %s PART 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" );
}
cmd_t cmd_instruction = {
"instruction",
N_("change active instruction for a part"),
cmd_instruction_help,
cmd_instruction_run
};

@ -0,0 +1,72 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include "part.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_print_run( char *params[] )
{
if (cmd_params( params ) != 1)
return -1;
if (!cmd_test_cable())
return 1;
parts_print( chain->parts, 1 );
return 1;
}
static void
cmd_print_help( void )
{
printf( _(
"Usage: %s\n"
"Display JTAG chain status.\n"
"\n"
"Display list of the parts connected to the JTAG chain including\n"
"part number and current (active) instruction and data register.\n"
), "print" );
}
cmd_t cmd_print = {
"print",
N_("display JTAG chain list/status"),
cmd_print_help,
cmd_print_run
};

@ -0,0 +1,61 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include "cmd.h"
static int
cmd_quit_run( char *params[] )
{
if (params[1])
return -1;
return 0;
}
static void
cmd_quit_help( void )
{
printf( _(
"Usage: %s\n"
"Exit from %s.\n"
), "quit", PACKAGE );
}
cmd_t cmd_quit = {
"quit",
N_("exit from jtag"),
cmd_quit_help,
cmd_quit_run
};

@ -0,0 +1,95 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <stdint.h>
#include "jtag.h"
#include "cmd.h"
static int
cmd_readmem_run( char *params[] )
{
uint32_t adr;
uint32_t len;
FILE *f;
if (cmd_params( params ) != 4)
return -1;
if (!cmd_test_cable())
return 1;
if (!bus) {
printf( _("Error: Bus driver missing.\n") );
return 1;
}
if (cmd_get_number( params[1], &adr) || cmd_get_number( params[2], &len))
return -1;
f = fopen( params[3], "w" );
if (!f) {
printf( _("Unable to create file `%s'!\n"), params[3] );
return 1;
}
readmem( bus, f, adr, len );
fclose( f );
return 1;
}
static void
cmd_readmem_help( void )
{
printf( _(
"Usage: %s ADDR LEN FILENAME\n"
"Copy device memory content starting with ADDR to FILENAME file.\n"
"\n"
"ADDR start address of the copied memory area\n"
"LEN copied memory length\n"
"FILENAME name of the output file\n"
"\n"
"ADDR and LEN could be in decimal or hexadecimal (prefixed with 0x) form.\n"
"\n"
"`%s' command works only with part 0. Part 0 must support bus operations.\n"
), "readmem", "readmem" );
}
cmd_t cmd_readmem = {
"readmem",
N_("read content of the memory and write it to file"),
cmd_readmem_help,
cmd_readmem_run
};

@ -0,0 +1,71 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include "jtag.h"
#include "cmd.h"
static int
cmd_script_run( char *params[] )
{
int go;
if (cmd_params( params ) != 2)
return -1;
go = jtag_parse_file( params[1] );
if (go < 0)
printf( _("Unable to open file `%s'!\n"), params[1] );
return go ? 1 : 0;
}
static void
cmd_script_help( void )
{
printf( _(
"Usage: %s FILENAME\n"
"Run command sequence from external FILENAME.\n"
"\n"
"FILENAME Name of the file with commands\n"
), "script" );
}
cmd_t cmd_script = {
"script",
N_("run command sequence from external file"),
cmd_script_help,
cmd_script_run
};

@ -0,0 +1,109 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "part.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_set_run( char *params[] )
{
unsigned int n;
int dir;
unsigned int data = 0;
if (cmd_params( params ) < 5 || cmd_params( params ) > 6)
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;
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
if (n >= chain->parts->len) {
printf( _("%s: invalid part number\n"), "set" );
return 1;
}
/* direction */
if (strcmp( params[4], "in" ) != 0 && strcmp( params[4], "out" ) != 0)
return -1;
dir = (strcmp( params[4], "in" ) == 0) ? 0 : 1;
if (dir) {
if (cmd_get_number( params[5], &data ))
return -1;
if (data > 1)
return -1;
}
part_set_signal( chain->parts->parts[n], params[3], dir, data );
return 1;
}
static void
cmd_set_help( void )
{
printf( _(
"Usage: %s PART 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"
" is 'out'\n"
), "set signal" );
}
cmd_t cmd_set = {
"set",
N_("set external signal value"),
cmd_set_help,
cmd_set_run
};

@ -0,0 +1,78 @@
/*
* $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 <marcel@telka.sk>, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "chain.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_shift_run( char *params[] )
{
if (cmd_params( params ) != 2)
return -1;
if (!cmd_test_cable())
return 1;
if (strcmp( params[1], "ir" ) == 0) {
chain_shift_instructions( chain );
return 1;
}
if (strcmp( params[1], "dr" ) == 0) {
chain_shift_data_registers( chain );
return 1;
}
return -1;
}
static void
cmd_shift_help( void )
{
printf( _(
"Usage: %s\n"
"Usage: %s\n"
"Shift instruction or data register through JTAG chain.\n"
), "shift ir", "shift dr" );
}
cmd_t cmd_shift = {
"shift",
N_("shift data/instruction registers through JTAG chain"),
cmd_shift_help,
cmd_shift_run
};

@ -1,231 +0,0 @@
/*
* $Id$
*
* Copyright (C) 2002, 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 <marcel@telka.sk>, 2002, 2003.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gettext.h"
#define _(s) gettext(s)
#define N_(s) gettext_noop(s)
#define P_(s,p,n) ngettext(s,p,n)
#include <stdio.h>
#include <string.h>
#include "cable.h"
#include "flash.h"
#include "jtag.h"
void
help( const char *cmd )
{
if (!cmd)
printf(
_("Command list:\n"
"\n"
"quit exit from %s\n"
"help display this help\n"
"frequency setup JTAG frequency\n"
"cable select JTAG cable\n"
"detect detect parts on the JTAG chain\n"
"discovery discovery unknown parts in the JTAG chain\n"
"print display JTAG chain list/status\n"
"instruction change active instruction for a part\n"
"shift shift data/instruction register through JTAG chain\n"
"dr display active data register for a part\n"
"detectflash detect parameters of flash chip attached to a part\n"
"readmem read content of the memory and write it to file\n"
"flashmem burn flash memory with data from a file\n"
"set set external signal value\n"
"get get external signal value\n"
"script run command sequence from external file\n"
"\n"
"Type \"help COMMAND\" for details about particular command.\n"), PACKAGE
);
else if (strcmp( cmd, "quit" ) == 0)
printf(
_("Usage: %s\n"
"Exit from %s.\n"), "quit", PACKAGE
);
else if (strcmp( cmd, "help" ) == 0)
printf(
_("Usage: %s [COMMAND]\n"
"Print short help for COMMAND, or list of available commands.\n"), "help"
);
else if (strcmp( cmd, "frequency" ) == 0)
printf(
_("Usage: %s FREQ\n"
"Change TCK frequency to FREQ.\n"
"\n"
"FREQ is in hertz. It's a maximum TCK frequency for JTAG interface.\n"
"In some cases the TCK frequency is less than FREQ, but the frequency\n"
"is never more than FREQ. Maximum supported frequency depends on JTAG\n"
"adapter.\n"
"\n"
"FREQ must be an unsigned integer. Minimum allowed frequency is 1 Hz.\n"
"Use 0 for FREQ to disable frequency limit.\n"), "frequency"
);
else if (strcmp( cmd, "cable" ) == 0) {
int i;
printf(
_("Usage: %s PORTADDR CABLE\n"
"Usage: %s DEV CABLE\n"
"Select JTAG cable connected to parallel port.\n"
"\n"
"PORTADDR parallel port address (e.g. 0x378)\n"
"CABLE cable type\n"
"DEV ppdev device (e.g. /dev/parport0)\n"
"\n"
"List of supported cables:\n"
"%-14sNo cable connected\n"), "cable parallel", "cable ppdev", "none"
);
for (i = 0; cable_drivers[i]; i++)
printf( "%-14s%s\n", cable_drivers[i]->name, _(cable_drivers[i]->description) );
} else if (strcmp( cmd, "detect" ) == 0)
printf(
_("Usage: %s\n"
"Detect parts on the JTAG chain.\n"
"\n"
"Output from this command is a list of the detected parts.\n"
"If no parts are detected other commands may not work properly.\n"), "detect"
);
else if (strcmp( cmd, "discovery" ) == 0)
printf(
_("Usage: %s FILENAME\n"
"Discovery unknown parts in the JTAG chain.\n"
"\n"
"Detail output (report) is directed to the FILENAME.\n"
"'discovery' attempt to detect these parameters of an unknown JTAG\n"
"chain:\n"
" 1. JTAG chain size (number of parts in the chain)\n"
" 2. IR (instruction register) length\n"
" 3. DR (data register) length for all possible instructions\n"
"\n"
"Warning: This may be dangerous for some parts (especially, if the\n"
"part doesn't have TRST signal).\n"), "discovery"
);
else if (strcmp( cmd, "print" ) == 0)
printf(
_("Usage: %s\n"
"Display JTAG chain status.\n"
"\n"
"Display list of the parts connected to the JTAG chain including\n"
"part number and current (active) instruction and data register.\n"), "print"
);
else if (strcmp( cmd, "instruction" ) == 0)
printf(
_("Usage: %s PART 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"
);
else if (strcmp( cmd, "shift" ) == 0)
printf(
_("Usage: %s\n"
"Usage: %s\n"
"Shift instruction or data register through JTAG chain.\n"), "shift ir", "shift dr"
);
else if (strcmp( cmd, "dr" ) == 0)
printf(
_("Usage: %s PART [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"
);
else if (strcmp( cmd, "detectflash" ) == 0)
printf(
_("Usage: %s\n"
"Detect flash memory type connected to part.\n"
"\n"
"Only detects flash connected to part 0. Part 0 must support\n"
"bus operations.\n"), "detectflash"
);
else if (strcmp( cmd, "readmem" ) == 0)
printf(
_("Usage: %s ADDR LEN FILENAME\n"
"Copy device memory content starting with ADDR to FILENAME file.\n"
"\n"
"ADDR start address of the copied memory area\n"
"LEN copied memory length\n"
"FILENAME name of the output file\n"
"\n"
"ADDR and LEN could be in decimal or hexadecimal (prefixed with 0x) form.\n"
"\n"
"`%s' command works only with part 0. Part 0 must support bus operations.\n"),
"readmem", "readmem"
);
else if (strcmp( cmd, "flashmem" ) == 0) {
int i;
printf(
_("Usage: %s ADDR FILENAME\n"
"Usage: flashmem msbin FILENAME\n"
"Program FILENAME content to flash memory.\n"
"\n"
"ADDR target addres for raw binary image\n"
"FILENAME name of the input file\n"
"msbin FILENAME is in MS .bin format (for WinCE)\n"
"\n"
"ADDR could be in decimal or hexadecimal (prefixed with 0x) form.\n"
"\n"
"`%s' command works only with part 0. Part 0 must support bus operations.\n"
"Supported Flash Memories\n"), "flashmem", "flashmem"
);
for (i = 0; flash_drivers[i]; i++)
printf( "%s\n %s\n", flash_drivers[i]->name, flash_drivers[i]->description );
} else if (strcmp( cmd, "get" ) == 0)
printf(
_("Usage: %s PART 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"
);
else if (strcmp( cmd, "set" ) == 0)
printf(
_("Usage: %s PART 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"
" is 'out'\n"), "set signal"
);
else if (strcmp( cmd, "script" ) == 0)
printf(
_("Usage: %s FILENAME\n"
"Run command sequence from external FILENAME.\n"
"\n"
"FILENAME Name of the file with commands\n"), "script"
);
else
printf( _("Invalid command.\n") );
}

@ -39,12 +39,11 @@
#include <readline/readline.h>
#include <readline/history.h>
#include "part.h"
#include "tap.h"
#include "parport.h"
#include "chain.h"
#include "bus.h"
#include "cmd/cmd.h"
#include "jtag.h"
#ifndef HAVE_GETLINE
@ -60,8 +59,6 @@ get_token( char *buf )
return strtok( buf, " \f\n\r\t\v" );
}
static int jtag_parse_file( const char *filename );
#define JTAGDIR ".jtag"
#define HISTORYFILE "history"
#define RCFILE "rc"
@ -142,582 +139,43 @@ jtag_save_history( void )
static int
jtag_parse_line( char *line )
{
char *t;
if (!line || !(strlen( line ) > 0))
return 1;
t = get_token( line );
if (!t)
return 1;
if (strcmp( t, "quit" ) == 0) {
if (get_token( NULL )) {
printf( _("quit: syntax error\n\nType \"help\" for help.\n\n") );
return 1;
}
return 0;
}
if (strcmp( t, "help" ) == 0) {
t = get_token( NULL );
if (get_token( NULL ))
printf( _("help: Syntax error!\n") );
else
help( t );
return 1;
}
if (strcmp( t, "frequency" ) == 0) {
uint32_t freq;
t = get_token( NULL );
if (!t) {
printf( _("Missing argument(s)\n") );
return 1;
}
if ((sscanf( t, "0x%x", &freq ) != 1) && (sscanf( t, "%u", &freq ) != 1)) {
printf( _("syntax error\n") );
return 1;
}
if (get_token( NULL )) {
printf( _("frequency: syntax error\n") );
return 1;
}
printf( _("Setting TCK frequency to %u Hz\n"), freq );
frequency = freq;
return 1;
}
if (strcmp( t, "cable" ) == 0) {
int i;
const char *params[10];
int numpar;
t = get_token( NULL );
if (!t) {
printf( _("Missing argument(s)\n") );
return 1;
}
for (i = 0; parport_drivers[i]; i++)
if (strcmp( t, parport_drivers[i]->type ) == 0)
break;
if (!parport_drivers[i]) {
printf( _("Unknown connection type: %s\n"), t );
return 1;
}
for (numpar = 0; numpar < 10; numpar++) {
params[numpar] = get_token( NULL );
if (!params[numpar])
break;
}
if (get_token( NULL )) {
printf( _("syntax error!\n") );
return 1;
}
chain_disconnect( chain );
chain->cable = parport_drivers[i]->connect( params, numpar );
if (!chain->cable) {
printf( _("Error: Cable connection failed!\n") );
return 1;
}
if (cable_init( chain->cable )) {
printf( _("Error: Cable initialization failed!\n") );
chain_disconnect( chain );
return 1;
}
chain_set_trst( chain, 0 );
chain_set_trst( chain, 1 );
tap_reset( chain );
return 1;
}
if (strcmp( t, "discovery" ) == 0) {
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("discovery: missing filename\n") );
return 1;
}
if (get_token( NULL )) {
printf( _("syntax error!\n") );
return 1;
}
discovery( chain, t );
return 1;
}
if (strcmp( t, "detect" ) == 0) {
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
if (get_token( NULL )) {
printf( _("detect: syntax error\n") );
return 1;
}
if (bus) {
bus->free( bus );
bus = NULL;
}
parts_free( chain->parts );
chain->parts = detect_parts( chain, JTAG_DATA_DIR );
if (!chain->parts->len) {
parts_free( chain->parts );
chain->parts = NULL;
return 1;
}
parts_set_instruction( chain->parts, "SAMPLE/PRELOAD" );
chain_shift_instructions( chain );
chain_shift_data_registers( chain );
parts_set_instruction( chain->parts, "BYPASS" );
chain_shift_instructions( chain );
if (strcmp( chain->parts->parts[0]->part, "SA1110" ) == 0)
bus = new_sa1110_bus( chain, 0 );
if (strcmp( chain->parts->parts[0]->part, "PXA250" ) == 0)
bus = new_pxa250_bus( chain, 0 );
if (strcmp( chain->parts->parts[0]->part, "IXP425" ) == 0)
bus = new_ixp425_bus( chain, 0 );
return 1;
}
if (strcmp( t, "flashmem" ) == 0) {
FILE *f;
int msbin = 0;
uint32_t addr = 0;
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("flashmem: Missing argument(s)\n") );
return 1;
}
if (strcmp( t, "msbin" ) != 0) {
if ((sscanf( t, "0x%x", &addr ) != 1) && (sscanf( t, "%d", &addr ) != 1)) {
printf( _("error\n") );
return 1;
}
printf( "0x%08X\n", addr );
} else
msbin = 1;
/* filename */
t = get_token( NULL );
if (!t) {
printf( _("flashmem: missing filename\n") );
return 1;
}
if (get_token( NULL )) {
printf( _("syntax error!\n") );
return 1;
}
f = fopen( t, "r" );
if (!f) {
printf( _("Unable to open file `%s'!\n"), t );
return 1;
}
if (msbin)
flashmsbin( bus, f );
else
flashmem( bus, f, addr );
fclose( f );
return 1;
}
if (strcmp( t, "readmem" ) == 0) {
FILE *f;
uint32_t addr = 0;
uint32_t len = 0;
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("flashmem: Missing argument(s)\n") );
return 1;
}
if ((sscanf( t, "0x%x", &addr ) != 1) && (sscanf( t, "%d", &addr ) != 1)) {
printf( _("syntax error\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("flashmem: Missing argument(s)\n") );
return 1;
}
if ((sscanf( t, "0x%x", &len ) != 1) && (sscanf( t, "%d", &len ) != 1)) {
printf( _("syntax error\n") );
return 1;
}
/* filename */
t = get_token( NULL );
if (!t) {
printf( _("flashmem: missing filename\n") );
return 1;
}
if (get_token( NULL )) {
printf( _("syntax error!\n") );
return 1;
}
f = fopen( t, "w" );
if (!f) {
printf( _("Unable to create file `%s'!\n"), t );
return 1;
}
readmem( bus, f, addr, len );
fclose( f );
return 1;
}
if (strcmp( t, "detectflash" ) == 0) {
if (get_token( NULL )) {
printf( _("detectflash: syntax error\n") );
return 1;
}
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
detectflash( bus );
return 1;
}
if (strcmp( t, "print" ) == 0) {
if (get_token( NULL )) {
printf( _("print: syntax error\n") );
return 1;
}
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
char *t;
int l;
int n;
char **a;
int r;
parts_print( chain->parts, 1 );
return 1;
}
if (strcmp( t, "instruction" ) == 0) {
int n;
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("instruction: syntax error\n") );
return 1;
}
n = strtol( t, &t, 10 );
if (t && *t) {
printf( _("instruction: syntax error\n") );
return 1;
}
if ((n < 0) || (n >= chain->parts->len)) {
printf( _("instruction: invalid part number\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("instruction: missing instruction name\n") );
return 1;
}
if (get_token( NULL )) {
printf( _("instruction: syntax error\n") );
return 1;
}
part_set_instruction( chain->parts->parts[n], t );
if (chain->parts->parts[n]->active_instruction == NULL)
printf( _("instruction: unknown instruction %s\n"), t );
return 1;
}
if (strcmp( t, "shift" ) == 0) {
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
t = get_token( NULL );
if (t && (strcmp( t, "ir" ) == 0)) {
chain_shift_instructions( chain );
return 1;
}
if (t && (strcmp( t, "dr" ) == 0)) {
chain_shift_data_registers( chain );
return 1;
}
printf( _("shift: syntax error\n") );
return 1;
}
if (strcmp( t, "dr" ) == 0) {
int n;
int dir;
tap_register *r;
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("dr: syntax error\n") );
return 1;
}
n = strtol( t, &t, 10 );
if (t && *t) {
printf( _("dr: syntax error\n") );
return 1;
}
if ((n < 0) || (n >= chain->parts->len)) {
printf( _("dr: invalid part number\n") );
return 1;
}
t = get_token( NULL );
if (!t)
dir = 1;
else {
if (strcmp( t, "in" ) == 0)
dir = 0;
else if (strcmp( t, "out" ) == 0)
dir = 1;
else {
printf( _("dr: syntax error\n") );
return 1;
}
if (get_token( NULL )) {
printf( _("dr: syntax error\n") );
return 1;
}
}
if (dir)
r = chain->parts->parts[n]->active_instruction->data_register->out;
else
r = chain->parts->parts[n]->active_instruction->data_register->in;
printf( "%s\n", register_get_string( r ) );
return 1;
}
if (strcmp( t, "set" ) == 0) {
int n;
int data;
int dir;
char *s;
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
t = get_token( NULL );
if (!t || strcmp( t, "signal" ) != 0) {
printf( _("set: syntax error\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("set: syntax error\n") );
return 1;
}
n = strtol( t, &t, 10 );
if (t && *t) {
printf( _("set: syntax error\n") );
return 1;
}
if ((n < 0) || (n >= chain->parts->len)) {
printf( _("set: invalid part number\n") );
return 1;
}
s = get_token( NULL ); /* signal name */
if (!s) {
printf( _("set: syntax error\n") );
return 1;
}
t = get_token( NULL ); /* direction */
if (!t || (strcmp( t, "in" ) != 0 && strcmp( t, "out" ) != 0)) {
printf( _("set: syntax error\n") );
return 1;
}
dir = (strcmp( t, "in" ) == 0) ? 0 : 1;
if (dir) {
t = get_token( NULL );
if (!t) {
printf( _("set: syntax error\n") );
return 1;
}
data = strtol( t, &t, 10 );
if (t && *t) {
printf( _("set: syntax error\n") );
return 1;
}
if ((data < 0) || (data > 1)) {
printf( _("set: invalid data value\n") );
return 1;
}
} else
data = 0;
if (get_token( NULL )) {
printf( _("set: syntax error\n") );
return 1;
}
part_set_signal( chain->parts->parts[n], s, dir, data );
return 1;
}
if (strcmp( t, "get" ) == 0) {
int n;
int data;
if (!chain->cable) {
printf( _("Error: Cable not configured. Use 'cable' command first!\n") );
return 1;
}
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
t = get_token( NULL );
if (!t || strcmp( t, "signal" ) != 0) {
printf( _("get: syntax error\n") );
return 1;
}
t = get_token( NULL );
if (!t) {
printf( _("get: syntax error\n") );
return 1;
}
n = strtol( t, &t, 10 );
if (t && *t) {
printf( _("get: syntax error\n") );
return 1;
}
if ((n < 0) || (n >= chain->parts->len)) {
printf( _("get: invalid part number\n") );
return 1;
}
t = get_token( NULL ); /* signal name */
if (!t || get_token( NULL )) {
printf( _("get: syntax error\n") );
return 1;
}
data = part_get_signal( chain->parts->parts[n], t );
if (data != -1)
printf( _("%s = %d\n"), t, data );
return 1;
}
if (!line || !(strlen( line ) > 0))
return 1;
if (strcmp( t, "script" ) == 0) {
int go;
t = get_token( line );
if (!t)
return 1;
t = get_token( NULL ); /* filename */
if (!t) {
printf( _("script: missing filename\n") );
n = 0;
l = 0;
a = NULL;
while (t) {
if (n + 2 > l) {
char **newa;
l = (l < 16) ? 16 : (l * 2);
newa = realloc( a, l );
if (!newa) {
free( a );
printf( _("Out of memory\n") );
return 1;
}
if (get_token( NULL )) {
printf( _("script: syntax error\n") );
return 1;
}
go = jtag_parse_file( t );
if (go < 0)
printf( _("Unable to open file `%s'!\n"), t );
return go;
a = newa;
}
a[n++] = t;
a[n] = NULL;
t = get_token( NULL );
}
printf( _("%s: unknown command\n"), t );
return 1;
r = cmd_run( a );
free( a );
return r;
}
static void
@ -739,7 +197,7 @@ jtag_readline_loop( const char *prompt )
free( line );
}
static int
int
jtag_parse_file( const char *filename )
{
FILE *f;

@ -299,13 +299,16 @@ parts_print( parts_t *ps, int header )
{
int i;
char format[100];
snprintf( format, 100, _(" No. %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds\n"), MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING,
MAXLEN_INSTRUCTION, MAXLEN_DATA_REGISTER );
if (header) {
printf( format, _("Manufacturer"), _("Part"), _("Stepping"), _("Instruction"), _("Register") );
for (i = 0; i < strlen( format ) + 1; i++ )
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' );
}

Loading…
Cancel
Save