GoodFET firmware on the Telos B reveals the Flash chip.
[goodfet] / firmware / apps / jtag / jtag430.c
index cd8b6b8..2338847 100644 (file)
@@ -14,19 +14,18 @@ void jtag430_handle_fn(uint8_t const app,
 
 // define the jtag430 app's app_t
 app_t const jtag430_app = {
-
-       /* app number */
-       JTAG430,
-
-       /* handle fn */
-       jtag430_handle_fn,
-
-       /* name */
-       "JTAG430",
-
-       /* desc */
-       "\tThe JTAG430 app adds to the basic JTAG app\n"
-       "\tsupport for JTAG'ing MSP430 devices.\n"
+  /* app number */
+  JTAG430,
+  
+  /* handle fn */
+  jtag430_handle_fn,
+  
+  /* name */
+  "JTAG430",
+  
+  /* desc */
+  "\tThe JTAG430 app adds to the basic JTAG app\n"
+  "\tsupport for JTAG'ing MSP430 devices.\n"
 };
 
 unsigned int jtag430mode=MSP430X2MODE;
@@ -174,8 +173,6 @@ void jtag430_writeflash(unsigned int adr, unsigned int data){
 
 //! Power-On Reset
 void jtag430_por(){
-  unsigned int jtagid;
-
   // Perform Reset
   jtag_ir_shift8(IR_CNTRL_SIG_16BIT);
   jtag_dr_shift16(0x2C01); // apply
@@ -266,7 +263,6 @@ void jtag430_resettap(){
   
 }
 
-unsigned char jtagid;
 
 //! Get the JTAG ID
 unsigned char jtag430x2_jtagid(){
@@ -373,25 +369,14 @@ void jtag430_setinstrfetch(){
   }
 }
 
-//! Grab the core ID.
-unsigned int jtag430_coreid(){
-  jtag_ir_shift8(IR_COREIP_ID);
-  return jtag_dr_shift16(0);
-}
-
-//! Grab the device ID.
-unsigned long jtag430_deviceid(){
-  jtag_ir_shift8(IR_DEVICE_ID);
-  return jtag_dr_shift20(0);
-}
 
 
 
 
 //! Handles classic MSP430 JTAG commands.  Forwards others to JTAG.
 void jtag430_handle_fn(uint8_t const app,
-                                          uint8_t const verb,
-                                          uint32_t const len)
+                      uint8_t const verb,
+                      uint32_t const len)
 {
   unsigned long at, l;
   unsigned int i, val;
@@ -414,15 +399,8 @@ void jtag430_handle_fn(uint8_t const app,
   
   switch(verb){
   case START:
-    /* old method, classic MSP430. 
-    //Enter JTAG mode.
-    jtag430x2_start();
-    //TAP setup, fuse check
-    jtag430_resettap();
+    debugstr("Using JTAG430 (instead of JTAG430X2)!");
     
-    cmddata[0]=jtag_ir_shift8(IR_BYPASS);    
-    txdata(app,verb,1);
-    */
     jtag430x2_start();
     cmddata[0]=jtagid;
     
@@ -493,21 +471,6 @@ void jtag430_handle_fn(uint8_t const app,
     cmddataword[0]=jtag430_readmem(cmddataword[0]);
     txdata(app,verb,2);
     break;
-    /*
-  case JTAG430_WRITEFLASH:
-
-    //debugstr("Poking flash memory.");
-    jtag430_writeflash(cmddataword[0],cmddataword[2]);
-    
-    //Try again if failure.
-    //if(cmddataword[2]!=jtag430_readmem(cmddataword[0]))
-    //  jtag430_writeflash(cmddataword[0],cmddataword[2]);
-    
-    //Return result.
-    cmddataword[0]=jtag430_readmem(cmddataword[0]);
-    
-    txdata(app,verb,2);
-    break; */
   case JTAG430_WRITEFLASH:
     at=cmddataword[0];
     
@@ -551,11 +514,14 @@ void jtag430_handle_fn(uint8_t const app,
     txdata(app,verb,2);
     break;
   case JTAG430_COREIP_ID:
-    cmddataword[0]=jtag430_coreid();
+    //cmddataword[0]=jtag430_coreid();
+    cmddataword[0]=0xdead;
     txdata(app,verb,2);
     break;
   case JTAG430_DEVICE_ID:
-    cmddatalong[0]=jtag430_deviceid();
+    //cmddatalong[0]=jtag430_deviceid();
+    cmddataword[0]=0xdead;
+    cmddataword[1]=0xbeef;
     txdata(app,verb,4);
     break;
   default: