X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETARM.py;h=889f2e42bf115cff0ac452eb30f35bbd8a2eadab;hp=9991d55eef817e7dc87a6165971b5a5398313864;hb=a9ea210bbc231454d5bf0db46984247d15fea06d;hpb=8203dc42156b3745f4f79ba7da4845da365902ff diff --git a/client/GoodFETARM.py b/client/GoodFETARM.py index 9991d55..889f2e4 100644 --- a/client/GoodFETARM.py +++ b/client/GoodFETARM.py @@ -7,6 +7,7 @@ # import sys, binascii, struct +import atlasutils.smartprint as asp #Global Commands READ = 0x00 @@ -54,6 +55,14 @@ SET_SPSR = 0x9b SET_MODE_THUMB = 0x9c SET_MODE_ARM = 0x9d + +platforms = { + "at91sam7": {0:(0x100000, "Flash before remap, SRAM after remap"), + 0x100000: (0x100000, "Internal Flash"), + 0x200000: (0x100000, "Internal SRAM"), + }, + } + from GoodFET import GoodFET from intelhex import IntelHex @@ -64,16 +73,18 @@ class GoodFETARM(GoodFET): """A GoodFET variant for use with ARM7TDMI microprocessor.""" def ARMhaltcpu(self): """Halt the CPU.""" - self.writecmd(0x33,HALTCPU,0,self.data) + self.writecmd(0x13,HALTCPU,0,self.data) def ARMreleasecpu(self): """Resume the CPU.""" - self.writecmd(0x33,RESUMECPU,0,self.data) + self.writecmd(0x13,RESUMECPU,0,self.data) def ARMsetModeArm(self): - self.writecmd(0x33,SET_MODE_ARM,0,self.data) + self.writecmd(0x13,SET_MODE_ARM,0,self.data) + def ARMsetModeThumb(self): + self.writecmd(0x13,SET_MODE_THUMB,0,self.data) def ARMtest(self): - self.ARMreleasecpu() - self.ARMhaltcpu() - #print "Status: %s" % self.ARMstatusstr() + #self.ARMreleasecpu() + #self.ARMhaltcpu() + print "Status: %s" % self.ARMstatusstr() #Grab ident three times, should be equal. ident1=self.ARMident() @@ -83,9 +94,27 @@ class GoodFETARM(GoodFET): print "Error, repeated ident attempts unequal." print "%04x, %04x, %04x" % (ident1, ident2, ident3) + #Set and Check Registers + regs = [1024+x for x in range(0,15)] + regr = [] + for x in range(len(regs)): + self.ARMset_register(x, regs[x]) + + for x in range(len(regs)): + regr.append(self.ARMget_register(x)) + + for x in range(len(regs)): + if regs[x] != regr[x]: + print "Error, R%d fail: %x != %x"%(x,regs[x],regr[x]) + + return + + + + #Single step, printing PC. print "Tracing execution at startup." - for i in range(1,15): + for i in range(15): pc=self.ARMgetPC() byte=self.ARMpeekcodebyte(i) #print "PC=%04x, %02x" % (pc, byte) @@ -112,24 +141,23 @@ class GoodFETARM(GoodFET): def setup(self): """Move the FET into the JTAG ARM application.""" #print "Initializing ARM." - self.writecmd(0x33,SETUP,0,self.data) + self.writecmd(0x13,SETUP,0,self.data) def ARMget_dbgstate(self): """Read the config register of an ARM.""" - self.writecmd(0x33,GET_DEBUG_STATE,0,self.data) - print "DEBUGGING get_dbgstate: %s"%repr(self.data) + self.writecmd(0x13,GET_DEBUG_STATE,0,self.data) retval = struct.unpack(">24, (val>>16)&0xff, (val>>8)&0xff, val&0xff]) - print "DEBUG:SET_REGISTER: %s"%repr(self.data) + self.writecmd(0x13,SET_REGISTER,8,[val&0xff, (val>>8)&0xff, (val>>16)&0xff, val>>24, reg,0,0,0]) + #self.writecmd(0x13,SET_REGISTER,8,[reg,0,0,0, (val>>16)&0xff, val>>24, val&0xff, (val>>8)&0xff]) retval = struct.unpack(">24, (reg>>16)&0xff, (reg>>8)&0xff, reg&0xff]) - self.writecmd(0x33,GET_REGISTER,16*4,regarray) - print "DEBUG:SET_REGISTER: %s"%repr(self.data) + regarry.extend([reg&0xff, (reg>>8)&0xff, (reg>>16)&0xff, reg>>24]) + self.writecmd(0x13,SET_REGISTERS,16*4,regarry) + retval = struct.unpack(">8)&0xff, (val>>16)&0xff, val>>24]) def ARMcmd(self,phrase): - self.writecmd(0x33,READ,len(phrase),phrase) + self.writecmd(0x13,READ,len(phrase),phrase) val=ord(self.data[0]) print "Got %02x" % val return val def ARMdebuginstr(self,instr): if type (instr) == int: instr = struct.pack(">8] - self.writecmd(0x33,PEEK,2,self.data) - retval = struct.unpack(">8)&0xff, (adr>>16)&0xff, (adr>>24)&0xff, words&0xff, (words>>8)&0xff, (words>>16)&0xff, (words>>24)&0xff ] + self.writecmd(0x13,READ_CODE_MEMORY,8,self.data) + retval = [] + retval.append(self.serialport.read(words*4)) + #retval = struct.unpack(">8] - self.writecmd(0x33, PEEK, 2, self.data) + self.data=[ adr&0xff, (adr>>8)&0xff, (adr>>16)&0xff, (adr>>24)&0xff ] + self.writecmd(0x13, PEEK, 4, self.data) + #retval.append(self.serialport.read(words*4)) retval = struct.unpack(">8, val] - self.writecmd(0x33, POKE, 3, self.data) + self.data=[adr&0xff, (adr>>8)&0xff, (adr>>16)&0xff, (adr>>24)&0xff, val&0xff, (val>>8)&0xff, (val>>16)&0xff, (val>>24)&0xff ] + self.writecmd(0x13, POKE, 8, self.data) retval = struct.unpack(">8)&0xFF, - (adr>>16)&0xFF, - (adr>>24)&0xFF] - print "Flashing buffer to 0x%06x" % adr - self.writecmd(0x33,MASS_FLASH_PAGE,4,data) + self.writecmd(0x13,STOP,0,self.data) + #def ARMstep_instr(self): + # """Step one instruction.""" + # self.writecmd(0x13,STEP_INSTR,0,self.data) + #def ARMflashpage(self,adr): + # """Flash 2kB a page of flash from 0xF000 in XDATA""" + # data=[adr&0xFF, + # (adr>>8)&0xFF, + # (adr>>16)&0xFF, + # (adr>>24)&0xFF] + # print "Flashing buffer to 0x%06x" % adr + # self.writecmd(0x13,MASS_FLASH_PAGE,4,data) def writecmd(self, app, verb, count=0, data=[]): """Write a command and some data to the GoodFET."""