]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl\r | |
2 | \r | |
3 | # This tool converts a Xilinx xxx.rbt FPGA bitstream to a table that will\r | |
4 | # compile as C source code. The output format is DWORDs, MSB first.\r | |
5 | \r | |
6 | print "// Generated by rbt2c.pl, do not edit!\n\n";\r | |
7 | \r | |
8 | for(1..7) {\r | |
9 | chomp($_ = <>);\r | |
10 | print "//// $_\n";\r | |
11 | }\r | |
12 | \r | |
13 | print <<EOT;\r | |
14 | \r | |
15 | #include <proxmark3.h>\r | |
16 | \r | |
17 | const DWORD FpgaImage[] = {\r | |
18 | EOT\r | |
19 | \r | |
20 | while(<>) {\r | |
21 | chomp;\r | |
22 | $v = 0;\r | |
23 | for $b (split(//, $_)) {\r | |
24 | $v <<= 1;\r | |
25 | if($b eq '1') {\r | |
26 | $v |= 1;\r | |
27 | } elsif($b ne '0') {\r | |
28 | die;\r | |
29 | }\r | |
30 | }\r | |
31 | printf("\t0x%08x,\n", $v);\r | |
32 | }\r | |
33 | \r | |
34 | print <<EOT;\r | |
35 | };\r | |
36 | \r | |
37 | const DWORD FpgaImageLen = sizeof(FpgaImage) / sizeof(FpgaImage[0]);\r | |
38 | \r | |
39 | EOT\r |