From: travisutk Date: Thu, 8 Oct 2009 00:10:41 +0000 (+0000) Subject: Fixed python client buffering issues, minor changes to SPI app. X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=15750ecb20e3f348c419f0666452534c8b6a0b8e Fixed python client buffering issues, minor changes to SPI app. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@194 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- diff --git a/client/GoodFET.py b/client/GoodFET.py index 7497497..ec65900 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -63,9 +63,13 @@ class GoodFET: self.serialport.write(chr(count>>8)); #print "count=%02x, len(data)=%04x" % (count,len(data)); + if count!=0: - for d in data: - self.serialport.write(chr(d)); + for i in range(0,count): + #print "Converting %02x at %i" % (data[i],i) + data[i]=chr(data[i]); + outstr=''.join(data); + self.serialport.write(outstr); if not self.besilent: self.readcmd(); diff --git a/client/GoodFETSPI.py b/client/GoodFETSPI.py index 021c7e6..bd28019 100644 --- a/client/GoodFETSPI.py +++ b/client/GoodFETSPI.py @@ -93,16 +93,12 @@ class GoodFETSPIFlash(GoodFETSPI): self.SPIpokebytes(adr,[val]); def SPIpokebytes(self,adr,data): #Used to be 24 bits, BE, not 32 bits, LE. -# adranddata=[(adr&0xFF0000)>>16, -# (adr&0xFF00)>>8, -# adr&0xFF -# ]+data; adranddata=[adr&0xFF, (adr&0xFF00)>>8, (adr&0xFF0000)>>16, 0, #MSB ]+data; - + #print "%06x: poking %i bytes" % (adr,len(data)); self.writecmd(0x01,0x03, len(adranddata),adranddata); diff --git a/client/goodfet.spiflash b/client/goodfet.spiflash index b7cec4b..d4450c2 100755 --- a/client/goodfet.spiflash +++ b/client/goodfet.spiflash @@ -111,16 +111,21 @@ if(sys.argv[1]=="verify"): file = open(f, mode='rb') i=start; - bits=0; + bytes=0; while i<=stop: - data=client.SPIpeekblock(i,255); + data=client.SPIpeekblock(i); print "Verified %06x." % i; for j in data: if i>16); + spitrans8((adr&0xFF00)>>8); + spitrans8(adr&0xFF); + + SETSS; + while(spiflash_status()&0x01);//while busy + //debugstr("Erased."); +} + + //! Handles a monitor command. void spihandle(unsigned char app, unsigned char verb, @@ -234,7 +262,7 @@ void spihandle(unsigned char app, cmddata+4,//buf len-4);//len - txdata(app,verb,len); + txdata(app,verb,0); break; diff --git a/firmware/include/command.h b/firmware/include/command.h index 4eda217..569dab2 100644 --- a/firmware/include/command.h +++ b/firmware/include/command.h @@ -9,9 +9,11 @@ #define u16 unsigned int #define u32 unsigned long - #ifndef CMDDATALEN +//512 bytes #define CMDDATALEN 0x204 +//4k +//#define CMDDATALEN 0x1004 #endif //! Global data buffer. diff --git a/firmware/include/spi.h b/firmware/include/spi.h index f5c0d8e..e96bef3 100644 --- a/firmware/include/spi.h +++ b/firmware/include/spi.h @@ -35,3 +35,14 @@ void spiflash_peekblock(unsigned long adr, void spiflash_pokeblocks(unsigned long adr, unsigned char *buf, unsigned int len); + + +//! Enable SPI writing +void spiflash_wrten(); + +//! Read and write an SPI byte. +unsigned char spitrans8(unsigned char byte); +//! Grab the SPI flash status byte. +unsigned char spiflash_status(); +//! Erase a sector. +void spiflash_erasesector(unsigned long adr);