]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
merge-srec.pl create proper S19 file with checksums.
authord18c7db <d18c7db@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 28 Jul 2009 01:03:09 +0000 (01:03 +0000)
committerd18c7db <d18c7db@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 28 Jul 2009 01:03:09 +0000 (01:03 +0000)
tools/merge-srec.pl

index 852a96b8f7d61a5bbd74366967610f2d09c8cc10..683e6d3c3f6ed5bb0bce126214fc0f7956411cff 100644 (file)
@@ -6,13 +6,18 @@ open(FLASH, $flashFile) or die "$flashFile: $!\n";
 \r
 while(<FLASH>) {\r
        print if /^S3/;\r
+       $EOF_record = $_ if /^S[789]/;\r
 }\r
 \r
 open(RAM, $ramFile) or die "$ramFile: $!\n";\r
 \r
 while(<RAM>) {\r
-       if(/^S3(..)(........)(.*)/) {\r
+       if(/^S3(..)(........)(.*)([0-9a-fA-F]{2})/) {\r
                $addr = sprintf('%08X', hex($2) - 0x00200000 + 0x200);\r
-               print "S3$1$addr$3\n";\r
+               $line = "$1$addr$3";\r
+               $checksum = 0;\r
+               $checksum += $_ foreach map(hex, unpack("a2"x40, $line));\r
+               print "S3$line", sprintf("%02X", ($checksum%256)^0xff ), "\n";\r
        }\r
 }\r
+print $EOF_record;\r
Impressum, Datenschutz