/[mdap]/bin/fw-info.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/fw-info.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 18 by dpavlin, Mon Apr 23 18:04:04 2007 UTC revision 59 by dpavlin, Fri Nov 16 23:44:29 2007 UTC
# Line 7  Line 7 
7  use strict;  use strict;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9    
10  my $path = shift @ARGV || '/srv/tftp/BANT-R'; # die "Usage: $0 firmware.bin\n";  my @images = @ARGV;
11    push @images, '/srv/tftp/BANT-R' unless @images;
12    
13  my $magic = 'BLI223QH0';  my $magic = 'BLI223QH0';
14    
15  open(my $fh, $path) || die "Can't open $path: $!";  sub get_from {
16  my $b;          my ($fh,$seek,$len) = @_;
17  read($fh, $b, length($magic));          my $b;
18  die "# $path not a firmware image\n" unless ($b eq $magic);          seek($fh, $seek, 0) || die "can't seek to $seek: $!";
19  seek($fh, 32, 0) || die "can't seek to 32: $!";          read($fh, $b, $len) || die "can't read $len bytes: $!";
20  read($fh, $b, 4);          return $b;
21  print join('.',unpack('CCCC', $b)),"\t$path\n";  }
22    
23    for my $path ( @images ) {
24            next unless -f $path;
25            open(my $fh, $path) || die "Can't open $path: $!";
26            my $b;
27            read($fh, $b, length($magic));
28            warn "# $path not a firmware image\n" unless ($b eq $magic);
29            my $version     = get_from($fh, 32, 4);
30            my $board       = get_from($fh, 0x136, 6);
31            my $name        = get_from($fh, 0x144, 15);
32            chomp($name);
33    
34            printf("%8s %6s %s\t%s\n", join('.',unpack('CCCC', $version)), $board, $name, $path);
35    }

Legend:
Removed from v.18  
changed lines
  Added in v.59

  ViewVC Help
Powered by ViewVC 1.1.26