Patchwork Dediprog SF100 support

login
register
about
Submitter Carl-Daniel Hailfinger
Date 2010-01-21 09:26:45
Message ID <4B581DD5.5070802@gmx.net>
Download mbox | patch
Permalink /patch/825/
State Superseded
Headers show

Comments

Carl-Daniel Hailfinger - 2010-01-21 09:26:45
On 19.01.2010 13:14, Stefan Reinauer wrote:
> On 1/19/10 1:08 PM, Carl-Daniel Hailfinger wrote:
>   
>> The file specified by -r will only be filled
>> with contents after the read is complete.
>>   
>>     
> Maybe it shouldn't be created before that, either, then?
>   

Hm. If we read for a few minutes, then we notice that the file can't be
created, users will be very unhappy. An alternative would be to remove
the file if read failed, or create it with a temp name and move it into
place at the end.


>> I see a speedup by a factor of 4 on the horizon, but I will implement
>> that only after I get confirmation that read works correctly (would be
>> pointless otherwise).
>>   
>>     
> Requiring 10 minutes to read the chip is still kind of pointless, so I
> don't know if it's worth the effort if the driver can't be generally fixed.
>   

Thanks to Patrick Georgi and his tireless log generation, I was able to
find out how to get good speed out of the dumb mode of the SF100. Write
now works (very slow, slower than the old read, but definitely fixable),
but read speed should now be roughly half the speed of the windows
driver. At least that's the prognosis. Given that we use control
transfers instead of bulk transfers, we have more overhead, but 100%
control over the SPI commands. The windows driver can't do that. Plus,
we're firmware independent with my approach.

Changelog:
Add write support.
Speed up reads by a factor of 64 by switching block size from 4 to 256.
Add support for 4 byte RDID.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Michael Karcher - 2010-01-21 09:41:31
Am Donnerstag, den 21.01.2010, 10:26 +0100 schrieb Carl-Daniel
Hailfinger:
> +	msg_pspew("%s, start=0x%x, len=0x%x\n", __func__, start, len);
> +	/* Maximum read length is 16 bytes for now. */
> +	return spi_read_chunked(flash, buf, start, len, 256);
You want to fix the comment, I suppose.

Regards,
  Michael Karcher
Stefan Reinauer - 2010-01-21 20:50:32
On 1/21/10 10:26 AM, Carl-Daniel Hailfinger wrote:
> Add write support.
> Speed up reads by a factor of 64 by switching block size from 4 to 256.
> Add support for 4 byte RDID.
>
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
>   
Acked-by: Stefan Reinauer <stepan@coresystems.de>

MacPro:flashrom stepan$ time ./flashrom -pdediprog -r testread.rom
flashrom v0.9.1-r878
Calibrating delay loop... OK.
Found chip "ST M25P32" (4096 KB, SPI) at physical address 0xffc00000.
===
This flash part has status UNTESTED for operations: ERASE
Please email a report to flashrom@flashrom.org if any of the above
operations
work correctly for you with this flash part. Please include the flashrom
output with the additional -V option for all operations you tested (-V, -rV,
-wV, -EV), and mention which mainboard or programmer you tested. Thanks
for your help!
===
Reading flash... Command Receive SPI failed, ret=-34, expected 256!
done.

real    0m31.602s
user    0m0.924s
sys    0m0.794s

dd if=/dev/urandom of=testwrite.rom bs=1024 count=$((1024*4))
time ./flashrom -pdediprog -w testwrite.rom
flashrom v0.9.1-r878
Calibrating delay loop... OK.
Found chip "ST M25P32" (4096 KB, SPI) at physical address 0xffc00000.
===
This flash part has status UNTESTED for operations: ERASE
Please email a report to flashrom@flashrom.org if any of the above
operations
work correctly for you with this flash part. Please include the flashrom
output with the additional -V option for all operations you tested (-V, -rV,
-wV, -EV), and mention which mainboard or programmer you tested. Thanks
for your help!
===
Flash image seems to be a legacy BIOS. Disabling checks.
Writing flash chip... Erasing flash before programming... Erasing flash
chip... Command Receive SPI failed, ret=-34, expected 256!
ERASE FAILED at 0x00000000! Expected=0xff, Read=0x00, failed byte count
from 0x00000000-0x0000ffff: 0x16ea
ERASE FAILED!
ERASE FAILED at 0x00000000! Expected=0xff, Read=0x00,
^C

real    1m17.836s
user    0m1.948s
sys    0m2.206s




time ./flashrom -pdediprog -w testwrite.rom -VV
flashrom v0.9.1-r878
dediprog_init
Found USB device (0483:dada).
Found a SF100   V:3.1.8
Setting SPI voltage to 3.500 V
Calibrating delay loop... 761M loops per second, 100 myus = 200 us. OK.
Probing for AMD Am29F010A/B, 128 KB: skipped. Host bus type SPI and chip
bus type Parallel are incompatible.
Probing for AMD Am29F002(N)BB, 256 KB: skipped. Host bus type SPI and
chip bus type Parallel are incompatible.
Probing for AMD Am29F002(N)BT, 256 KB: skipped. Host bus type SPI and
chip bus type Parallel are incompatible.
Probing for AMD Am29F016D, 2048 KB: skipped. Host bus type SPI and chip
bus type Parallel are incompatible.
Probing for AMD Am29F040B, 512 KB: skipped. Host bus type SPI and chip
bus type Parallel are incompatible.
Probing for AMD Am29F080B, 1024 KB: skipped. Host bus type SPI and chip
bus type Parallel are incompatible.
Probing for AMD Am29LV040B, 512 KB: skipped. Host bus type SPI and chip
bus type Parallel are incompatible.
Probing for AMD Am29LV081B, 1024 KB: skipped. Host bus type SPI and chip
bus type Parallel are incompatible.
Probing for ASD AE49F2008, 256 KB: skipped. Host bus type SPI and chip
bus type Parallel are incompatible.
Probing for Atmel AT25DF021, 256 KB: dediprog_spi_send_command,
writecnt=1, readcnt=3
RDID returned 0x20 0x20 0x16. probe_spi_rdid_generic: id1 0x20, id2 0x2016
Probing for Atmel AT25DF041A, 512 KB: dediprog_spi_send_command,
writecnt=1, readcnt=3
RDID returned 0x20 0x20 0x16. probe_spi_rdid_generic: id1 0x20, id2 0x2016
Probing for Atmel AT25DF081, 1024 KB: dediprog_spi_send_command,
writecnt=1, readcnt=3
RDID returned 0x20 0x20 0x16. probe_spi_rdid_generic: id1 0x20, id2 0x2016
Probing for Atmel AT25DF161, 2048 KB: dediprog_spi_send_command,
writecnt=1, readcnt=3
RDID returned 0x20 0x20 0x16. probe_spi_rdid_generic: id1 0x20, id2 0x2016
Probing for Atmel AT25DF321, 4096 KB: dediprog_spi_send_command,
writecnt=1, readcnt=3
RDID returned 0x20 0x20 0x16. probe_spi_rdid_generic: id1 0x20, id2 0x2016
Probing for Atmel AT25DF321A, 4096 KB: dediprog_spi_send_command,
writecnt=1, readcnt=3
RDID returned 0x20 0x20 0x16. probe_spi_rdid_generic: id1 0x20, id2 0x2016
Probing for Atmel AT25DF641, 8192 KB: dediprog_spi_send_command,
writecnt=1, readcnt=3
RDID returned 0x20 0x20 0x16. probe_spi_rdid_generic: id1 0x20, id2 0x2016
[...]
Probing for ST M25P32, 4096 KB: dediprog_spi_send_command, writecnt=1,
readcnt=3
RDID returned 0x20 0x20 0x16. probe_spi_rdid_generic: id1 0x20, id2 0x2016
dediprog_spi_send_command, writecnt=1, readcnt=2
Chip status register is 00
Chip status register: Status Register Write Disable (SRWD) is not set
Chip status register: Bit 6 is not set
Chip status register: Bit 5 / Block Protect 3 (BP3) is not set
Chip status register: Bit 4 / Block Protect 2 (BP2) is not set
Chip status register: Bit 3 / Block Protect 1 (BP1) is not set
Chip status register: Bit 2 / Block Protect 0 (BP0) is not set
Chip status register: Write Enable Latch (WEL) is not set
Chip status register: Write In Progress (WIP/BUSY) is not set
Found chip "ST M25P32" (4096 KB, SPI) at physical address 0xffc00000.
[...]
Flash image seems to be a legacy BIOS. Disabling checks.
Writing flash chip... dediprog_spi_send_command, writecnt=1, readcnt=2
Erasing flash before programming... Erasing flash chip... Looking at
blockwise erase function 0... trying... 0x000000-0x00ffff,
dediprog_spi_send_command, writecnt=1, readcnt=0
dediprog_spi_send_command, writecnt=4, readcnt=0
dediprog_spi_send_command, writecnt=1, readcnt=2
dediprog_spi_send_command, writecnt=1, readcnt=2
dediprog_spi_send_command, writecnt=1, readcnt=2
dediprog_spi_send_command, writecnt=1, readcnt=2
dediprog_spi_send_command, writecnt=1, readcnt=2
dediprog_spi_read, start=0x0, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
Command Receive SPI failed, ret=-34, expected 256!
ERASE FAILED at 0x00000000! Expected=0xff, Read=0x00,dediprog_spi_read,
start=0x100, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x200, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x300, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x400, len=0x100
[...]
dediprog_spi_read, start=0xff00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
 failed byte count from 0x00000000-0x0000ffff: 0x16ea
ERASE FAILED!

Looking at blockwise erase function 1... trying... 0x000000-0x3fffff,
dediprog_spi_send_command, writecnt=1, readcnt=2
dediprog_spi_send_command, writecnt=1, readcnt=0
dediprog_spi_send_command, writecnt=1, readcnt=0
dediprog_spi_send_command, writecnt=1, readcnt=2
dediprog_spi_read, start=0x0, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
ERASE FAILED at 0x00000000! Expected=0xff, Read=0x00,dediprog_spi_read,
start=0x100, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x200, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x300, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x400, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x500, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x600, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x700, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x800, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x900, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0xa00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0xb00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0xc00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0xd00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0xe00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0xf00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x1000, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x1100, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x1200, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x1300, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x1400, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x1500, len=0x100
[...]
dediprog_spi_read, start=0x3ff900, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x3ffa00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x3ffb00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x3ffc00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x3ffd00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x3ffe00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
dediprog_spi_read, start=0x3fff00, len=0x100
dediprog_spi_send_command, writecnt=4, readcnt=256
 failed byte count from 0x00000000-0x003fffff: 0x58000
ERASE FAILED!

Looking at blockwise erase function 2... not defined. Looking for
another erase function.
Looking at blockwise erase function 3... not defined. Looking for
another erase function.
Looking at blockwise erase function 4... not defined. Looking for
another erase function.
FAILED!
ERASE FAILED!
FAILED!
Your flash chip is in an unknown state.
Get help on IRC at irc.freenode.net (channel #flashrom) or
mail flashrom@flashrom.org!
-------------------------------------------------------------------------------
DO NOT REBOOT OR POWEROFF!
dediprog_shutdown
Setting SPI voltage to 0.000 V

real    1m58.392s
user    0m2.733s
sys    0m4.135s

Patch

Index: flashrom-dediprog_bigchunks/spi.c
===================================================================
--- flashrom-dediprog_bigchunks/spi.c	(Revision 877)
+++ flashrom-dediprog_bigchunks/spi.c	(Arbeitskopie)
@@ -335,6 +335,9 @@ 
 #if BUSPIRATE_SPI_SUPPORT == 1
 	case SPI_CONTROLLER_BUSPIRATE:
 #endif
+#if DEDIPROG_SUPPORT == 1
+	case SPI_CONTROLLER_DEDIPROG:
+#endif
 		return probe_spi_rdid_generic(flash, 4);
 	default:
 		printf_debug("4b ID not supported on this SPI controller\n");
Index: flashrom-dediprog_bigchunks/dediprog.c
===================================================================
--- flashrom-dediprog_bigchunks/dediprog.c	(Revision 877)
+++ flashrom-dediprog_bigchunks/dediprog.c	(Arbeitskopie)
@@ -145,8 +145,9 @@ 
 
 int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
 {
-	/* Maximum read length is 4 bytes for now. */
-	return spi_read_chunked(flash, buf, start, len, 4);
+	msg_pspew("%s, start=0x%x, len=0x%x\n", __func__, start, len);
+	/* Maximum read length is 16 bytes for now. */
+	return spi_read_chunked(flash, buf, start, len, 256);
 }
 
 int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
@@ -154,14 +155,17 @@ 
 {
 	int ret;
 
+	msg_pspew("%s, writecnt=%i, readcnt=%i\n", __func__, writecnt, readcnt);
 	/* Paranoid, but I don't want to be blamed if anything explodes. */
-	if ((writecnt != 1) && (writecnt != 4))
+	if (writecnt > 7) {
 		msg_perr("Untested writecnt=%i, aborting.\n", writecnt);
-	if (readcnt > 4)
+		return 1;
+	}
+	/* readcnt=513 was tested, but let's keep this sane. */
+	if (readcnt > 256) {
 		msg_perr("Untested readcnt=%i, aborting.\n", readcnt);
-	if ((readcnt == 0) && (writecnt != 1))
-		msg_perr("Untested writecnt=%i, readcnt=%i combination, "
-			 "aborting.\n", writecnt, readcnt);
+		return 1;
+	}
 	
 	ret = usb_control_msg(dediprog_handle, 0x42, 0x1, 0xff, readcnt ? 0x1 : 0x0, (char *)writearr, writecnt, DEFAULT_TIMEOUT);
 	if (ret != writecnt) {