summaryrefslogtreecommitdiffstats
path: root/tools/romsizetest.pl
blob: 4dd8d401afbb005fbd2a7e5231aac6526f844fdc (plain)
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
#!/usr/bin/perl

#
# Check that the given file is smaller than the given size and if not, return
# an error code. Used to verify that the rombox.ucl file fits on the particular
# model you build for.

sub filesize {
    my ($filename)=@_;
    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
        $atime,$mtime,$ctime,$blksize,$blocks)
        = stat($filename);
    return $size;
}

my $romsize = 256*1024; # 256 KB

my $romstart = $ARGV[0];

if($romstart =~ /^0x(.*)/i) {
    $romstart = hex($romstart);
}


my $max = $romsize - $romstart;

my $file = filesize($ARGV[1]);

if($file > $max ) {
    printf "Output is %d bytes larger than max ($max)\n", $file-$max;
    exit 1;
}