stellaris: automatically generate and update device IDs
[openocd.git] / contrib / gen-stellaris-part-header.pl
1 #!/usr/bin/perl
2 # Automatically generates the StellarisParts struct in src/flash/nor/stellaris.c
3 # Uses the header files from TI/Luminary's StellarisWare complete Firmware Development Package
4 # available from: http://www.luminarymicro.com/products/software_updates.html
5
6 $comment = "// Autogenerated by contrib/gen-stellaris-part-header.pl
7 // From Stellaris Firmware Development Package revision";
8
9 $struct_header = "static struct {
10 uint32_t partno;
11 const char *partname;
12 } StellarisParts[] =
13 {
14 ";
15
16 $struct_footer = "\t{0,\"Unknown part\"}\n};\n";
17
18 $#ARGV == 1 || die "Usage: $0 <inc directory> <output file>\n";
19 -d $ARGV[0] || die $ARGV[0]." is not a directory\n";
20 $dir = $ARGV[0];
21 -f $ARGV[1] || die $ARGV[1]." is not a file\n";
22 $file = $ARGV[1];
23 print STDERR "Scanning $dir, Updating $file\n";
24
25 opendir(DIR, $dir) || die "can't open $dir: $!";
26 @files = readdir(DIR);
27 closedir(DIR);
28
29 @short_files = sort(grep(/lm3s...\.h/, @files));
30 @long_files = sort(grep(/lm3s....\.h/, @files));
31
32 $ver = 0;
33 $new_struct = $struct_header;
34 process_file(@short_files);
35 process_file(@long_files);
36 $new_struct .= $struct_footer;
37
38 $dump = "$comment $ver\n$new_struct";
39 {
40 local($/, *INPUT);
41 open(INPUT, $file) || die "can't open $file: $!";
42 $contents = <INPUT>;
43 close(INPUT);
44 }
45
46 $old_struct = qr/((^\/\/.*?\n)*)\Q$struct_header\E.*?$struct_footer/sm;
47 $contents =~ s/$old_struct/$dump/;
48 open(OUTPUT, ">$file") || die "can't open file $file for writing: $!";
49 print OUTPUT $contents;
50 close(OUTPUT);
51
52 sub process_file {
53 foreach $h_file (@_) {
54 ($base) = ($h_file =~ m/lm3s(.{3,4})\.h/ig);
55 $base = uc($base);
56 local($/, *FILE);
57 open(FILE, "$dir/$h_file");
58 $content = <FILE>;
59 close(FILE);
60 $invalid = 0;
61 if ($content =~ /This is part of revision (\d+) of/) {
62 if ($ver != 0 and $ver != $1) {
63 print STDERR "File version mismatch: $ver != $1\n";
64 $ver = max($ver, $1);
65 } else {
66 $ver = $1;
67 }
68 }
69 if ($content =~ /SYSCTL_DID1_VER_[^M]\s+0x(\S+)/) {
70 $did1_ver = hex($1);
71 } else {
72 print STDERR "$h_file is missing SYSCTL_DID1_VER\n";
73 $did1_ver = 255;
74 $invalid = 1;
75 }
76 if ($content =~ /SYSCTL_DID1_PRTNO_$base\s+0x(\S+)/) {
77 $prtno = hex($1);
78 } else {
79 print STDERR "$h_file is missing SYSCTL_DID1_PRTNO\n";
80 $prtno = 0;
81 $invalid = 1;
82 }
83 $id = ($did1_ver | $prtno) >> 16;
84 $new_member = sprintf "{0x%04X,\"LM3S%s\"},", $id, $base;
85 if ($invalid == 1) {
86 #$new_struct .= "\t//$new_member\t// Invalid\n";
87 } else {
88 $new_struct .= "\t$new_member\n";
89 }
90 }
91 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)