1933730 "idcode" command (by U.Bonnes)

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1151 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Kolja Waschk 17 years ago
parent 7f26d5814d
commit b067b0d946

@ -1,3 +1,9 @@
2008-04-03 Kolja Waschk <kawk>
* include/jtag.h, src/cmd/cmd.c, src/cmd/idcode.c, src/cmd/Makefile.am,
src/tap/parport/ftdi.c, src/tap/idcode.c, src/tap/Makefile.am, THANKS:
[1933730] new "idcode" command (by U.Bonnes)
2008-04-03 Arnim Laeuger <arniml@users.sourceforge.net>
[ 1929235 ] Use less global and static variables:

@ -7,6 +7,7 @@ Shaju Abraham
Beregnyei Balazs
Krzysztof Blaszkowski
Eugene Boldenkov
Uwe Bonnes
Cliff Brake
Martin Buck
Ian Campbell

@ -45,6 +45,7 @@ int jtag_parse_stream( chain_t *chain, FILE *f );
int detect_parts( chain_t *chain, char *db_path );
int detect_register_size( chain_t *chain );
void discovery( chain_t *chain );
void idcode( chain_t *chain , unsigned int bytes);
void readmem( bus_t *bus, FILE *f, uint32_t addr, uint32_t len );
void writemem( bus_t *bus, FILE *f, uint32_t addr, uint32_t len );

@ -30,6 +30,7 @@ libcmd_a_SOURCES = \
cable.c \
reset.c \
discovery.c \
idcode.c \
detect.c \
detectflash.c \
help.c \

@ -37,6 +37,7 @@ extern cmd_t cmd_frequency;
extern cmd_t cmd_cable;
extern cmd_t cmd_reset;
extern cmd_t cmd_discovery;
extern cmd_t cmd_idcode;
extern cmd_t cmd_detect;
extern cmd_t cmd_signal;
extern cmd_t cmd_scan;
@ -79,6 +80,7 @@ const cmd_t *cmds[] = {
&cmd_cable,
&cmd_reset,
&cmd_discovery,
&cmd_idcode,
&cmd_detect,
&cmd_signal,
&cmd_scan,

@ -0,0 +1,68 @@
/*
* $Id: idcode.c 1102 2008-02-27 03:38:31Z jiez $
*
* 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 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>, 2008.
*
*/
#include "sysdep.h"
#include <stdio.h>
#include "jtag.h"
#include "cmd.h"
static int
cmd_idcode_run( chain_t *chain, char *params[] )
{
unsigned int bytes=0;
if (cmd_params( params ) == 1) {
bytes = 0;
}
else if (cmd_params( params ) >2)
return -1;
else if (cmd_get_number( params[1], &bytes ))
return -1;
printf( _("Reading %d bytes if idcode\n"), bytes );
idcode( chain , bytes);
return 1;
}
static void
cmd_idcode_help( void )
{
printf( _(
"Usage: %s [BYTES]\n"
"Read [BYTES]|all IDCODEs of all parts in a JTAG chain.\n"
"\n"
"BYTES must be an unsigned integer, Use 0 for BYTES to read all bytes\n"
), "idcode" );
}
cmd_t cmd_idcode = {
"idcode",
N_("Read IDCODEs of all parts in a JTAG chain"),
cmd_idcode_help,
cmd_idcode_run
};

@ -32,6 +32,7 @@ libtap_a_SOURCES = \
chain.c \
detect.c \
discovery.c \
idcode.c \
parport.c \
usbconn.c \
cable.c \

@ -0,0 +1,80 @@
/*
* $Id: idcode.c 1120 2008-03-15 02:27:13Z jiez $
*
* 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 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>, 2008.
*
*/
#include "sysdep.h"
#include <stdio.h>
#include <stdlib.h>
#include "cable.h"
#include "tap.h"
#include "chain.h"
#include "jtag.h"
void
idcode( chain_t *chain , unsigned int bytes)
{
int i;
int hit = 0;
tap_register *rz;
tap_register *rout;
tap_register *rnull;
chain_set_trst( chain, 0 );
chain_set_trst( chain, 1 );
tap_reset( chain );
tap_capture_dr( chain );
/* read in chunks of 8 bytes */
rz = register_fill( register_alloc( 8 ), 0);
rnull = register_fill( register_alloc( 8 ), 0 );
rout = register_alloc( 8 );
if (!rz || !rout || !rnull)
{
printf(_("Allocation failed\n"));
}
printf(_("Read"));
for (i=0; i<((bytes)?bytes:1000); i++)
{
tap_shift_register( chain, rz, rout, 0 );
printf(_(" %s"), register_get_string(rout));
if (!bytes)
{
/* Abort Reading when a null IDCODE has been read */
if (!register_compare(rout, rnull))
hit++;
else
hit = 0;
if (hit >3)
break;
}
}
register_free( rz );
register_free( rnull );
register_free( rout );
printf(_("\n"));
}

@ -465,7 +465,13 @@ static int
ftdi_flush_output ( ftdi_params_t *p )
{
int xferred;
int i;
unsigned char * q;
// printf("ftdi_flush_output, length %d", p->outcount);
// for (i=0, q=p->outbuf; i<p->outcount; i++, q++)
// printf(" %01x", *q);
// printf("\n");
xferred = ftdi_write_data(p->fc, p->outbuf, p->outcount);
if (xferred < 0)
printf( _("Error from ftdi_write_data(): %d\n"), xferred);
@ -539,12 +545,15 @@ ftdi_get_data( parport_t *parport )
{
unsigned char d;
ftdi_params_t *p = parport->params;
int res = 0;
if (p->fc) {
while(ftdi_read_data( p->fc, &d, 1) == 0);
return d;
res = d;
} else
return 0;
res = 0;
// printf("ftdi_get_data %01x\n", d);
return res;
}
static int

Loading…
Cancel
Save