From: travisutk Date: Thu, 16 Jul 2009 18:54:00 +0000 (+0000) Subject: SPI Flash dumping. X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=92560226caf1a463eb144324978b0a390327e09e SPI Flash dumping. 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 --- diff --git a/client/GoodFET.py b/client/GoodFET.py index 9c11161..952ae98 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -139,6 +139,14 @@ class GoodFET: 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().""" diff --git a/client/goodfet.spiflash b/client/goodfet.spiflash index ef72c28..7056968 100755 --- a/client/goodfet.spiflash +++ b/client/goodfet.spiflash @@ -69,10 +69,15 @@ if(sys.argv[1]=="dump"): 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"): diff --git a/firmware/apps/spi/spi.c b/firmware/apps/spi/spi.c index 2ee2d2c..93a41b9 100644 --- a/firmware/apps/spi/spi.c +++ b/firmware/apps/spi/spi.c @@ -32,9 +32,9 @@ //! 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. @@ -81,6 +81,27 @@ void spihandle(unsigned char app, 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