From: dodge-this Date: Sat, 10 Nov 2012 23:58:18 +0000 (+0000) Subject: Finally have a basic goodfet.arm7 script. not done, but the base is there. X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=ee53293be17c053f5eaca7fdee7912d3d0544934 Finally have a basic goodfet.arm7 script. not done, but the base is there. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1328 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- diff --git a/client/GoodFETARM7.py b/client/GoodFETARM7.py index 01e929c..307a1fe 100644 --- a/client/GoodFETARM7.py +++ b/client/GoodFETARM7.py @@ -217,13 +217,29 @@ class GoodFETARM(GoodFET): """Move the FET into the JTAG ARM application.""" #print "Initializing ARM." self.writecmd(0x13,SETUP,0,self.data) - def getpc(self): - return self.ARMgetPC() def flash(self,file): """Flash an intel hex file to code memory.""" print "Flash not implemented."; - def dump(self,file,start=0,stop=0xffff): + def dump(self,fn,start=0,stop=0xffffffff): """Dump an intel hex file from code memory.""" + + print "Dumping from %04x to %04x as %s." % (start,stop,f); + # FIXME: get mcu state and return it to that state + self.halt() + + h = IntelHex(None); + i=start; + while i<=stop: + data=self.ARMreadChunk(i, 48, verbose=0); + print "Dumped %06x."%i; + for dword in data: + if i<=stop and dword != 0xdeadbeef: + h.puts( i, struct.pack(" 0): - if (wordcount%64 == 0): sys.stderr.write(".") + if (verbose and wordcount%64 == 0): sys.stderr.write(".") count = (wordcount, 0xe)[wordcount>0xd] bitmask = LDM_BITMASKS[count] self.ARMset_register(14,adr) @@ -563,7 +581,7 @@ class GoodFETARM(GoodFET): self.ARM_nop(0) self.ARMrestart() self.ARMwaitDBG() - print >>sys.stderr,hex(self.ARMget_register(1)) + #print >>sys.stderr,hex(self.ARMget_register(1)) self.ARMset_register(1, r1); # restore R0 and R1 self.ARMset_register(0, r0); def writeMemByte(self, adr, byte): @@ -588,10 +606,11 @@ class GoodFETARM(GoodFET): bulk = chop(address,4) bulk.extend(chop(bits,8)) bulk.extend(chop(data,4)) - print >>sys.stderr,(repr(bulk)) + #print >>sys.stderr,(repr(bulk)) self.writecmd(0x13,CHAIN0,16,bulk) d1,b1,a1 = struct.unpack("3): + 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); + # FIXME: get mcu state and return it to that state + client.halt() + + h = IntelHex(None); + i=start; + while i<=stop: + #data=client.ARMreadMem(i, 48); + data=client.ARMreadChunk(i, 48, verbose=0); + print "Dumped %06x."%i; + for dword in data: + if i<=stop and dword != 0xdeadbeef: + h.puts( i, struct.pack("3): + start=int(sys.argv[3],16); + if(len(sys.argv)>4): + stop=int(sys.argv[4],16); + + client.halt() + h = IntelHex16bit(f); + + #Should this be default? + #Makes flashing multiple images inconvenient. + #client.ARMmasserase(); + + count=0; #Bytes in commit. + first=0; + vals=[]; + last=0; #Last address committed. + for i in h._buf.keys(): + if((count>0x40 or last+2!=i) and count>0 and i&1==0): + #print "%i, %x, %x" % (len(vals), last, i); + client.ARMpokeflashblock(first,vals); + count=0; + first=0; + last=0; + vals=[]; + if(i>=start and i>1]; + if(count==0): + first=i; + last=i; + count+=2; + vals+=[val&0xff,(val&0xff00)>>8]; + if(i%0x100==0): + print "%04x" % i; + if count>0: #last commit, ivt + client.ARMpokeflashblock(first,vals); + client.resume() + +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); + + client.halt() + 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.resume() + + +if(sys.argv[1]=="peek"): + start=0x0000; + if(len(sys.argv)>2): + start=int(sys.argv[2],16); + stop=start; + if(len(sys.argv)>3): + stop=int(sys.argv[3],16); + + print "Peeking from %04x to %04x." % (start,stop); + client.halt() + for dword in client.ARMreadChunk(start, (stop-start)/4, verbose=0): + print "%.4x: %.8x" % (start, dword) + start += 4 + client.resume() + +if(sys.argv[1]=="poke"): + start=0x0000; + val=0x00; + if(len(sys.argv)>2): + start=int(sys.argv[2],16); + if(len(sys.argv)>3): + val=int(sys.argv[3],16); + + print "Poking %06x to become %04x." % (start,val); + client.halt() + #???while client.ARMreadMem(start)[0]&(~val)>0: + client.ARMwriteChunk(start, [val]) + print "Poked to %.8x" % client.ARMreadMem(start)[0] + client.resume() + + +if(sys.argv[1]=="reset"): + #Set PC to RESET vector's value. + + client.ARMsetPC(0x00000000); + client.ARMreleasecpu(); + +#client.ARMreleasecpu(); +#client.ARMstop();