File: tos-write-image.in

package info (click to toggle)
tinyos-tools 1.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,140 kB
  • ctags: 1,626
  • sloc: cpp: 10,398; sh: 1,229; python: 1,200; ansic: 562; makefile: 305; xml: 24
file content (73 lines) | stat: -rw-r--r-- 1,593 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!@pathperl@ -w
#
# This script generates an ihex binary image and XML description
# from an srec binary image. These are used by the Deluge binary
# image dissemination service.
#
#$Id: tos-write-image.in,v 1.5 2007-04-27 05:01:25 prabal Exp $
#@author Jonathan Hui <jwhui@cs.berkeley.edu>
#
use strict;

my $MaxNameLength = 10;

if ( @ARGV == 0 ) {
  print "usage: tos-write-image [ident_flags] [exe_file]\n";
  exit 0;
}

my %ident_flags = ();
my $exe = "";
my $ihex = "";
my $objdump = "avr-objdump";
my $platform = "";

for my $arg (@ARGV) {
  if ($arg =~ /^-DIDENT_(.+)=0x(.+)$/) {
    $ident_flags{lc($1)} = uc($2);
  }
  elsif ($arg =~ /^-DIDENT_(.+)="(.+)"$/) {
    $ident_flags{lc($1)} = $2;
  }
  elsif ($arg =~ /^--ihex=(.+)$/) {
    $ihex = $1;
  }
  elsif ($arg =~ /^--exe=(.+)$/) {
    $exe = $1;
  }
  elsif ($arg =~ /^--objdump=(.+)$/) {
    $objdump = $1;
  }
  elsif ($arg =~ /^--platform=(.+)$/) {
    $platform = $1;
  }
}

my $deluge_support = "no";
# See if app has deluge included
open( EXE, "$objdump -t $exe |") or die "Cannot open exe file: $!\n";
while(<EXE>) {
  if ( /Deluge/ ) {
    $deluge_support = "yes";
  }
}
close(EXE);
$ident_flags{"deluge_support"} = $deluge_support;
$ident_flags{"platform"} = $platform;

open ( IHEX, $ihex ) or die "Cannot open ihex file: $!\n";

print "<tos_image>\n";
print "  <ident>\n";
for my $flag (keys %ident_flags) {
  print "    <$flag>$ident_flags{$flag}</$flag>\n";
}
print "  </ident>\n";
print "  <image format=\"ihex\">\n";

while ( my $line = <IHEX> ) {
  print $line;
}

print "  </image>\n";
print "</tos_image>\n";