sbsv1/abld/e32util/omapsig.pl
author jjkang
Fri, 25 Jun 2010 19:56:45 +0800
changeset 604 b33dd54aaa52
parent 599 fa7a3cc6effd
child 606 30b30f9da0b7
permissions -rw-r--r--
add cpptoolsplat
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# e32toolp\e32util\omapsig.pl
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# Description: 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
# Prepend OMAP boot signature to miniboot binaries
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
# Syntax:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
#	perl omapsig.pl <load address in hex> <input miniboot> <output minboot with sig>
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
use warnings;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
use IO::Handle;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
use File::Copy;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
if (scalar(@ARGV)!=3) {
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
	die "perl omapsig.pl <load address in hex> <input miniboot> <output minboot with sig>\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
my ($load_address, $infile, $outfile) = @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
$load_address = pack('L', hex($load_address));
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
my $filesize_in_bytes = -s $infile;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
print "miniboot input ", $filesize_in_bytes, " bytes\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
$filesize_in_bytes = pack('L', $filesize_in_bytes);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
open my $in, "< $infile" or die "Can't open $infile for input: $!";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
binmode($in);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
open my $out, "> $outfile" or die "Can't open $outfile for output: $!";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
binmode($out);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
$out->autoflush(1);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
print $out $filesize_in_bytes;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
print $out $load_address;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
copy($in, $out) or die "Couldn't copy from $infile to $outfile: $!";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
close $in;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
close $out;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
print "signed miniboot output ", -s $outfile, " bytes\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
exit;