2 \author Travis Goodspeed <travis at radiantmachines.com>
4 This is an implementation of the MSP430X2 JTAG protocol
5 for the GoodFET project at http://goodfet.sf.net/
7 See the license file for details of proper use.
17 unsigned char jtag430x2_jtagid(){
19 return jtagid=jtag_ir_shift8(IR_BYPASS);
21 //! Start JTAG, take pins
22 unsigned char jtag430x2_start(){
25 //Known-good starting position.
26 //Might be unnecessary.
32 //Entry sequence from Page 67 of SLAU265A for 4-wire MSP430 JTAG
45 //Perform a reset and disable watchdog.
46 return jtag430x2_jtagid();
49 unsigned int jtag430_coreid(){
50 jtag_ir_shift8(IR_COREIP_ID);
51 return jtag_dr_shift16(0);
54 unsigned long jtag430_deviceid(){
55 jtag_ir_shift8(IR_DEVICE_ID);
56 return jtag_dr_shift20(0);
60 //! Read data from address
61 unsigned int jtag430x2_readmem(unsigned long adr){
64 jtag_ir_shift8(IR_CNTRL_SIG_CAPTURE);
65 if(jtag_dr_shift16(0) & 0x0301){
68 jtag_ir_shift8(IR_CNTRL_SIG_16BIT);
70 jtag_dr_shift16(0x0501);//word read
72 jtag_dr_shift16(0x0511);//byte read
74 jtag_ir_shift8(IR_ADDR_16BIT);
77 jtag_ir_shift8(IR_DATA_TO_ADDR);
80 toret = jtag_dr_shift16(0x0000);
83 // one or more cycle, so CPU is driving correct MAB
87 // Processor is now again in Init State
96 //! Handles classic MSP430 JTAG commands. Forwards others to JTAG.
97 void jtag430x2handle(unsigned char app,
104 do cmddata[0]=jtag430x2_start();
105 while(cmddata[0]==00 || cmddata[0]==0xFF);
108 if(jtagid==MSP430JTAGID){
109 jtag430mode=MSP430MODE;
111 }else if(jtagid==MSP430X2JTAGID){
112 jtag430mode=MSP430X2MODE;
119 //TAP setup, fuse check
120 //jtag430_resettap();
123 case JTAG430_READMEM:
125 cmddataword[0]=jtag430x2_readmem(cmddataword[0]);
126 //cmddataword[0]=jtag430_readmem(cmddataword[0]);
129 case JTAG430_COREIP_ID:
130 cmddataword[0]=jtag430_coreid();
133 case JTAG430_DEVICE_ID:
134 cmddatalong[0]=jtag430_deviceid();
137 case JTAG430_HALTCPU:
138 case JTAG430_RELEASECPU:
139 case JTAG430_SETINSTRFETCH:
140 case JTAG430_WRITEMEM:
142 case JTAG430_WRITEFLASH:
143 case JTAG430_ERASEFLASH:
146 jtaghandle(app,verb,len);