X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2Fgoodfet.msp430;h=c5413c5d742e8707f91daa386336490fdaea1280;hp=0f402d45f56251c393a8c6e0b3f8d36dc42af378;hb=ba447ec2175b15e3f9368c6dd18988215b36b84b;hpb=fa7c4f1b34ed53c88a678f947eb4b34c6e9807b4 diff --git a/client/goodfet.msp430 b/client/goodfet.msp430 index 0f402d4..c5413c5 100755 --- a/client/goodfet.msp430 +++ b/client/goodfet.msp430 @@ -3,9 +3,8 @@ import sys; import binascii; -from GoodFET import GoodFETMSP430; -from intelhex import IntelHex16bit; - +from GoodFETMSP430 import GoodFETMSP430; +from intelhex import IntelHex16bit, IntelHex; if(len(sys.argv)==1): @@ -15,22 +14,36 @@ if(len(sys.argv)==1): print "%s erase" % sys.argv[0]; print "%s flash $foo.hex [0x$start 0x$stop]" % sys.argv[0]; print "%s verify $foo.hex [0x$start 0x$stop]" % sys.argv[0]; + print "%s poke 0x$adr 0x$val" % sys.argv[0]; + print "%s peek 0x$start [0x$stop]" % sys.argv[0]; + print "%s run" % sys.argv[0]; sys.exit(); -#Initailize FET and set baud rate +#Initialize FET and set baud rate client=GoodFETMSP430(); client.serInit() #Connect to target -client.MSP430setup(); -client.MSP430start(); +client.setup(); +#print "setup" + +#Identify model number. +client.start(); -#client.setBaud(2); +#print "started" -if(sys.argv[1]=="monitortest"): - client.monitortest(); +if(sys.argv[1]=="info"): + #print "Model %08x " % client.MSP430deviceid(); + #print "Core %04x " % client.MSP430coreid(); + #print "Identity %04x" % client.MSP430ident(); + print "Identifies as %s (%04x)" % ( + client.MSP430identstr(), + client.MSP430ident()); if(sys.argv[1]=="test"): client.MSP430test(); +if(sys.argv[1]=="glitch"): + for foo in range(0,100): + print "Identifies as %04x" % client.MSP430ident(); if(sys.argv[1]=="dump"): f = sys.argv[2]; start=0x0200; @@ -41,13 +54,15 @@ if(sys.argv[1]=="dump"): stop=int(sys.argv[4],16); print "Dumping from %04x to %04x as %s." % (start,stop,f); - h = IntelHex16bit(None); + #h = IntelHex16bit(None); + h = IntelHex(None); i=start; - while i>1]=client.MSP430peek(i); - if(i%0x100==0): - print "Dumped %04x."%i; - i+=2; + while i<=stop: + data=client.MSP430peekblock(i); + print "Dumped %06x."%i; + for j in data: + if i<=stop: h[i]=ord(j); + i+=1; h.write_hex_file(f); if(sys.argv[1]=="erase"): client.MSP430masserase(); @@ -64,15 +79,37 @@ if(sys.argv[1]=="flash"): h = IntelHex16bit(f); + #Should this be default? + #Makes flashing multiple images inconvenient. client.MSP430masserase(); + + count=0; #Bytes in commit. + first=0; + vals=[]; + last=0; #Last address committed. for i in h._buf.keys(): - #print "%04x: %04x"%(i,h[i>>1]); + if((count>0x40 or last+2!=i) and count>0 and i&1==0): + #print "%i, %x, %x" % (len(vals), last, i); + client.MSP430pokeflashblock(first,vals); + count=0; + first=0; + last=0; + vals=[]; if(i>=start and i>1]); + val=h[i>>1]; + if(count==0): + first=i; + last=i; + count+=2; + #val2=client.MSP430pokeflash(i,val); + #if(val!=val2): + # print "Write error at %04x, %04x!=%04x." %( + # i, val, val2); + vals+=[val&0xff,(val&0xff00)>>8]; if(i%0x100==0): print "%04x" % i; -if(sys.argv[1]=="flashtest"): - client.MSP430flashtest(); + if count>0: #last commit, ivt + client.MSP430pokeflashblock(first,vals); if(sys.argv[1]=="verify"): f=sys.argv[2]; start=0; @@ -90,10 +127,41 @@ if(sys.argv[1]=="verify"): print "ERROR at %04x, found %04x not %04x"%(i,peek,h[i>>1]); if(i%0x100==0): print "%04x" % i; +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); + while start<=stop: + print "%04x: %04x" % (start,client.MSP430peek(start)); + start=start+2; + +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); + + while client.MSP430peek(start)!=val: + client.MSP430pokeflash(start,val); + print "Poked to %04x" % client.MSP430peek(start); + + +if(sys.argv[1]=="run"): + #Set PC to RESET vector's value. + #client.MSP430setPC(client.MSP430peek(0xfffe)); + #client.MSP430releasecpu(); + client.MSP430run(); if(sys.argv[1]=="whatever"): for i in [0x24FF, 0x2500, 0x2502, 0x2504]: print "%04x" % client.MSP430peek(i); -client.MSP430releasecpu(); -client.MSP430stop(); +#client.MSP430releasecpu(); +#client.MSP430stop();