/[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

Contents of /bin/fw-info.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 76 - (show annotations)
Sun Nov 18 15:20:16 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 1178 byte(s)
 r114@brr:  dpavlin | 2007-11-18 16:20:12 +0100
 display selected firmwares for each board

1 #!/usr/bin/perl -w
2
3 # fw-info.pl
4 #
5 # 04/22/07 16:33:13 CEST Dobrica Pavlinusic <dpavlin@rot13.org>
6
7 use strict;
8 use Data::Dump qw/dump/;
9 use File::Find;
10
11 my $debug = 0;
12
13 my @images = @ARGV;
14 push @images, '/srv/tftp/BANT-R' unless @images;
15
16 my $magic = 'BLI223Q';
17
18 sub get_from {
19 my ($fh,$seek,$len) = @_;
20 my $b;
21 seek($fh, $seek, 0) || die "can't seek to $seek: $!";
22 read($fh, $b, $len) || die "can't read $len bytes: $!";
23 return $b;
24 }
25
26 sub firmware {
27 my $path = shift;
28 open(my $fh, $path) || die "Can't open $path: $!";
29 my $b;
30 read($fh, $b, length($magic));
31 if ($b ne $magic) {
32 warn "# $path not a firmware image\n";
33 return;
34 }
35 my $version = get_from($fh, 32, 4);
36 my $board = get_from($fh, 0x136, 6);
37 my $name = get_from($fh, 0x144, 15);
38 chomp($name);
39 $version = join('.',unpack('CCCC', $version));
40 printf("%-8s %6s %s\t%s\n", $version, $board, $name, $path);
41 }
42
43 for my $path ( @images ) {
44 warn "# ? $path\n" if $debug;
45 if ( -d $path ) {
46 find( sub {
47 my $path = $File::Find::name;
48 warn "# ?? $path\n" if $debug;
49 firmware( $path ) if -f $path;
50 }, $path );
51 } elsif ( -f $path ) {
52 firmware( $path );
53 } else {
54 warn "# unknown: $path\n";
55 }
56 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26