Thursday, November 8, 2012

How to recover TelosB motes after setting RST/NMI pin in NMI mode

I have many TelosB motes running on TinyOS 2.1.2. Recently I accidentally configured RST/NMI pin from reset to NMI mode by changing $TOSROOT/tos/platforms/telosa/

Consequently, the BSL is not started by the BSL RESET vector if RST/NMI pin is configured for NMI functionality (NMI bit is set) [1]. After RST/NMI pin is configured in NMI mode, TelosB motes cannot programmed. Detailed information is shown below:
/opt/tinyos-2.1.2/apps/Blink$ make telosb reinstall bsl,/dev/ttyUSB0
cp build/telosb/main.ihex build/telosb/main.ihex.out
    installing telosb binary using bsl
tos-bsl --telosb -c /dev/ttyUSB0 -r -e -I -p build/telosb/main.ihex.out
MSP430 Bootstrap Loader Version: 1.39-goodfet-8
Mass Erase...
MSP430 Bootstrap Loader Version: 1.39-goodfet-8
Mass Erase...
Traceback (most recent call last):
  File "/usr/bin/tos-bsl", line 1918, in <module>
  File "/usr/bin/tos-bsl", line 1833, in main
    for f in toinit: f()
  File "/usr/bin/tos-bsl", line 1098, in actionMassErase
    0xa506)             #Required setting for mass erase!
  File "/usr/bin/tos-bsl", line 758, in bslTxRx
    rxFrame = self.comTxRx(cmd, dataOut, len(dataOut))  #Send frame
  File "/usr/bin/tos-bsl", line 440, in comTxRx
    rxHeader, rxNum = self.comRxHeader()        #receive header
  File "/usr/bin/tos-bsl", line 346, in comRxHeader
    if not hdr: raise BSLException("Timeout")
__main__.BSLException: Timeout
make: *** [program] Error 1

Literally, TelosB motes are all dead: wheven it is powered on, RST/NMI is in NMI mode, preventing bsl from taking over.

Following are the step-by-step guide to recover the motes. Prior to rolling up your sleeves, let's look at some logistics.
MSP430 LaunchPad: only from $4.30 and free shipping from TI eStore

Jumper wires: with female/male headers

Launchpad(LPD) BSL interface code:
BSLdemo2: in
Binary TI TXT file: also in

Now we are ready for the implementation.
(1) Compile the LPD BSL interface code with IAR KickStart and download it into the LPD. Be sure to change the target platform to MSP430G2553 when compiling.
(2) Power off. Connect TelosB [2] to LPD.
          LPD                      TelosB
          VCC                      U2.1
          GND                      U2.9
          P1.6                       FT232BM pin 24 (RXD)
          P1.7                       FT232BM pin 25 (TXD)
          P1.4                       U28.6
          P1.0                       U8.7
Note: do not connect VCC now. You will do it in step (3).

(3) Power up LPD, make sure that both Green and Red LEDs are off. If not, press Reset (S1) on the LPD.
(4) Power up TelosB by connecting VCC. (If it is already on, turn it off and wait for 10 seconds, then turn it on.)
(5) Press and release S2 on the LPD. Both Green and Red LEDs should turn on.
(6) Start BSLdemo2 on the PC. Go to $LPAD_BSL_INTERFACE/TestScripts/MSP430F1612 and launch test.bat. Be sure to change the COM port number in test.bat.
(7) Download Blink app in $TOSROOT/apps/Blink into the mote through bsl.

By now, you should see the mote blinks happily! Hope this helps. Drop me a comment if you have any issue. Enjoy.

Special thanks to Ye-sheng Kuo from University of Michigan and Lichen Wang, without whose assistance my motes may not survive.

[1] MSP430 Programming Via the Bootstrap Loader User's Guide

1 comment:

  1. Hey, we were trying to use your method for getting a TelosB mote to work again but faced an error towards the end of the execution of test.bat.
    Program starting at 38b0,240 bytes....Error = 7
    ERROR:Verification failed!

    The rest of the lines end with Error = 0
    What should we change or do next??