--- fw-info.pl 2007/04/22 14:42:56 5 +++ bin/fw-info.pl 2007/11/18 14:17:54 73 @@ -7,11 +7,29 @@ use strict; use Data::Dump qw/dump/; -my $path = shift @ARGV || die "Usage: $0 firmware.bin\n"; +my @images = @ARGV; +push @images, '/srv/tftp/BANT-R' unless @images; -open(my $fh, $path) || die "Can't open $path: $!"; -my $ver; -seek($fh, 32, 0) || die "can't seek to 32: $!"; -read($fh, $ver, 5); -print dump( $ver ), dump( unpack 'CCCCC', $ver ),$/; +my $magic = 'BLI223QH0'; +sub get_from { + my ($fh,$seek,$len) = @_; + my $b; + seek($fh, $seek, 0) || die "can't seek to $seek: $!"; + read($fh, $b, $len) || die "can't read $len bytes: $!"; + return $b; +} + +for my $path ( @images ) { + next unless -f $path; + open(my $fh, $path) || die "Can't open $path: $!"; + my $b; + read($fh, $b, length($magic)); + warn "# $path not a firmware image\n" unless ($b eq $magic); + my $version = get_from($fh, 32, 4); + my $board = get_from($fh, 0x136, 6); + my $name = get_from($fh, 0x144, 15); + chomp($name); + + printf("%8s %6s %s\t%s\n", join('.',unpack('CCCC', $version)), $board, $name, $path); +}