|
1 #!/usr/bin/perl |
|
2 # e32toolp\e32util\omapsig.pl |
|
3 # |
|
4 # Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
5 # All rights reserved. |
|
6 # This component and the accompanying materials are made available |
|
7 # under the terms of "Eclipse Public License v1.0" |
|
8 # which accompanies this distribution, and is available |
|
9 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
10 # |
|
11 # Initial Contributors: |
|
12 # Nokia Corporation - initial contribution. |
|
13 # |
|
14 # Contributors: |
|
15 # |
|
16 # Description: |
|
17 # |
|
18 # Prepend OMAP boot signature to miniboot binaries |
|
19 # |
|
20 # Syntax: |
|
21 # perl omapsig.pl <load address in hex> <input miniboot> <output minboot with sig> |
|
22 # |
|
23 |
|
24 use warnings; |
|
25 use IO::Handle; |
|
26 use File::Copy; |
|
27 |
|
28 # Version |
|
29 my $MajorVersion = 1; |
|
30 my $MinorVersion = 1; |
|
31 my $PatchVersion = 0; |
|
32 |
|
33 if (scalar(@ARGV)!=3) { |
|
34 die "OMAPSIG signature tool V$MajorVersion.$MinorVersion.$PatchVersion\nperl omapsig.pl <load address in hex> <input miniboot> <output minboot with sig>\n"; |
|
35 } |
|
36 |
|
37 my ($load_address, $infile, $outfile) = @ARGV; |
|
38 |
|
39 $load_address = pack('L', hex($load_address)); |
|
40 |
|
41 my $filesize_in_bytes = -s $infile; |
|
42 |
|
43 print "miniboot input ", $filesize_in_bytes, " bytes\n"; |
|
44 |
|
45 $filesize_in_bytes = pack('L', $filesize_in_bytes); |
|
46 |
|
47 open my $in, "< $infile" or die "Can't open $infile for input: $!"; |
|
48 binmode($in); |
|
49 open my $out, "> $outfile" or die "Can't open $outfile for output: $!"; |
|
50 binmode($out); |
|
51 $out->autoflush(1); |
|
52 |
|
53 print $out $filesize_in_bytes; |
|
54 print $out $load_address; |
|
55 |
|
56 copy($in, $out) or die "Couldn't copy from $infile to $outfile: $!"; |
|
57 |
|
58 close $in; |
|
59 close $out; |
|
60 |
|
61 print "signed miniboot output ", -s $outfile, " bytes\n"; |
|
62 exit; |