From 4ac2a571cc33d04b31cf251d13a38eb98c3d4fc2 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 12 Jun 2016 15:54:32 +0200 Subject: [PATCH] specify bsdl file and read boundary length from it --- openocd-jtag-boundary-scan.pl | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/openocd-jtag-boundary-scan.pl b/openocd-jtag-boundary-scan.pl index 3169f1b..1e381e7 100755 --- a/openocd-jtag-boundary-scan.pl +++ b/openocd-jtag-boundary-scan.pl @@ -8,6 +8,8 @@ use IO::Socket::INET; use Storable; my $openocd_remote = shift @ARGV || 'picam:4444'; +my $bsdl_file = $ENV{BSDL} || '_3128at100.bsd'; +my $BOUNDARY_LENGTH = 288; my $bit2pin; my $io2bit; @@ -18,7 +20,7 @@ my $pin_map = ''; $|=1; # flush stdout -open(my $bsdl, '<', '_3128at100.bsd'); +open(my $bsdl, '<', $bsdl_file); while(<$bsdl>) { if ( m/PIN_MAP_STRING/ ) { $pin_map .= $_; @@ -30,7 +32,11 @@ while(<$bsdl>) { } elsif ( m/"(\d+)\s+\(BC_\d+,\s+(\S+),\s+(\S+)/ ) { $bit2pin->{$1} = [ $2, $3 ]; push @{ $io2bit->{$2} }, $1; + } elsif ( m/attribute\s+BOUNDARY_LENGTH\s+of\s+\S+\s*:\s*entity\s+is\s+(\d+);/ ) { + $BOUNDARY_LENGTH = $1; + warn "# BSDL $bsdl_file BOUNDARY_LENGTH = $BOUNDARY_LENGTH\n"; } + } close($bsdl); @@ -118,7 +124,7 @@ my $BSR; # first sample print $sock "irscan x300.tap 0x55\n"; # SAMPLE/PRELOAD -print $sock "drscan x300.tap 288 0\n"; +print $sock "drscan x300.tap $BOUNDARY_LENGTH 0\n"; while(1) { @@ -148,7 +154,7 @@ sub diff_bits { if ( $o[$i] eq $n[$i] ) { $o[$i]='.'; } else { - my $pin = $bit2pin->{ 288 - ($i * 3) - 3 }->[0]; + my $pin = $bit2pin->{ $BOUNDARY_LENGTH - ($i * 3) - 3 }->[0]; $o[$i] = " $pin:" . $o[$i] . '>' . $n[$i]; } } @@ -181,7 +187,7 @@ if ( $cmd =~ /(p|o)(\d+)=(\d+)/ ) { ; - } elsif ( $what eq 'o' && $p < 288 ) { + } elsif ( $what eq 'o' && $p < $BOUNDARY_LENGTH ) { my $o = $p; #$b = substr($old_bsr,0,$o) . reverse $v . substr($old_bsr,$o+length($v)); $b = ( "0" x $o ) . reverse $v . ( "0" x ( length($old_bsr) - $o - length($v) ) ); @@ -196,17 +202,17 @@ warn "XXX",length($old_bsr), " == ",length($b); diff_bits( $BSR, $b ), $/; # print $sock "irscan x300.tap 0x55\n"; # SAMPLE/PRELOAD - print $sock "drscan x300.tap 288 0x", bin2hex($b), "\n"; + print $sock "drscan x300.tap $BOUNDARY_LENGTH 0x", bin2hex($b), "\n"; print $sock "irscan x300.tap 0x00\n"; # EXTEST -# print $sock "drscan x300.tap 288 0x", bin2hex($b), "\n"; +# print $sock "drscan x300.tap $BOUNDARY_LENGTH 0x", bin2hex($b), "\n"; } elsif ( $cmd =~ m/\?/ ) { $last_bits = ''; print $sock "irscan x300.tap 0x55\n"; # SAMPLE/PRELOAD - print $sock "drscan x300.tap 288 0\n"; + print $sock "drscan x300.tap $BOUNDARY_LENGTH 0\n"; } else { print $sock "irscan x300.tap 0x55\n"; # SAMPLE/PRELOAD - print $sock "drscan x300.tap 288 0\n"; + print $sock "drscan x300.tap $BOUNDARY_LENGTH 0\n"; } -- 2.20.1