1933730 "idcode" command (by U.Bonnes)
git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1151 b68d4a1b-bc3d-0410-92ed-d4ac073336b7master
parent
7f26d5814d
commit
b067b0d946
@ -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
|
||||
};
|
@ -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"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue