From 2578d3d26d4b79f281f46ca36faf6d0c67edbace Mon Sep 17 00:00:00 2001 From: travisutk Date: Mon, 22 Jun 2009 23:01:37 +0000 Subject: [PATCH] Chipcon debugger is working. Can't yet write flash memory. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@52 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/GoodFET.py | 31 ++++++++++- client/goodfet.cc | 98 +++++++++++++++++++++++++++++++++ firmware/apps/chipcon/chipcon.c | 2 + 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100755 client/goodfet.cc diff --git a/client/GoodFET.py b/client/GoodFET.py index 94737ba..263e368 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -116,6 +116,23 @@ class GoodFET: """Move the FET into the MSP430 JTAG application.""" print "Initializing MSP430."; self.writecmd(0x11,0x10,0,self.data); + def CCsetup(self): + """Move the FET into the CC2430/CC2530 application.""" + print "Initializing Chipcon."; + self.writecmd(0x30,0x10,0,self.data); + def CCrd_config(self): + """Read the config register of a Chipcon.""" + self.writecmd(0x30,0x82,0,self.data); + return ord(self.data[0]); + def CCwr_config(self,config): + """Write the config register of a Chipcon.""" + self.writecmd(0x30,0x81,1,[config&0xFF]); + def CCident(self): + """Get a chipcon's ID.""" + self.writecmd(0x30,0x8B,0,None); + chip=ord(self.data[0]); + rev=ord(self.data[1]); + return (chip<<8)+rev; def MSP430peek(self,adr): """Read the contents of memory at an address.""" self.data=[adr&0xff, (adr&0xff00)>>8]; @@ -132,6 +149,15 @@ class GoodFET: self.writecmd(0x11,0x20,0,self.data); ident=self.MSP430ident(); print "Target identifies as %04x." % ident; + + def CCstart(self): + """Start debugging.""" + self.writecmd(0x30,0x20,0,self.data); + ident=self.CCident(); + print "Target identifies as %04x." % ident; + def CCstop(self): + """Stop debugging.""" + self.writecmd(0x30,0x21,0,self.data); def MSP430stop(self): """Stop debugging.""" @@ -202,4 +228,7 @@ class GoodFET: while i3): + start=int(sys.argv[3],16); + if(len(sys.argv)>4): + stop=int(sys.argv[4],16); + + print "Dumping from %04x to %04x as %s." % (start,stop,f); + h = IntelHex16bit(None); + i=start; + while i>1]=client.MSP430peek(i); + if(i%0x100==0): + print "Dumped %04x."%i; + i+=2; + h.write_hex_file(f); +if(sys.argv[1]=="erase"): + client.MSP430masserase(); +if(sys.argv[1]=="ivt"): + client.MSP430dumpmem(0xFFE0,0xFFFF); +if(sys.argv[1]=="flash"): + f=sys.argv[2]; + start=0; + stop=0xFFFF; + if(len(sys.argv)>3): + start=int(sys.argv[3],16); + if(len(sys.argv)>4): + stop=int(sys.argv[4],16); + + h = IntelHex16bit(f); + + client.MSP430masserase(); + for i in h._buf.keys(): + #print "%04x: %04x"%(i,h[i>>1]); + if(i>=start and i>1]); + if(i%0x100==0): + print "%04x" % i; +if(sys.argv[1]=="flashtest"): + client.MSP430flashtest(); +if(sys.argv[1]=="verify"): + f=sys.argv[2]; + start=0; + stop=0xFFFF; + if(len(sys.argv)>3): + start=int(sys.argv[3],16); + if(len(sys.argv)>4): + stop=int(sys.argv[4],16); + + h = IntelHex16bit(f); + for i in h._buf.keys(): + if(i>=start and i>1]!=peek): + print "ERROR at %04x, found %04x not %04x"%(i,peek,h[i>>1]); + if(i%0x100==0): + print "%04x" % i; + + +#client.MSP430releasecpu(); +#client.MSP430stop(); diff --git a/firmware/apps/chipcon/chipcon.c b/firmware/apps/chipcon/chipcon.c index e2fbcb4..49aa7d8 100644 --- a/firmware/apps/chipcon/chipcon.c +++ b/firmware/apps/chipcon/chipcon.c @@ -139,12 +139,14 @@ void cchandle(unsigned char app, break; case START://enter debugger ccdebuginit(); + txdata(app,verb,0); break; case STOP://exit debugger //Take RST low, then high. P5OUT&=~RST; CCDELAY(CCSPEED); P5OUT|=RST; + txdata(app,verb,0); break; case SETUP: ccsetup(); -- 2.20.1