X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2Fgoodfet.cc;h=6d8eed120ccd2ce48b7d961cfc9bd0d7e163552d;hp=b76ce8f1bcba50e70d951867de0f8523f3f59f6e;hb=ed7afb6af8b3831d61a8ef6cba7592f17592af72;hpb=ce76931b979c96a39e2e6e6841ac7b49f3a2bbac diff --git a/client/goodfet.cc b/client/goodfet.cc index b76ce8f..6d8eed1 100755 --- a/client/goodfet.cc +++ b/client/goodfet.cc @@ -82,28 +82,77 @@ if(sys.argv[1]=="erase"): client.CCchiperase(); print "Status: %s" %client.CCstatusstr(); -# 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); +if(sys.argv[1]=="peekinfo"): + print "Select info flash." + client.CCwr_config(1); + print "Config is %02x" % client.CCrd_config(); -# h = IntelHex(f); - -# client.CCchiperase(); -# for i in h._buf.keys(): -# #print "%04x: %04x"%(i,h[i>>1]); -# if(i>=start and i<=stop and i&1==0): -# client.CCwriteflash(i,h[i>>1]); -# if(i%0x100==0): -# print "%04x" % i; + 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: %02x" % (start,client.CCpeekcodebyte(start)); + start=start+1; + +if(sys.argv[1]=="config"): + print "Config is %02x" % client.CCrd_config(); +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 = IntelHex(f); + page = 0x0000; + pagelen = 2048; #2kB pages in 32-bit words + bcount = 0; + + print "Wiping Flash." + #Wipe all of flash. + client.CCchiperase(); + #Wipe the RAM buffer for the next flash page. + client.CCeraseflashbuffer(); + for i in h._buf.keys(): + while(i>page+pagelen): + if bcount>0: + client.CCflashpage(page); + client.CCeraseflashbuffer(); + bcount=0; + print "Flashed page at %06x" % page + page+=pagelen; + + #Place byte into buffer. + client.CCpokedatabyte(0xF000+i-page, + h[i]); + bcount+=1; + if(i%0x100==0): + print "Buffering %04x to %06x" % (i,page); + #last page + client.CCflashpage(page); + print "Flashed final page at %06x" % page; + +if(sys.argv[1]=="lock"): + print "Status: %s" %client.CCstatusstr(); + client.CClockchip(); + print "Status: %s" %client.CCstatusstr(); if(sys.argv[1]=="flashpage"): + target=0; + if(len(sys.argv)>2): + target=int(sys.argv[2],16); print "Writing a page of flash from 0xF000 in XDATA" - client.CCflashpage(0x0000); + client.CCflashpage(target); +if(sys.argv[1]=="erasebuffer"): + print "Erasing flash buffer."; + client.CCeraseflashbuffer(); + if(sys.argv[1]=="writedata"): f=sys.argv[2]; start=0;