GoodFET.CCstop() is now GoodFET.stop()
[goodfet] / client / goodfet.bsl
index 3a8aa79..458bedd 100755 (executable)
@@ -200,12 +200,14 @@ deviceids = {
     0xf449: F4x,
     0x1232: F1x,
     0xf26f: F2x, #for GoodFET20
     0xf449: F4x,
     0x1232: F1x,
     0xf26f: F2x, #for GoodFET20
+    0xf227: F2x, #for GoodFET30
 }
 
 #GoodFET firmware
 firmware = {
     0xf16c: "http://goodfet.sourceforge.net/dist/msp430x1612.hex",
     0xf26f: "http://goodfet.sourceforge.net/dist/msp430x2618.hex",
 }
 
 #GoodFET firmware
 firmware = {
     0xf16c: "http://goodfet.sourceforge.net/dist/msp430x1612.hex",
     0xf26f: "http://goodfet.sourceforge.net/dist/msp430x2618.hex",
+    0xf227: "http://goodfet.sourceforge.net/dist/msp430x2274.hex"
 }
 
 class BSLException(Exception):
 }
 
 class BSLException(Exception):
@@ -983,8 +985,12 @@ class BootStrapLoader(LowLevel):
         """start BSL, download patch if desired and needed, adjust SP if desired"""
         sys.stderr.write("Invoking BSL...\n")
         sys.stderr.flush()
         """start BSL, download patch if desired and needed, adjust SP if desired"""
         sys.stderr.write("Invoking BSL...\n")
         sys.stderr.flush()
+        
+        #for '30, invertTEST=0, else =1
         if bslreset:
             self.bslReset(1)                        #Invoke the boot loader.
         if bslreset:
             self.bslReset(1)                        #Invoke the boot loader.
+        
+        
         self.txPasswd(self.passwd)                  #transmit password
 
         #Read actual bootstrap loader version.
         self.txPasswd(self.passwd)                  #transmit password
 
         #Read actual bootstrap loader version.
@@ -1130,9 +1136,9 @@ class BootStrapLoader(LowLevel):
             raise BSLException, "programming without data not possible"
     def actionFromweb(self):
         """Grab GoodFET firmware from the web, then flash it."""
             raise BSLException, "programming without data not possible"
     def actionFromweb(self):
         """Grab GoodFET firmware from the web, then flash it."""
-        print "%x" % self.dev_id;
+        print "Grabbing %x firmware." % self.dev_id;
         print "%s" % firmware[self.dev_id];
         print "%s" % firmware[self.dev_id];
-        fn="/tmp/fw.hex"
+        fn="/tmp/.goodfet.hex"
         os.system("curl %s >%s" % (firmware[self.dev_id],fn))
         
         fw=Memory(fn);
         os.system("curl %s >%s" % (firmware[self.dev_id],fn))
         
         fw=Memory(fn);
@@ -1275,6 +1281,9 @@ General options:
                         --swap-reset-test, and --telos-latch
   --telosb              Implies options --swap-reset-test, --telos-i2c,
                         --no-BSL-download, and --speed=38400
                         --swap-reset-test, and --telos-latch
   --telosb              Implies options --swap-reset-test, --telos-i2c,
                         --no-BSL-download, and --speed=38400
+  --goodfet10
+  --goodfet20
+  --goodfet30
   --tmote               Identical operation to --telosb
   --no-BSL-download     Do not download replacement BSL (disable automatic)
   --force-BSL-download  Download replacement BSL even if not needed (the one
   --tmote               Identical operation to --telosb
   --no-BSL-download     Do not download replacement BSL (disable automatic)
   --force-BSL-download  Download replacement BSL even if not needed (the one
@@ -1348,7 +1357,7 @@ def hexify(line, bytes, width=16):
         )
 
 #Main:
         )
 
 #Main:
-def main():
+def main(itest=1):
     global DEBUG
     import getopt
     filetype    = None
     global DEBUG
     import getopt
     filetype    = None
@@ -1373,7 +1382,7 @@ def main():
     dumpinfo    = 0
     
     bsl.invertRST = 1
     dumpinfo    = 0
     
     bsl.invertRST = 1
-    bsl.invertTEST = 1
+    bsl.invertTEST = itest
     
     if comPort is None and os.environ.get("GOODFET")!=None:
         glob_list = glob.glob(os.environ.get("GOODFET"));
     
     if comPort is None and os.environ.get("GOODFET")!=None:
         glob_list = glob.glob(os.environ.get("GOODFET"));
@@ -1402,7 +1411,9 @@ def main():
              "bslversion", "f1x", "f2x", "f4x", "invert-reset", "invert-test",
             "swap-reset-test", "telos-latch", "telos-i2c", "telos", "telosb",
              "tmote","no-BSL-download", "force-BSL-download", "slow",
              "bslversion", "f1x", "f2x", "f4x", "invert-reset", "invert-test",
             "swap-reset-test", "telos-latch", "telos-i2c", "telos", "telosb",
              "tmote","no-BSL-download", "force-BSL-download", "slow",
-             "dumpivt", "dumpinfo", "fromweb"]
+             "dumpivt", "dumpinfo", "fromweb",
+       "goodfet30", "goodfet20", "goodfet10"
+       ]
         )
     except getopt.GetoptError:
         # print help information and exit:
         )
     except getopt.GetoptError:
         # print help information and exit:
@@ -1542,6 +1553,15 @@ def main():
             bsl.invertTEST = 1
             bsl.swapRSTTEST = 1
             bsl.telosLatch = 1
             bsl.invertTEST = 1
             bsl.swapRSTTEST = 1
             bsl.telosLatch = 1
+       elif o in ("--goodfet10", ):
+           bsl.invertRST = 1
+           bsl.invertTEST = 1
+       elif o in ("--goodfet20", ):
+           bsl.invertRST = 1
+           bsl.invertTEST = 1
+       elif o in ("--goodfet30", ):
+           bsl.invertRST = 1
+           bsl.invertTEST = 0
         elif o in ("--telosb", ):
             bsl.swapRSTTEST = 1
             bsl.telosI2C = 1
         elif o in ("--telosb", ):
             bsl.swapRSTTEST = 1
             bsl.telosI2C = 1
@@ -1700,7 +1720,7 @@ def main():
 
 if __name__ == '__main__':
     try:
 
 if __name__ == '__main__':
     try:
-        main()
+        main(1)
     except SystemExit:
         raise               #let pass exit() calls
     except KeyboardInterrupt:
     except SystemExit:
         raise               #let pass exit() calls
     except KeyboardInterrupt:
@@ -1709,5 +1729,6 @@ if __name__ == '__main__':
         sys.exit(1)         #set errorlevel for script usage
     except Exception, msg:  #every Exception is caught and displayed
         if DEBUG: raise     #show full trace in debug mode
         sys.exit(1)         #set errorlevel for script usage
     except Exception, msg:  #every Exception is caught and displayed
         if DEBUG: raise     #show full trace in debug mode
-        sys.stderr.write("\nAn error occoured:\n%s\n" % msg) #short messy in user mode
-        sys.exit(1)         #set errorlevel for script usage
+        #sys.stderr.write("\nAn error occoured:\n%s\n" % msg) #short messy in user mode
+        #sys.exit(1)         #set errorlevel for script usage
+        main(0);