Remaining diffs from gumstix repository: Add debug, test and shell command, aliases for parts, small fixes.

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@731 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Kolja Waschk 17 years ago
parent 2b8ab248ff
commit 851277f003

@ -32,11 +32,11 @@
#define BSBIT_INTERNAL 4
#define BSBIT_BIDIR 5
char dev_name[64]="";
int IR_l=0;
int BR_l=0;
int idcode[64];
int id_num=0;
static char dev_name[64]="";
static int IR_l=0;
static int BR_l=0;
static int idcode[64];
static int id_num=0;
struct bsbit {
int bit;
char name[32];
@ -47,13 +47,13 @@ struct bsbit {
int control_value;
int control_state;
} *bs_bits;
char insts[100][2][64];
int inst_num=0;
char pins[2048][16], pinsp[2048][1024];
int pins_num=-1;
static char insts[100][2][64];
static int inst_num=0;
static char pins[2048][16], pinsp[2048][1024];
static int pins_num=-1;
char line[1024], pline[1024];
int mode;
static char line[1024], pline[1024];
static int mode;
int endline(void) {
@ -63,7 +63,7 @@ int endline(void) {
// if(pline[0])printf("%s\n", pline);
if(!strncmp(pline, "entity ", 7)) {
if(dev_name[0]==0) sscanf(pline, "entity %s", dev_name);
if(dev_name[0]=='\0') (void)sscanf(pline, "entity %s", dev_name);
mode=0;
} else
if(!strncmp(pline, "attribute ", 10)) {
@ -79,6 +79,7 @@ int endline(void) {
if(i!=2) return -3;
BR_l=j;
bs_bits=malloc(BR_l * sizeof(struct bsbit));
if(bs_bits==NULL)return -80; /* djf */
for(i=0;i<BR_l;i++)bs_bits[i].bit=-1;
} else
if(!strncmp(att, "IDCODE_REGISTER", 15)) {

@ -229,6 +229,7 @@ const bus_driver_t ppc440gx_ebc8_bus = {
ppc440gx_ebc8_bus_read_end,
ppc440gx_ebc8_bus_read,
ppc440gx_ebc8_bus_write,
NULL
};
static bus_t *

@ -43,6 +43,9 @@ libcmd_a_SOURCES = \
shift.c \
dr.c \
get.c \
test.c \
debug.c \
shell.c \
set.c \
endian.c \
peekpoke.c \

@ -50,6 +50,8 @@ extern cmd_t cmd_instruction;
extern cmd_t cmd_shift;
extern cmd_t cmd_dr;
extern cmd_t cmd_get;
extern cmd_t cmd_test;
extern cmd_t cmd_shell;
extern cmd_t cmd_set;
extern cmd_t cmd_endian;
extern cmd_t cmd_peek;
@ -62,6 +64,7 @@ extern cmd_t cmd_eraseflash;
extern cmd_t cmd_script;
extern cmd_t cmd_include;
extern cmd_t cmd_svf;
extern cmd_t cmd_debug;
const cmd_t *cmds[] = {
&cmd_quit,
@ -83,6 +86,8 @@ const cmd_t *cmds[] = {
&cmd_shift,
&cmd_dr,
&cmd_get,
&cmd_test,
&cmd_shell,
&cmd_set,
&cmd_endian,
&cmd_peek,
@ -95,6 +100,7 @@ const cmd_t *cmds[] = {
&cmd_script,
&cmd_include,
&cmd_svf,
&cmd_debug,
NULL /* last must be NULL */
};

@ -0,0 +1,70 @@
/*
* $Id: debug.c,v 1.0 2005/10/10 00:00:0 DJF $
*
* Copyright (C) 2005 Protoparts
*
* 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 David Farrell, 2005
* based on templates by and portions Written by Marcel Telka <marcel@telka.sk>, 2003.i
*
*/
#include "sysdep.h"
#include <stdio.h>
#include <string.h>
//#include <stdlib.h>
//#include "part.h"
//#include "bssignal.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_debug_run( char *params[] )
{
int data,i;
signal_t *s;
if (cmd_params( params ) != 2)
return -1;
if (cmd_get_number( params[1], &i ))
return 1;
debug_mode = i;
return 1;
}
static void
cmd_debug_help( void )
{
printf( _(
"Usage: %s n\n"
"Enabled debugging.\n"
"\n"
"n =1 fileio, 2=tap commands, 4 =?\n"
), "debug n" );
}
cmd_t cmd_debug = {
"debug",
N_("debug jtag program"),
cmd_debug_help,
cmd_debug_run
};

@ -36,6 +36,18 @@ cmd_part_run( char *params[] )
{
unsigned int n;
/* part alias U1 (3 params) */
if(cmd_params( params ) == 3) {
if(strcasecmp(params[1],"alias") == 0) {
part_t *part;
part = chain->parts->parts[chain->active_part];
part->alias = malloc(strlen(params[2])+1);
strcpy(part->alias,params[2]);
return 1;
}
}
if (cmd_params( params ) != 2)
return -1;
@ -47,8 +59,22 @@ cmd_part_run( char *params[] )
return 1;
}
if (cmd_get_number( params[1], &n ))
return -1;
/* Search for alias too djf */
if (cmd_get_number( params[1], &n )) {
/* Search all parts to check their aliases */
int i;
char *a;
for(i=0;i<chain->parts->len;i++) {
a = chain->parts->parts[i]->alias;
if(a && strcmp(a,params[1]) == 0)break;
}
if(i < chain->parts->len)n = i;
else return -1;
}
if (n >= chain->parts->len) {
printf( _("%s: invalid part number\n"), "part" );
@ -67,7 +93,7 @@ cmd_part_help( void )
"Usage: %s PART\n"
"Change active part for current JTAG chain.\n"
"\n"
"PART part number\n"
"PART part number | alias\n"
), "part" );
}

@ -58,10 +58,24 @@ cmd_print_run( char *params[] )
}
if (cmd_params( params ) == 2) {
if ((strcasecmp( params[1], "chain" ) != 0) && (strcasecmp( params[1], "bus") != 0))
return -1;
if (strcasecmp( params[1], "bus") == 0)
noheader = 1;
if (strcasecmp( params[1], "signals") == 0) {
printf("Signals:\n");
part_t *part;
signal_t *s;
part = chain->parts->parts[chain->active_part];
for(s = part->signals;s != NULL;s = s->next) {
if(s->pin)printf("%s %s",s->name,s->pin);
else printf("%s",s->name);
if(s->input)printf("\tinput=%s",s->input->name);
if(s->output)printf("\toutput=%s",s->output->name);
printf("\n");
}
return(1);
}
}
if (noheader == 0) {
@ -87,7 +101,11 @@ cmd_print_run( char *params[] )
if (cmd_params( params ) == 1) {
if (chain->parts->len > chain->active_part) {
printf( _(" %3d "), chain->active_part );
if(chain->parts->parts[chain->active_part]->alias)
printf( _(" %3d %s "), chain->active_part,chain->parts->parts[chain->active_part]->alias );
else
printf( _(" %3d "), chain->active_part);
part_print( chain->parts->parts[chain->active_part] );
}
if (bus != NULL) {
@ -138,7 +156,7 @@ static void
cmd_print_help( void )
{
printf( _(
"Usage: %s [chain|bus]\n"
"Usage: %s [chain|bus|signals]\n"
"Display JTAG chain status.\n"
"\n"
"Display list of the parts connected to the JTAG chain including\n"

@ -33,15 +33,25 @@
static int
cmd_script_run( char *params[] )
{
int go;
int i,j;
if (cmd_params( params ) != 2)
int go;
i = 0; j = 1;
if (cmd_params( params ) == 3) {
sscanf(params[2],"%d",&j); /* loop n times option */
}
else 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] );
for(i=0;i<j;i++) {
go = jtag_parse_file( params[1] );
if (go < 0) {
if(go != -99)printf( _("Unable to open file `%s go=%s'!\n"), params[1], go );
break;
}
}
if(debug_mode & 1)printf("Return at cmd_script_run\n");
return go ? 1 : 0;
}
@ -49,8 +59,8 @@ static void
cmd_script_help( void )
{
printf( _(
"Usage: %s FILENAME\n"
"Run command sequence from external FILENAME.\n"
"Usage: %s FILENAME [n] \n"
"Run command sequence n times from external FILENAME.\n"
"\n"
"FILENAME Name of the file with commands\n"
), "script" );

@ -0,0 +1,80 @@
/*
* $Id: shell.c,v 1.6 2003/08/19 08:42:20 telka Exp $
*
* 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.
* shell.c added by djf
*/
#include "sysdep.h"
//#include <stdio.h>
//#include <string.h>
#include <stdlib.h>
//#include "part.h"
//#include "bssignal.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_shell_run( char *params[] )
{
int n,l1,l2;
char *t;
if((n=cmd_params( params )) == 1)
return -1;
/* I must apologize to everyone who knows what they are doing for
* the following. If you can pass a shell argument past strtok the
* please fix this.
*/
l1 = strlen(params[1]);
l2 = strlen(params[2]);
t = malloc(l1+l2+2); /* space + term */
strcpy(t,params[1]); /* main command */
if(n == 3) {
*(t+l1)= ' '; /* add space */
strcpy((t+l1+1),params[2]);
}
system(t);
return 1;
}
static void
cmd_shell_help( void )
{
printf( _(
"Usage: %s cmmd\n"
"Shell out to os for a command.\n"
"\n"
"CMMD OS Shell Command\n"
), "shell cmmd" );
}
cmd_t cmd_shell = {
"shell",
N_("shell cmmd"),
cmd_shell_help,
cmd_shell_run
};

@ -37,8 +37,9 @@ cmd_signal_run( char *params[] )
{
part_t *part;
signal_t *s;
int i;
if (cmd_params( params ) < 2)
if ((i = cmd_params( params )) < 2)
return -1;
@ -56,12 +57,33 @@ cmd_signal_run( char *params[] )
}
part = chain->parts->parts[chain->active_part];
if (part_find_signal( part, params[1] ) != NULL) {
printf( _("Signal '%s' already defined\n"), params[1] );
return 1;
if ((s = part_find_signal( part, params[1] )) != NULL) {
if(i == 3) {
printf("Defining pin for signal %s\m",s->name);
if(s->pin)free(s->pin); /* erase old */
/* Allocate the space for the pin number & copy it */
s->pin = malloc(strlen(params[2])+1);
strcpy(s->pin,params[2]);
return 1;
}
else {
printf( _("Signal '%s' already defined\n"), params[1] );
return 1;
}
}
s = signal_alloc( params[1]);
if(i == 3) { /* Add pin number */
/* Allocate the space for the pin number & copy it */
s->pin = malloc(strlen(params[2])+1);
strcpy(s->pin,params[2]);
}
s = signal_alloc( params[1] );
if (!s) {
printf( _("out of memory\n") );
return 1;
@ -77,11 +99,11 @@ static void
cmd_signal_help( void )
{
printf( _(
"Usage: %s SIGNAL [PINLIST...]\n"
"Usage: %s SIGNAL [PIN#]\n"
"Define new signal with name SIGNAL for a part.\n"
"\n"
"SIGNAL New signal name\n"
"PINLIST List of pins for a signal (not used)\n"
"SIGNAL New signal name\n"
"PIN# List of pin # for a signal\n"
), "signal" );
}

@ -0,0 +1,101 @@
/*
* $Id: test.c,v 1.0 2005/10/10 00:00:0 DJF $
*
* Copyright (C) 2005 Protoparts
*
* 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 David Farrell, 2005
* based on templates by and portions Written by Marcel Telka <marcel@telka.sk>, 2003.i
*
*/
#include "sysdep.h"
#include <stdio.h>
#include <string.h>
//#include <stdlib.h>
#include "part.h"
#include "bssignal.h"
#include "jtag.h"
#include "cmd.h"
static int
cmd_test_run( char *params[] )
{
int data,i;
signal_t *s;
if (cmd_params( params ) != 4)
return -1;
if (strcmp( params[1], "signal") != 0)
return -1;
if (!cmd_test_cable())
return 1;
if (!chain->parts) {
printf( _("Run \"detect\" first.\n") );
return 1;
}
if (chain->active_part >= chain->parts->len) {
printf( _("%s: no active part\n"), "get" );
return 1;
}
s = part_find_signal( chain->parts->parts[chain->active_part], params[2] );
if (!s) {
printf( _("signal '%s' not found\n"), params[2] );
return 1;
}
/* values 0,1,X since X is not a number, the following failure exits clean
* and doesnt test anything, as it should.
*/
if (cmd_get_number( params[3], &i ))
return 1;
data = part_get_signal( chain->parts->parts[chain->active_part], s );
if (data != -1) {
if(data != i) {
printf( _("<FAIL>%s = %d\n"), params[2], data );
return -99;
}
}
return 1;
}
static void
cmd_test_help( void )
{
printf( _(
"Usage: %s SIGNAL 0/1\n"
"Test signal state from output BSR (Boundary Scan Register).\n"
"\n"
"SIGNAL signal name (from JTAG declaration file)\n"
), "get signal" );
}
cmd_t cmd_test = {
"test",
N_("test external signal value"),
cmd_test_help,
cmd_test_run
};

@ -160,6 +160,20 @@ find_record( char *filename, tap_register *key, struct id_record *idr )
return r;
}
unsigned long bits_to_long(tap_register *t) {
int i;
unsigned long l,b;
l = 0; b=1;
for(i=0;i < t->len ;i++) {
if(t->data[i] & 1)l |= b;
b <<= 1;
// printf("%01d",t->data[i]);
}
return l;
}
int
detect_parts( chain_t *chain, char *db_path )
{
@ -246,7 +260,7 @@ detect_parts( chain_t *chain, char *db_path )
did = id;
}
printf( _("Device Id: %s\n"), register_get_string( did ) );
printf( _("Device Id: %s (0x%08X)\n"), register_get_string( did ), bits_to_long(did) );
part = part_alloc( did );
if (part == NULL) {
printf( _("Out of memory\n") );
@ -297,7 +311,7 @@ detect_parts( chain_t *chain, char *db_path )
}
register_free( key );
printf( _(" Part: %s\n"), idr.fullname );
printf( _(" Part(%d): %s\n"), chain->active_part, idr.fullname );
if (strlen( idr.fullname ) > MAXLEN_PART)
printf( _("Warning: Part too long\n") );
strncpy( partname, idr.fullname, MAXLEN_PART );

@ -37,7 +37,7 @@ part_alloc( const tap_register *id )
part_t *p = malloc( sizeof *p );
if (!p)
return NULL;
p->alias = NULL; /* djf */
p->id = register_duplicate( id );
p->manufacturer[0] = '\0';
p->part[0] = '\0';
@ -65,6 +65,8 @@ part_free( part_t *p )
/* id */
free( p->id );
if(p->alias)free(p->alias); /* djf */
/* signals */
while (p->signals) {
signal_t *s = p->signals;

@ -39,6 +39,7 @@ signal_alloc( const char *name )
free( s );
return NULL;
}
s->pin = NULL; /* djf hack pin number */
s->next = NULL;
s->input = NULL;
s->output = NULL;

Loading…
Cancel
Save