ask openocd for tap name
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 16 Jul 2016 16:45:21 +0000 (18:45 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 16 Jul 2016 16:45:21 +0000 (18:45 +0200)
openocd-jtag-boundary-scan.pl

index d16f465..2a3d9eb 100755 (executable)
@@ -12,7 +12,6 @@ my $bsdl_file = $ENV{BSDL} ||
        'EP4CE6E22.bsd';
 #      '_3128at100.bsd';
 #      '3064at44.bsd'; # XXX 
-my $tap = $ENV{TAP} || 'tb276.tap';
 my $project_file = 'Altera/epm3064_dac/3064at44.qsf';
 $project_file = 'tb276/f32c.qsf';
 
@@ -221,16 +220,12 @@ sub bin2hex {
         return unpack("H$hlen", pack("B$blen", $b));
 }
 
-#my $cmd;
-
 
+my $tap;
+print $sock "jtag names\n"; # will fill-in $tap variable from openocd
 
 my $BSR;
 
-# first sample
-print $sock "irscan $tap $opcode->{SAMPLE}\n"; # SAMPLE/PRELOAD
-print $sock "drscan $tap $BOUNDARY_LENGTH 0\n";
-
 while(1) {
 
 while (<$sock>) {
@@ -245,6 +240,14 @@ while (<$sock>) {
                print_io $bin if $bin ne $last_bits;
                gpio::pins() if $have_gpio;
                last;
+       } elsif ( m/^(\w+\.tap)$/ && !$tap ) {
+               $tap = $1;
+               warn "# using TAP $tap";
+
+               # first sample
+               print $sock "irscan $tap $opcode->{SAMPLE}\n"; # SAMPLE/PRELOAD
+               print $sock "drscan $tap $BOUNDARY_LENGTH 0\n";
+
        } else {
                warn "# in ",dump($_);
        }