]> git.zerfleddert.de Git - proxmark3-svn/blob - tools/srecswap.pl
syntax sugar
[proxmark3-svn] / tools / srecswap.pl
1 #!/usr/bin/perl
2
3 # endian-swap S records; we need this because the JTAG tools we're using
4 # expect the memory image in byte-swapped format
5 #
6 # Jonathan Westhues, April 2004
7
8 if(@ARGV == 0) {
9 die "usage: $0 file-to-endian-swap.s19 > out.s19\n";
10 }
11
12 while(<>) {
13 chomp;
14
15 if(/^S0/) {
16 next;
17 }
18 if(/^S7/) {
19 print "$_\n";
20 next;
21 }
22
23 if(not /^S3(..)(........)(.*)(..)$/) {
24 die "bad S record at line $.\n";
25 }
26
27 $data = $3;
28 $checksum = $4;
29
30 print "S3$1$2";
31 while($data =~ m#(..)(..)(..)(..)#g) {
32 print "$4$3$2$1";
33 }
34 print "$checksum\n";
35 }
Impressum, Datenschutz