Beginning AVR client.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Wed, 7 Oct 2009 08:58:59 +0000 (08:58 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Wed, 7 Oct 2009 08:58:59 +0000 (08:58 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@189 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETAVR.py [new file with mode: 0644]
client/goodfet.avr [new file with mode: 0644]

diff --git a/client/GoodFETAVR.py b/client/GoodFETAVR.py
new file mode 100644 (file)
index 0000000..2d36a44
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# GoodFET SPI and SPIFlash Client Library
+# 
+# (C) 2009 Travis Goodspeed <travis at radiantmachines.com>
+#
+# This code is being rewritten and refactored.  You've been warned!
+
+import sys, time, string, cStringIO, struct, glob, serial, os;
+
+from GoodFET import GoodFET;
+
+class GoodFETAVR(GoodFET):
+    AVRAPP=0x32;
+    
+    def setup(self):
+        """Move the FET into the SPI application."""
+        self.writecmd(self.AVRAPP,0x10,0,self.data); #SPI/SETUP
+    
+    def trans(self,data):
+        """Exchange data by AVR.
+        Input should probably be 4 bytes."""
+        self.data=data;
+        self.writecmd(self.AVRAPP,0x00,len(data),data);
+        return self.data;
+
+    def start(self):
+        """Start the connection."""
+        self.writecmd(self.AVRAPP,0x20,0,None);
+
+    def identstr(self):
+        """Return an identifying string."""
+        self.writecmd(self.AVRAPP,0x83,0,None);
+        return "AVR(%02x)" % ord(self.data[0]);
diff --git a/client/goodfet.avr b/client/goodfet.avr
new file mode 100644 (file)
index 0000000..ca16880
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import sys;
+import binascii;
+
+from GoodFETAVR import GoodFETAVR;
+from intelhex import IntelHex16bit, IntelHex;
+
+if(len(sys.argv)==1):
+    print "Usage: %s verb [objects]\n" % sys.argv[0];
+    print "%s test" % sys.argv[0];
+    print "%s dump $foo.hex [0x$start 0x$stop]" % sys.argv[0];
+    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];
+    sys.exit();
+
+#Initialize FET and set baud rate
+client=GoodFETAVR();
+client.serInit()
+
+#Connect to target
+client.start();
+#print "setup"
+
+if(sys.argv[1]=="info"):
+       print "Identifies as %s" % client.identstr();