1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/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;
}
sub cmd1line {
my ($c)=@_;
my @out=`$c 2>/dev/null`;
chomp $out[0];
return $out[0];
}
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;
}
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;
}
elsif($_ =~ / +0x([0-9a-f]+) *_dramcopystart = \./) {
$start = $1;
}
elsif($_ =~ / +0x([0-9a-f]+) *__start/) {
$start = $1;
}
}
close(M);
# return number of bytes
return hex($end) - hex($start);
}
sub features {
my ($f)=@_;
my $feat;
open(M, "<$f");
while(<M>) {
chomp;
if($feat) {
$feat.=":";
}
$feat.=$_;
}
close(M);
return $feat;
}
if(!$output) {
print "Usage: mkinfo.pl <filename>\n";
exit;
}
open(O, ">$output") || die "couldn't open $output for writing";
# Variables identifying the target, that should remain the same as long
# as the hardware is unmodified
printf O ("Target: %s\n", $ENV{'MODELNAME'});
printf O ("Target id: %d\n", $ENV{'TARGET_ID'});
printf O ("Target define: %s\n", $ENV{'TARGET'});
printf O ("Memory: %d\n", $ENV{'MEMORYSIZE'});
printf O ("CPU: %s\n", $ENV{'CPU'});
printf O ("Manufacturer: %s\n", $ENV{'MANUFACTURER'});
# Variables identifying Rockbox and bootloader properties. Possibly changing
# every software upgrade.
printf O ("Version: %s", `$ENV{TOOLSDIR}/version.sh $ENV{ROOTDIR}`);
printf O ("Binary: %s\n", $ENV{'BINARY'});
printf O ("Binary size: %s\n", filesize($ENV{'BINARY'}));
printf O ("Voice format: %s\n", definescan("$ENV{APPSDIR}/talk.h", "VOICE_VERSION"));
if ($ENV{'APPSDIR'} =~ /\/apps$/) {
if (-f "rockbox.bin") {
printf O ("Actual size: %s\n", filesize("rockbox.bin"));
} else {
printf O ("Actual size: %s\n", filesize($ENV{'BINARY'}));
}
printf O ("RAM usage: %s\n", mapscan("rockbox.map"));
printf O ("Features: %s\n", features("apps/features"));
} elsif ($ENV{'APPSDIR'} =~ /\/bootloader$/) {
if (-f "bootloader.bin") {
printf O ("Actual size: %s\n", filesize("bootloader.bin"));
} else {
printf O ("Actual size: %s\n", filesize($ENV{'BINARY'}));
}
printf O ("RAM usage: %s\n", mapscan("bootloader.map"));
}
# 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'});
close(O);
|