/[mdap]/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 /fw-info.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (show annotations)
Fri Nov 16 23:44:29 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 833 byte(s)
 r80@brr:  dpavlin | 2007-11-17 00:44:22 +0100
 extract board and name from firmware

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
10 my @images = @ARGV;
11 push @images, '/srv/tftp/BANT-R' unless @images;
12
13 my $magic = 'BLI223QH0';
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 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26