X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETARM7.py;h=f7f0b94de919f432deb1958058657100f2996888;hp=01e929c0227f975cf024f15bb7dd89c49752d36a;hb=494cd04e27c3f437f55517c2de3f28b9b778ede4;hpb=f7fdc48f01ada713d5034763a2f3395fe2a7c51b diff --git a/client/GoodFETARM7.py b/client/GoodFETARM7.py index 01e929c..f7f0b94 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: + out.append( 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) @@ -514,17 +572,21 @@ class GoodFETARM(GoodFET): #FIXME: do we need the extra nop here? self.ARMrestart() self.ARMwaitDBG() - output.extend([self.ARMget_register(x) for x in xrange(count)]) + for x in range(count): + yield self.ARMget_register(x) wordcount -= count adr += count*4 #print hex(adr) # FIXME: handle the rest of the wordcount here. self.ARMset_registers(regs,0xe) - return output - def ARMreadStream(self, adr, bytecount): + #return output + + ARMreadMem = ARMreadChunk + peek = ARMreadMem + '''def ARMreadStream(self, adr, bytecount): data = [struct.unpack(">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); + ''' + ARMwriteMem = ARMwriteChunk + + def ARMwriteStream(self, addr, datastr): + #bytecount = len(datastr) + #baseaddr = addr & 0xfffffffc + #diffstart = addr - baseaddr + #endaddr = ((addr + bytecount) & 0xfffffffc) + 4 + #diffend = 4 - (endaddr - (addr+bytecount)) + bytecount = len(datastr) + baseaddr = addr & 0xfffffffc + endaddr = ((addr + bytecount + 3) & 0xfffffffc) + diffstart = 4 - (addr - baseaddr) + diffend = 4 - (endaddr - (addr + bytecount )) + + print hex(baseaddr), hex(diffstart), hex(endaddr), hex(diffend) + out = [] + if diffstart: + dword = self.ARMreadChunk(baseaddr, 1)[0] & (0xffffffff>>(8*diffstart)) + dst = "\x00" * (4-diffstart) + datastr[:diffstart]; print hex(dword), repr(dst) + datachk = struct.unpack(">8)&0xff ] ) + def ARMchain0(self, address, bits=0x819684c054, data=0): 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("