From 49209d37da501059b41f5563d6d27e291dea4ffa Mon Sep 17 00:00:00 2001 From: d18c7db Date: Tue, 28 Jul 2009 01:03:09 +0000 Subject: [PATCH] merge-srec.pl create proper S19 file with checksums. --- tools/merge-srec.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/merge-srec.pl b/tools/merge-srec.pl index 852a96b8..683e6d3c 100644 --- a/tools/merge-srec.pl +++ b/tools/merge-srec.pl @@ -6,13 +6,18 @@ open(FLASH, $flashFile) or die "$flashFile: $!\n"; while() { print if /^S3/; + $EOF_record = $_ if /^S[789]/; } open(RAM, $ramFile) or die "$ramFile: $!\n"; while() { - if(/^S3(..)(........)(.*)/) { + if(/^S3(..)(........)(.*)([0-9a-fA-F]{2})/) { $addr = sprintf('%08X', hex($2) - 0x00200000 + 0x200); - print "S3$1$addr$3\n"; + $line = "$1$addr$3"; + $checksum = 0; + $checksum += $_ foreach map(hex, unpack("a2"x40, $line)); + print "S3$line", sprintf("%02X", ($checksum%256)^0xff ), "\n"; } } +print $EOF_record; -- 2.39.5