|
@@ -17,19 +17,20 @@ sub filelen($) {
|
|
|
|
|
|
return $s[7];
|
|
|
}
|
|
|
-sub makeheader($$$$) {
|
|
|
- my($zlen,$dlen,$dcrc,$address) = @_;
|
|
|
+sub makeheader($$$$$) {
|
|
|
+ my($target,$zlen,$dlen,$dcrc,$address) = @_;
|
|
|
|
|
|
- my $hdr = pack("V*", $SPIFLASH_MAGIC, $zlen, $dlen, $dcrc, $address,
|
|
|
- 0, 0);
|
|
|
+ my $hdr = pack("V*", $SPIFLASH_MAGIC, $zlen, $dlen, $dcrc, $address);
|
|
|
+ $hdr .= substr($target.("\0" x 8), 0, 8);
|
|
|
$hdr .= pack("V", Digest::CRC::crc32($hdr));
|
|
|
return $hdr;
|
|
|
}
|
|
|
|
|
|
+my $target = shift @ARGV;
|
|
|
my $outfile = shift @ARGV;
|
|
|
|
|
|
if (!defined($outfile)) {
|
|
|
- die "Usage: $0 outfile [infile addr]...\n";
|
|
|
+ die "Usage: $0 target_name outfile [infile addr]...\n";
|
|
|
}
|
|
|
|
|
|
open(my $out, '>', $outfile)
|
|
@@ -60,7 +61,7 @@ while (1) {
|
|
|
$dlen = unpack("V", substr($data, -4));
|
|
|
}
|
|
|
my $dcrc = Digest::CRC::crc32($data);
|
|
|
- print $out makeheader($zlen, $dlen, $dcrc, $inaddr);
|
|
|
+ print $out makeheader($target, $zlen, $dlen, $dcrc, $inaddr);
|
|
|
print $out $data;
|
|
|
if ($zlen & 3) {
|
|
|
# pad to dword boundary
|
|
@@ -74,5 +75,5 @@ if (defined($err)) {
|
|
|
die "$0: $err\n";
|
|
|
}
|
|
|
|
|
|
-print $out makeheader(0, 0, Digest::CRC::crc32(''), 0);
|
|
|
+print $out makeheader($target, 0, 0, Digest::CRC::crc32(''), 0);
|
|
|
close($out);
|