/[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 5 by dpavlin, Sun Apr 22 14:42:56 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 || die "Usage: $0 firmware.bin\n";  my @images = @ARGV;
11    push @images, '/srv/tftp/BANT-R' unless @images;
12    
13  open(my $fh, $path) || die "Can't open $path: $!";  my $magic = 'BLI223QH0';
 my $ver;  
 seek($fh, 32, 0) || die "can't seek to 32: $!";  
 read($fh, $ver, 5);  
 print dump( $ver ), dump( unpack 'CCCCC', $ver ),$/;  
14    
15    sub get_from {
16            my ($fh,$seek,$len) = @_;
17            my $b;
18            seek($fh, $seek, 0) || die "can't seek to $seek: $!";
19            read($fh, $b, $len) || die "can't read $len bytes: $!";
20            return $b;
21    }
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.5  
changed lines
  Added in v.59

  ViewVC Help
Powered by ViewVC 1.1.26