Dumping is a hell of a lot faster in blocks, as round-trip time is
no longer a bottleneck.
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@64
12e2690d-a6be-4b82-a7b7-
67c4a43b65c8
0];
self.SPItrans(data);
return ord(self.data[4]);
+ def SPIpeekblock(self,adr):
+ """Grab a byte from an SPI Flash ROM."""
+ data=[(adr&0xFF0000)>>16,
+ (adr&0xFF00)>>8,
+ adr&0xFF];
+
+ self.writecmd(0x01,0x02,3,data);
+ return self.data;
def SPIjedecmanstr(self):
"""Grab the JEDEC manufacturer string. Call after SPIjedec()."""
h = IntelHex(None);
i=start;
while i<=stop:
- h[i>>1]=client.SPIpeek(i);
+ data=client.SPIpeekblock(i);
+
+
if(i%0x100==0):
print "Dumped %04x."%i;
- i+=1;
+ for j in data:
+ h[i]=ord(j);
+ #print "*%08x=%02x" % (i,ord(j));
+ i+=1;
h.write_hex_file(f);
if(sys.argv[1]=="erase"):
//! Set up the pins for SPI mode.
void spisetup(){
+ P5OUT|=SS;
P5DIR|=MOSI+SCK+SS;
P5DIR&=~MISO;
- P5OUT|=SS;
}
//! Read and write an SPI bit.
P5OUT|=SS; //Raise !SS to end transaction.
txdata(app,verb,len);
break;
+ case SPI_JEDEC://Grab 3-byte JEDEC ID.
+ P5OUT&=~SS; //Drop !SS to begin transaction.
+ spitrans8(0x9f);
+ len=3;
+ for(i=0;i<len;i++)
+ cmddata[i]=spitrans8(cmddata[i]);
+ txdata(app,verb,len);
+ P5OUT|=SS; //Raise !SS to end transaction.
+ break;
+ case PEEK://Grab 128 bytes from an SPI Flash ROM
+ P5OUT&=~SS; //Drop !SS to begin transaction.
+ spitrans8(0x03);//Flash Read Command
+ len=3;//write 3 byte pointer
+ for(i=0;i<len;i++)
+ spitrans8(cmddata[i]);
+ len=0x80;//128 byte chunk
+ for(i=0;i<len;i++)
+ cmddata[i]=spitrans8(0);
+ txdata(app,verb,len);
+ P5OUT|=SS; //Raise !SS to end transaction.
+ break;
case SETUP:
spisetup();
txdata(app,verb,0);
#define JTAG_DR_SHIFT 0x81
#define JTAG_DR_SHIFT20 0x91
+//SPI commands
+#define SPI_JEDEC 0x80
+#define SPI_ERASE 0x81
+#define SPI_WRITE 0x82
+
//JTAG430 commands
#define JTAG430_HALTCPU 0xA0
#define JTAG430_RELEASECPU 0xA1