]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - tools/srecswap.pl
Added LF frequency adjustments from d18c7db, cleaned up code,
[proxmark3-svn] / tools / srecswap.pl
diff --git a/tools/srecswap.pl b/tools/srecswap.pl
new file mode 100644 (file)
index 0000000..24ef8e8
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/perl\r
+\r
+# endian-swap S records; we need this because the JTAG tools we're using\r
+# expect the memory image in byte-swapped format\r
+#\r
+# Jonathan Westhues, April 2004\r
+\r
+if(@ARGV == 0) {\r
+       die "usage: $0 file-to-endian-swap.s19 > out.s19\n";\r
+}\r
+\r
+while(<>) {\r
+       chomp;\r
+\r
+       if(/^S0/) {\r
+               next;\r
+       }\r
+       if(/^S7/) {\r
+               print "$_\n";\r
+               next;\r
+       }\r
+\r
+       if(not /^S3(..)(........)(.*)(..)$/) {\r
+               die "bad S record at line $.\n";\r
+       }\r
+\r
+       $data = $3;\r
+       $checksum = $4;\r
+\r
+       print "S3$1$2";\r
+       while($data =~ m#(..)(..)(..)(..)#g) {\r
+               print "$4$3$2$1";\r
+       }\r
+       print "$checksum\n";\r
+}\r
Impressum, Datenschutz