tcl/interface: support for Raspberry Pi 5
[openocd.git] / src / helper / update_jep106.pl
blob60472e39756c9953d24b01a22a34bde4ec939127
1 #!/usr/bin/perl
2 # SPDX-License-Identifier: GPL-2.0-or-later
4 use strict;
5 use warnings;
6 use File::Basename;
8 if (@ARGV != 1) {
9 die "Usage: $0 <JEP106 PDF document>\n\n"
10 . "Convert the JEDEC document containing manufacturer identification codes\n"
11 . "to an array initializer suitable for inclusion into jep106.c. The latest\n"
12 . "version of the document can be found here:\n"
13 . "http://www.jedec.org/standards-documents/results/jep106\n";
16 my $outfile = dirname($0) . "/jep106.inc";
18 open(my $out, ">", $outfile) || die "Cannot open $outfile: $!\n";
19 open(my $pdftotext, "pdftotext -layout $ARGV[0] - |") || die "Cannot fork: $!\n";
21 print $out "/* Autogenerated with " . basename($0) . "*/\n";
23 my $bank = -1;
25 while (<$pdftotext>) {
26 if (/^[0-9]+[[:space:]]+(.*?)[[:space:]]+([01][[:space:]]+){8}([0-9A-F]{2})$/) {
27 if ($3 eq "01") {
28 $bank++
30 my $id=sprintf("0x%02x",hex($3)&0x7f);
31 print $out "[$bank][$id - 1] = \"$1\",\n";
35 close $pdftotext || die "Error: $! $?\n";
37 print $out "/* EOF */\n";