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