aboutsummaryrefslogtreecommitdiff
path: root/src/helper/update_jep106.pl
diff options
context:
space:
mode:
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>2015-12-28 18:05:54 +0100
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2016-01-22 15:02:16 +0000
commit1919dbbfd23c699ecdc23d29ee3a79b2dc773571 (patch)
tree6fc1991f55d3c3fb1363f6ba1d45e6ddd1036eb7 /src/helper/update_jep106.pl
parentc520fdf902d0364681f358cd04f932f2a112cd78 (diff)
downloadriscv-openocd-1919dbbfd23c699ecdc23d29ee3a79b2dc773571.zip
riscv-openocd-1919dbbfd23c699ecdc23d29ee3a79b2dc773571.tar.gz
riscv-openocd-1919dbbfd23c699ecdc23d29ee3a79b2dc773571.tar.bz2
helper: Add converter from JEP106 ID to manufacturer name
Use it to print the manufacturer of detected TAPs Change-Id: Ic4384c61c7f6f7ae2a9b860a805a5997542f72cc Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/3177 Tested-by: jenkins Reviewed-by: Jiri Kastner <cz172638@gmail.com> Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Diffstat (limited to 'src/helper/update_jep106.pl')
-rwxr-xr-xsrc/helper/update_jep106.pl35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/helper/update_jep106.pl b/src/helper/update_jep106.pl
new file mode 100755
index 0000000..caec066
--- /dev/null
+++ b/src/helper/update_jep106.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use File::Basename;
+
+if (@ARGV != 1) {
+ die "Usage: $0 <JEP106 PDF document>\n\n"
+ . "Convert the JEDEC document containing manufacturer identification codes\n"
+ . "to an array initializer suitable for incusion into jep106.c. The latest\n"
+ . "version of the document can be found here:\n"
+ . "http://www.jedec.org/standards-documents/results/jep106\n";
+};
+
+my $outfile = dirname($0) . "/jep106.inc";
+
+open(my $out, ">", $outfile) || die "Cannot open $outfile: $!\n";
+open(my $pdftotext, "pdftotext -layout $ARGV[0] - |") || die "Cannot fork: $!\n";
+
+print $out "/* Autogenerated with " . basename($0) . "*/\n";
+
+my $bank = -1;
+
+while (<$pdftotext>) {
+ if (/^[0-9]+[[:space:]]+(.*?)[[:space:]]+([01][[:space:]]+){8}([0-9A-F]{2})$/) {
+ if ($3 eq "01") {
+ $bank++
+ }
+ my $id=sprintf("0x%02x",hex($3)&0x7f);
+ print $out "[$bank][$id - 1] = \"$1\",\n";
+ }
+}
+
+close $pdftotext || die "Error: $! $?\n";
+
+print $out "/* EOF */\n";