--- /dev/null
+#!/usr/bin/env python
+# GoodFET EM260 Radio Client
+#
+# (C) 2010 Travis Goodspeed <travis at radiantmachines.com>
+#
+# This code is being rewritten and refactored. You've been warned!
+
+# The EM260 is almost textbook SPI, except that the response cannot be
+# read until after the nHOST_INT pin of the EM260 drops low and a dummy
+# byte is read. That is, the sequence will look like the following:
+
+# Transmit Host->Slave Data
+# while(nHOST_INT); //Sleep until ready.
+# Recv Dummy Byte
+# Recv Slave->Host Data
+
+# The delay is mandatory.
+
+import sys, time, string, cStringIO, struct, glob, serial, os;
+
+from GoodFETSPI import GoodFETSPI;
+
+class GoodFETEM260(GoodFETSPI):
+ EM260APP=0x01;
+ def peek8(self,adr):
+ """Read a byte from the given address."""
+ data=self.SPItrans([0xfe,0x01,0x00,
+ 0x49,
+ 0xA7,0,0,0,0,0,0,0,0]);
+ return ord(data[7]);
+ def poke8(self,adr, byte):
+ """Poke a byte to the given address."""
+ def info(self):
+ """Read the info bytes."""
+ data=self.SPItrans([0x0B,0xA7,
+ 0xFF,
+ 0xFF,0xFF,0xFF, #00 02 A7
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0
+ ]);
+ for foo in data:
+ print "%02x" % ord(foo);
--- /dev/null
+#!/usr/bin/env python
+
+#GoodFET SPI Flash Client
+#by Travis Goodspeed
+
+#N.B.,
+#Might be Winbond W25x80-specific.
+
+import sys;
+import binascii;
+import array;
+
+from GoodFETEM260 import GoodFETEM260;
+from intelhex import IntelHex;
+
+if(len(sys.argv)==1):
+ print "Usage: %s verb [objects]\n" % sys.argv[0];
+ print "%s info" % sys.argv[0];
+ print "%s dump $foo.rom [0x$start 0x$stop]" % sys.argv[0];
+ #print "%s erase" % sys.argv[0];
+ #print "%s flash $foo.rom [0x$start 0x$stop]" % sys.argv[0];
+ #print "%s verify $foo.rom [0x$start 0x$stop]" % sys.argv[0];
+ print "%s peek 0x$start [0x$stop]" % sys.argv[0];
+ #print "%s poke 0x$adr 0x$val" % sys.argv[0];
+ sys.exit();
+
+#Initialize FET and set baud rate
+client=GoodFETEM260();
+client.serInit()
+#client.verbose=1;
+
+client.SPIsetup();
+
+#Dummy read.
+#Might read as all ones if chip has a startup delay.
+
+if(sys.argv[1]=="info"):
+ client.info();
+if(sys.argv[1]=="test"):
+ for adr in range(0,32): #*1024):
+ val=client.peek8(adr);
+ print "%04x:=%02x" % (adr,val);
+if(sys.argv[1]=="dump"):
+ f = sys.argv[2];
+ start=0x0000;
+ stop=4*1024;
+ if(len(sys.argv)>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 = IntelHex(None);
+ i=start;
+ while i<=stop:
+ data=client.peek8(i);
+ print "Dumped %04x=%02x."%(i,data);
+ h[i]=data;
+ i+=1;
+ h.write_hex_file(f);
+
+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: %02x" % (start,client.peek8(start));
+ start=start+1;