SPI Flash writing is now performed in chunks,
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sun, 19 Jul 2009 13:52:49 +0000 (13:52 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sun, 19 Jul 2009 13:52:49 +0000 (13:52 +0000)
and a bug with the execution of the first command after powerup
has been fixed.  This client is now useful.

git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@70 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFET.py
client/goodfet.spiflash
firmware/apps/spi/spi.c

index cbcf1c4..b87cee8 100755 (executable)
@@ -102,7 +102,7 @@ class GoodFET:
     def SPIsetup(self):
         """Moved the FET into the SPI application."""
         self.writecmd(0x01,0x10,0,self.data); #SPI/SETUP
-        #self.readcmd();
+        
     def SPItrans8(self,byte):
         """Read and write 8 bits by SPI."""
         data=self.SPItrans([byte]);
index a04ed19..354d502 100755 (executable)
@@ -28,8 +28,13 @@ if(len(sys.argv)==1):
 client=GoodFET();
 client.serInit("/dev/ttyUSB0")
 
+
 client.SPIsetup();
 
+#Dummy read.
+#Might read as all ones if chip has a startup delay.
+client.SPIjedec();
+
 if(sys.argv[1]=="test"):
     result="";
     dropped=0;
@@ -93,11 +98,17 @@ if(sys.argv[1]=="flash"):
     file = open(f, mode='rb')
 
     i=start;
-    bytes=file.read();
+    chars=list(file.read());
+    chunksize=0x80;
+    
     while i<=stop:
-        client.SPIpokebyte(i,ord(bytes[i]));
+        bytes=range(0,chunksize);
+        for j in range(0,chunksize):
+            bytes[j]=ord(chars[i+j]);
+        #client.SPIpokebyte(i,ord(chars[i]));
+        client.SPIpokebytes(i,bytes);
         
-        i+=1;
+        i+=chunksize;
         if(i%0x100==0):
             print "Flashed %06x."%i;
     file.close()
index e00d2aa..c70cdb4 100644 (file)
@@ -35,6 +35,10 @@ void spisetup(){
   P5OUT|=SS;
   P5DIR|=MOSI+SCK+SS;
   P5DIR&=~MISO;
+  
+  //Begin a new transaction.
+  P5OUT&=~SS; 
+  P5OUT|=SS;
 }
 
 //! Read and write an SPI bit.