Commit 4dd8ff10 authored by David Johnson's avatar David Johnson
Browse files

Fixes a fun little bug that's been screwing me over for awhile now.

Basically, tbuisp was checking if a file was an exe or srec based on
extension.  This was failing when tbuisp was invoked from xmlrpc, because
the rpc server created a temp file without a .exe extension.  Thus, tbuisp
thought that the file was an srec (since it wasn't an exe)... and motes
were not getting programmed properly.  tbuisp now distinguishes which type
the file is using avr-objdump, and matching the format.  The downside of
this is that we'll need to support different kinds of exe binary types as
we add different kinds of motes (i.e., the binary type for our avr-based
motes is elf32-avr... surely the telos motes will have a different type).
parent b4e79830
......@@ -43,6 +43,7 @@ my $SETID = "$TB/bin/set-mote-id";
my $TMPDIR = "/tmp";
my $DEBUG = 1;
my $OBJDUMP= "/usr/local/bin/avr-objdump";
# Handle command-line arguments
......@@ -194,12 +195,63 @@ if ($filename) {
my $tmpfile;
my $isexe = 0;
if ($filename =~ /\.exe$/) {
print "exe file, extra processing will be done\n";
$tmpfile = "$TMPDIR/tbuisp.$$.srec";
$isexe = 1;
# this is only broken because when an exe is uploaded via the xmlrpc stuff,
# a tmp file is created WITHOUT the .exe extension. Consequently, we check
# using avr-objcopy.
# to figure out what format it is, we look for the string 'file format',
# followed by a another string.
# currently, 'srec' corresponds to an srec, and 'elf32-avr' corresponds to an
# exe. THIS WILL CHANGE for different mote archs!
my @exe_strs = ("elf32-avr");
my $srec_str = "srec";
my @output = `$OBJDUMP -f $filename`;
my $line;
my $check = 0;
foreach $line (@output) {
if ($line =~ /file format\s+(.+)$/) {
$check = 1;
# match srec
if ($srec_str eq $1) {
$isexe = 0;
print "Binary is format $srec_str!\n";
else {
my $type;
foreach $type (@exe_strs) {
if ($type eq $1) {
$isexe = 1;
print "exe file, extra processing will be done\n";
$tmpfile = "$TMPDIR/tbuisp.$$.srec";
print "Binary is format $type.\n";
# oops, found unsupported binary!
if (!$isexe) {
die "Unsupported .exe format $1!\n";
if (!$check) {
die "$OBJDUMP did not provide any information about your binary!\n";
#if ($filename =~ /\.exe$/) {
# print "exe file, extra processing will be done\n";
# $tmpfile = "$TMPDIR/tbuisp.$$.srec";
# $isexe = 1;
# Program each mote
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment