2007-04-20 12:53:40 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
|
|
|
#
|
|
|
|
# Purpose: extract and gather info from a build and put that in a standard
|
|
|
|
# way in the output file. Meant to be put in rockbox zip package to help and
|
|
|
|
# aid machine installers and more.
|
|
|
|
#
|
|
|
|
|
|
|
|
my $output = $ARGV[0];
|
|
|
|
|
|
|
|
sub filesize {
|
|
|
|
my ($f)=@_;
|
|
|
|
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
|
|
|
$atime,$mtime,$ctime,$blksize,$blocks)
|
|
|
|
= stat($f);
|
|
|
|
return $size;
|
|
|
|
}
|
|
|
|
|
2007-04-20 13:36:56 +00:00
|
|
|
sub cmd1line {
|
|
|
|
my ($c)=@_;
|
|
|
|
my @out=`$c 2>/dev/null`;
|
|
|
|
chomp $out[0];
|
|
|
|
return $out[0];
|
|
|
|
}
|
|
|
|
|
2012-06-01 20:51:48 +00:00
|
|
|
sub definescan {
|
|
|
|
my ($f, $d)=($_[0], $_[1]);
|
|
|
|
my $v;
|
|
|
|
open(M, "<$f");
|
|
|
|
while(<M>) {
|
|
|
|
if($_ =~ /\#define\s+$d\s+([^\s]+)\s?/) {
|
|
|
|
$v = $1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(M);
|
|
|
|
|
|
|
|
return $v;
|
|
|
|
}
|
|
|
|
|
2007-08-16 08:10:45 +00:00
|
|
|
sub mapscan {
|
|
|
|
my ($f)=@_;
|
|
|
|
my $start, $end;
|
|
|
|
open(M, "<$f");
|
|
|
|
while(<M>) {
|
|
|
|
if($_ =~ / +0x([0-9a-f]+) *_end = \./) {
|
|
|
|
$end = $1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
elsif($_ =~ / +0x([0-9a-f]+) *_loadaddress = \./) {
|
|
|
|
$start = $1;
|
|
|
|
}
|
2020-07-15 18:08:14 +00:00
|
|
|
elsif($_ =~ / +0x([0-9a-f]+) *_dramcopystart = \./) {
|
|
|
|
$start = $1;
|
|
|
|
}
|
|
|
|
elsif($_ =~ / +0x([0-9a-f]+) *__start/) {
|
|
|
|
$start = $1;
|
|
|
|
}
|
2007-08-16 08:10:45 +00:00
|
|
|
}
|
2007-08-16 08:14:03 +00:00
|
|
|
close(M);
|
|
|
|
|
2007-08-16 08:10:45 +00:00
|
|
|
# return number of bytes
|
|
|
|
return hex($end) - hex($start);
|
|
|
|
}
|
|
|
|
|
2008-01-11 16:00:20 +00:00
|
|
|
sub features {
|
|
|
|
my ($f)=@_;
|
|
|
|
my $feat;
|
|
|
|
open(M, "<$f");
|
|
|
|
while(<M>) {
|
|
|
|
chomp;
|
|
|
|
if($feat) {
|
|
|
|
$feat.=":";
|
|
|
|
}
|
|
|
|
$feat.=$_;
|
|
|
|
}
|
|
|
|
close(M);
|
|
|
|
return $feat;
|
|
|
|
}
|
|
|
|
|
2007-04-20 12:53:40 +00:00
|
|
|
if(!$output) {
|
|
|
|
print "Usage: mkinfo.pl <filename>\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
open(O, ">$output") || die "couldn't open $output for writing";
|
|
|
|
|
2007-04-20 13:36:56 +00:00
|
|
|
# Variables identifying the target, that should remain the same as long
|
|
|
|
# as the hardware is unmodified
|
2008-02-25 18:12:11 +00:00
|
|
|
printf O ("Target: %s\n", $ENV{'MODELNAME'});
|
2007-04-20 12:53:40 +00:00
|
|
|
printf O ("Target id: %d\n", $ENV{'TARGET_ID'});
|
|
|
|
printf O ("Target define: %s\n", $ENV{'TARGET'});
|
2007-04-20 13:36:56 +00:00
|
|
|
printf O ("Memory: %d\n", $ENV{'MEMORYSIZE'});
|
2007-04-20 13:47:30 +00:00
|
|
|
printf O ("CPU: %s\n", $ENV{'CPU'});
|
|
|
|
printf O ("Manufacturer: %s\n", $ENV{'MANUFACTURER'});
|
2007-04-20 13:36:56 +00:00
|
|
|
|
|
|
|
# Variables identifying Rockbox and bootloader properties. Possibly changing
|
|
|
|
# every software upgrade.
|
2010-05-27 09:58:07 +00:00
|
|
|
printf O ("Version: %s", `$ENV{TOOLSDIR}/version.sh $ENV{ROOTDIR}`);
|
2007-04-20 12:53:40 +00:00
|
|
|
printf O ("Binary: %s\n", $ENV{'BINARY'});
|
|
|
|
printf O ("Binary size: %s\n", filesize($ENV{'BINARY'}));
|
2012-06-01 20:51:48 +00:00
|
|
|
printf O ("Voice format: %s\n", definescan("$ENV{APPSDIR}/talk.h", "VOICE_VERSION"));
|
2008-10-31 00:59:17 +00:00
|
|
|
|
|
|
|
if ($ENV{'APPSDIR'} =~ /\/apps$/) {
|
2020-05-17 13:31:45 +00:00
|
|
|
if (-f "rockbox.bin") {
|
|
|
|
printf O ("Actual size: %s\n", filesize("rockbox.bin"));
|
|
|
|
} else {
|
|
|
|
printf O ("Actual size: %s\n", filesize($ENV{'BINARY'}));
|
|
|
|
}
|
2008-11-20 16:05:06 +00:00
|
|
|
printf O ("RAM usage: %s\n", mapscan("rockbox.map"));
|
2008-10-31 00:59:17 +00:00
|
|
|
printf O ("Features: %s\n", features("apps/features"));
|
|
|
|
} elsif ($ENV{'APPSDIR'} =~ /\/bootloader$/) {
|
2020-05-17 13:31:45 +00:00
|
|
|
if (-f "bootloader.bin") {
|
|
|
|
printf O ("Actual size: %s\n", filesize("bootloader.bin"));
|
|
|
|
} else {
|
|
|
|
printf O ("Actual size: %s\n", filesize($ENV{'BINARY'}));
|
|
|
|
}
|
2008-11-20 16:05:06 +00:00
|
|
|
printf O ("RAM usage: %s\n", mapscan("bootloader.map"));
|
2008-10-31 00:59:17 +00:00
|
|
|
}
|
2007-04-20 12:53:40 +00:00
|
|
|
|
2007-04-20 13:36:56 +00:00
|
|
|
# Variables identifying tool and build environment details
|
|
|
|
printf O ("gcc: %s\n", cmd1line("$ENV{'CC'} --version"));
|
|
|
|
printf O ("ld: %s\n", cmd1line("$ENV{'LD'} --version"));
|
|
|
|
printf O ("Host gcc: %s\n", cmd1line("$ENV{'HOSTCC'} --version"));
|
|
|
|
printf O ("Host system: %s\n", $ENV{'UNAME'});
|
2007-04-20 12:53:40 +00:00
|
|
|
|
|
|
|
close(O);
|