2010-09-06 18:48:11 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
my $bin = shift;
|
|
|
|
my $terms = shift;
|
|
|
|
|
|
|
|
my $addr = "0x1e000";
|
2011-03-13 04:36:39 +01:00
|
|
|
my $iab = 0xa8c; # Redwire, LLC's IAB
|
|
|
|
|
|
|
|
my $mac_h;
|
|
|
|
my $mac_l;
|
2010-09-06 18:48:11 +02:00
|
|
|
|
|
|
|
if(defined($iab)) {
|
2011-03-13 04:36:39 +01:00
|
|
|
$mac_h = 0x0050C200 | ($iab >> 4);
|
|
|
|
$mac_l = ($iab & 0xf) << 28;
|
2010-09-06 18:48:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! $terms) {
|
|
|
|
print "Usage: $0 flasher.bin num-devices\n";
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (my $t=0; $t<$terms; $t++) {
|
|
|
|
my $dev_num = 2 * $t + 1;
|
2011-03-13 04:36:39 +01:00
|
|
|
$mac_l |= $dev_num;
|
|
|
|
#stupid 32-bit thing...
|
2010-09-06 18:48:11 +02:00
|
|
|
my $mac;
|
2011-03-13 04:36:39 +01:00
|
|
|
printf("mac_h %x\n", $mac_h);
|
|
|
|
printf("mac_l %x\n", $mac_l);
|
2010-09-08 23:00:36 +02:00
|
|
|
my @words;
|
2011-03-13 04:36:39 +01:00
|
|
|
for(my $i=0; $i<4; $i++) {
|
|
|
|
push @words, ($mac_h >> ($i * 8)) & 0xff;
|
|
|
|
}
|
|
|
|
for(my $i=0; $i<4; $i++) {
|
|
|
|
push @words, ($mac_l >> ($i * 8)) & 0xff;
|
2010-09-08 23:00:36 +02:00
|
|
|
}
|
|
|
|
reverse @words;
|
|
|
|
foreach my $byte (@words) {
|
|
|
|
printf("%02X",$byte);
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
|
|
|
|
my $word1 = sprintf("%02X%02X%02X%02X",$words[4],$words[5],$words[6],$words[7]);
|
|
|
|
my $word2 = sprintf("%02X%02X%02X%02X",$words[0],$words[1],$words[2],$words[3]);
|
|
|
|
|
2010-09-06 18:48:11 +02:00
|
|
|
my $ftdi_num = $terms - $t - 1;
|
2010-09-08 23:00:36 +02:00
|
|
|
my $cmd = "mc1322x-load.pl -e -f $bin -z -t /dev/ttyUSB$dev_num -c 'bbmc -l redbee-econotag -i $ftdi_num reset' $addr,0x$word1,0x$word2 &";
|
2010-09-06 18:48:11 +02:00
|
|
|
print "$cmd\n";
|
|
|
|
system($cmd);
|
|
|
|
}
|