]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - apps/tests/deluge/Blink/burn
Merge of the latest Deluge T2.
[tinyos-2.x.git] / apps / tests / deluge / Blink / burn
index 1418e38229ece16570862c88e1008bb1b01f1f84..1e82f5d3b23859ce8d8440fff2b1bf7f5985b89d 100755 (executable)
@@ -1,36 +1,94 @@
 #!/bin/bash
 
-if [ $# -ne 2 ]; then
-  echo "Usage: $0 <port> <platform>"
-  echo "<port>       For example, /dev/ttyUSB0"
-  echo "<platform>   \"micaz\", \"telosb\""
+python -c '
+import sys
+try: 
+  import serial
+except ImportError, e: 
+  sys.exit(1)'
+
+if [[ $? != 0 ]]
+then
+  echo "Please install PySerial first." 
   exit 2
 fi
 
-if [ $2 != 'micaz' -a $2 != 'telosb' ]; then
-  echo "\"$2\" is not a supported platform"
+TOS_DELUGE=`type -p tos-deluge`
+if [[ ! -x ${TOS_DELUGE} ]] ; then 
+    TOS_DELUGE=../../../../tools/tinyos/misc/tos-deluge
+fi 
+
+if [[ $# -ne 2 && $# -ne 3 ]]; then
+  echo "Usage: $0 <port> [<comm_port>] <platform>"
+  echo "  <port>       /dev/ttyUSB0"
+  echo "  <comm_port>  /dev/ttyUSB1"
+  echo "  <platform>   micaz, telosb or iris"
   exit 2
 fi
 
-PORT=$1
+PPORT=$1
+CPORT=$1
 PLATFORM=$2
 
+if [ $# -eq 3 ]; then
+ CPORT=$2
+ PLATFORM=$3
+fi
+
+if [ ${PLATFORM} != 'micaz' -a ${PLATFORM} != 'telosb' -a ${PLATFORM} != 'iris' ]; then
+  echo "\"${PLATFORM}\" is not a supported platform"
+  exit 2
+fi
+
+if ! [ -a ${TOSDIR}/lib/tosboot/build/${PLATFORM}/main.ihex ]
+then
+  echo ========================== Compile tosboot for ${PLATFORM} ===========================
+  ( cd $TOSDIR/lib/tosboot ; make ${PLATFORM} ) 
+fi
+
 make clean
 
-echo ==================== Compile and load Blink ====================
+echo ============================ Compile and load Blink ============================
 if [ $PLATFORM == 'micaz' ]
 then
-  CFLAGS=-DDELUGE_BASESTATION make $PLATFORM install mib510,$PORT
+  CFLAGS=-DDELUGE_BASESTATION make ${PLATFORM} install mib510,${PPORT}
 elif [ $PLATFORM == 'telosb' ]
 then
-  CFLAGS=-DDELUGE_BASESTATION make $PLATFORM install bsl,$PORT
+  CFLAGS=-DDELUGE_BASESTATION make ${PLATFORM} install bsl,${PPORT}
+elif [ $PLATFORM == 'iris' ]
+then
+  CFLAGS=-DDELUGE_BASESTATION make ${PLATFORM} install mib510,${PPORT}
 fi
 
-echo ==================== Compile a new Blink ====================
-CFLAGS=-DBLINK_REVERSE\ -DDELUGE_BASESTATION make $PLATFORM 
 
-echo ==================== Upload the image ====================
-../../../../tools/tinyos/misc/tos-deluge $PORT $PLATFORM -i 0 build/$PLATFORM/tos_image.xml
+echo '           +-------------------------------------------------------+'
+echo '           |                                                       |'
+echo '           | At this point the first led (red) should be blinking. |'
+echo '           |                                                       |'
+echo '           |               Press ENTER to continue...              |'
+echo '           |                                                       |'
+echo '           +-------------------------------------------------------+'
+read
+
+echo  ============================= Compile a new Blink ==============================
+CFLAGS=-DBLINK_REVERSE\ -DDELUGE_BASESTATION make ${PLATFORM}
+
+echo =============================== Upload the image ===============================
+${TOS_DELUGE} ${CPORT} ${PLATFORM} -i 1 build/${PLATFORM}/tos_image.xml
+
+echo '       +----------------------------------------------------------------+'
+echo '       |                                                                |'
+echo '       | In the next step the following things will take place:         |'
+echo '       | - the mote will be rebooted                                    |'
+echo '       | - all the leds will blink for some time as the                 |'
+echo '       |   reprogramming by tosboot takes place.                        |'
+echo '       | - a fading of the leds will indicate the exiting from tosboot. |'
+echo '       | - the mote should start blinking the 3rd led (blue/yellow).    |'
+echo '       |                                                                |'
+echo '       |                   Press ENTER to continue...                   |'
+echo '       |                                                                |'
+echo '       +----------------------------------------------------------------+'
+read
 
-echo ==================== Reboot ====================
-../../../../tools/tinyos/misc/tos-deluge $PORT $PLATFORM -r 0 
+echo =========================== Reboot the base station ============================
+${TOS_DELUGE} ${CPORT} ${PLATFORM} -r 1