Beginnings of selftest. Fixed poke instruction.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sat, 5 Jun 2010 22:10:18 +0000 (22:10 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sat, 5 Jun 2010 22:10:18 +0000 (22:10 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@598 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETMSP430.py
client/goodfet.msp430
client/goodfet.nrf

index 4d54fd9..a70c656 100644 (file)
@@ -203,6 +203,14 @@ class GoodFETMSP430(GoodFET):
     def MSP430setPC(self, pc):
         """Set the program counter."""
         self.writecmd(self.MSP430APP,0xC2,2,[pc&0xFF,(pc>>8)&0xFF]);
     def MSP430setPC(self, pc):
         """Set the program counter."""
         self.writecmd(self.MSP430APP,0xC2,2,[pc&0xFF,(pc>>8)&0xFF]);
+    def MSP430setreg(self,reg,val):
+        """Set a register."""
+        self.writecmd(self.MSP430APP,0xD2,3,[reg,val&0xFF,(val>>8)&0xFF]);
+    def MSP430getreg(self,reg):
+        """Get a register."""
+        self.writecmd(self.MSP430APP,0xD3,1,[reg]);
+        return ord(self.data[0])+(ord(self.data[1])<<8);
+
     def MSP430run(self):
         """Reset the MSP430 to run on its own."""
         self.writecmd(self.MSP430APP,0x21,0,None);
     def MSP430run(self):
         """Reset the MSP430 to run on its own."""
         self.writecmd(self.MSP430APP,0x21,0,None);
index 7183103..a250341 100755 (executable)
@@ -71,9 +71,22 @@ if(sys.argv[1]=="eraseinfo"):
     print "Erasing info memory."
     client.MSP430infoerase();
 
     print "Erasing info memory."
     client.MSP430infoerase();
 
+if(sys.argv[1]=="selftest"):
+    entry=client.peek16(0xFFC0);
+    print "Calling self-test at 0x%04x." %entry;
+    client.MSP430setPC(entry);
+    print "PC=%04x" % client.MSP430getreg(0);
+    client.MSP430releasecpu();
+    
+    import time;
+    time.sleep(30)
 
 if(sys.argv[1]=="ivt"):
 
 if(sys.argv[1]=="ivt"):
-    client.MSP430dumpmem(0xFFE0,0xFFFF);
+    client.MSP430dumpmem(0xFFC0,0xFFFF);
+if(sys.argv[1]=="regs"):
+    for i in range(0,16):
+        print "r%i=%04x" % (i,client.MSP430getreg(i));
+
 if(sys.argv[1]=="flash"):
     f=sys.argv[2];
     start=0;
 if(sys.argv[1]=="flash"):
     f=sys.argv[2];
     start=0;
@@ -151,7 +164,7 @@ if(sys.argv[1]=="poke"):
     print "Poking %06x to become %04x." % (start,val);
     
     while client.MSP430peek(start)&(~val)>0:
     print "Poking %06x to become %04x." % (start,val);
     
     while client.MSP430peek(start)&(~val)>0:
-        client.MSP430pokeflashblock(start,[val&0xFF, (val>>8)&0xFF]);
+        client.MSP430pokeflash(start,val);
         print "Poked to %04x" % client.MSP430peek(start);
 if(sys.argv[1]=="serial"):
     oid=0xdeadbeef;
         print "Poked to %04x" % client.MSP430peek(start);
 if(sys.argv[1]=="serial"):
     oid=0xdeadbeef;
index 4c2eb0e..b7f7927 100755 (executable)
@@ -132,12 +132,13 @@ if(sys.argv[1]=="sniffob"):
     client.poke(0x00,0x00); #Stop nRF
     client.poke(0x01,0x00); #Disable Shockburst
     client.poke(0x02,0x01); #Set RX Pipe 0
     client.poke(0x00,0x00); #Stop nRF
     client.poke(0x01,0x00); #Disable Shockburst
     client.poke(0x02,0x01); #Set RX Pipe 0
-    client.RF_setmaclen(5); # SETUP_AW for 5-byte addresses.
+    
     client.RF_setfreq(2481 * 10**6);
     client.poke(0x06,0x09); #2MBps, -18dBm in RF_SETUP
     client.poke(0x07,0x78); #Reset status register
     
     #OpenBeacon defines these in little endian as follows.
     client.RF_setfreq(2481 * 10**6);
     client.poke(0x06,0x09); #2MBps, -18dBm in RF_SETUP
     client.poke(0x07,0x78); #Reset status register
     
     #OpenBeacon defines these in little endian as follows.
+    client.RF_setmaclen(5); # SETUP_AW for 5-byte addresses.
     #0x01, 0x02, 0x03, 0x02, 0x01
     client.RF_setsmac(0x0102030201);
     #'O', 'C', 'A', 'E', 'B'
     #0x01, 0x02, 0x03, 0x02, 0x01
     client.RF_setsmac(0x0102030201);
     #'O', 'C', 'A', 'E', 'B'
@@ -146,7 +147,7 @@ if(sys.argv[1]=="sniffob"):
     #Set packet length of 16.
     client.RF_setpacketlen(16);
     
     #Set packet length of 16.
     client.RF_setpacketlen(16);
     
-    #Power radio, prime for RX, but no checksum.
+    #Power radio, prime for RX, one-byte checksum.
     client.poke(0x00,0x70|0x03|0x08); #0x08 for one byte, 0x04 for two.
     
     print "Listening as %010x on %i MHz" % (client.RF_getsmac(),
     client.poke(0x00,0x70|0x03|0x08); #0x08 for one byte, 0x04 for two.
     
     print "Listening as %010x on %i MHz" % (client.RF_getsmac(),
@@ -178,3 +179,27 @@ if(sys.argv[1]=="sniff"):
             packet=client.RF_rxpacket();
         printpacket(packet);
         sys.stdout.flush();
             packet=client.RF_rxpacket();
         printpacket(packet);
         sys.stdout.flush();
+if(sys.argv[1]=="explore"):
+    #client.poke(0x00,0x00); #Stop nRF
+    client.poke(0x07,0x78); #Reset status register
+    
+    #Power radio, prime for RX, no checksum.
+    client.poke(0x00,0x70|0x03);
+    
+    #Set packet length of 32.
+    #Without checksums, extra data will mix in.
+    client.RF_setpacketlen(32);
+    client.RF_setmaclen(3); # shortest address length
+    
+    #Now we're ready to get packets.
+    for smac in [0x0102030201, 0]:
+        client.RF_setsmac(smac);
+        for chan in range(0,0x80):
+            client.RF_setfreq((2400+chan) * 10**6);
+            time.sleep(1);
+            packet=client.RF_rxpacket();
+            if packet!=None:
+                print "Listening as %010x on %i MHz" % (client.RF_getsmac(),
+                                                        client.RF_getfreq()/10**6);
+                printpacket(packet);
+                sys.stdout.flush();