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