]> git.zerfleddert.de Git - proxmark3-svn/blame - tools/rbt2c.pl
(Our Windows ARM toolchain really likes its glue sections)
[proxmark3-svn] / tools / rbt2c.pl
CommitLineData
30f2a7d3 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
94f6d4a6 6local $/ = "\r\n";\r
7\r
30f2a7d3 8print "// Generated by rbt2c.pl, do not edit!\n\n";\r
9\r
10for(1..7) {\r
11 chomp($_ = <>);\r
12 print "//// $_\n";\r
13}\r
14\r
15print <<EOT;\r
16\r
17#include <proxmark3.h>\r
18\r
19const DWORD FpgaImage[] = {\r
20EOT\r
21\r
22while(<>) {\r
23 chomp;\r
24 $v = 0;\r
25 for $b (split(//, $_)) {\r
26 $v <<= 1;\r
27 if($b eq '1') {\r
28 $v |= 1;\r
29 } elsif($b ne '0') {\r
30 die;\r
31 }\r
32 }\r
33 printf("\t0x%08x,\n", $v);\r
34}\r
35\r
36print <<EOT;\r
37};\r
38\r
39const DWORD FpgaImageLen = sizeof(FpgaImage) / sizeof(FpgaImage[0]);\r
40\r
41EOT\r
Impressum, Datenschutz