Found you SPI page which had the write then read command listed. So I did a quick hack (see below) where I used that mode instead of Bulk SPI. Seems to be down to a couple of seconds above 1minute, which kind of also puzzles me. I'm calculating the max speed in my case at 115200,1 start and 1 stop to 2048*1024/(115200/10)/60~3minutes (what do I miss??). Here is the run:
date;./flashrom -p buspirate_spi:dev=/dev/ttyACM0,spispeed=1M -r spidmp10;date
Wed Apr 4 08:47:47 CEST 2012
flashrom v0.9.5-r1504 on Linux 3.0.0-17-generic-pae (i686), built with libpci 3.0.0, GCC 4.4.3, little endian
flashrom is free software, get the source code at
Calibrating delay loop... OK.
Found ST flash chip "M25P16" (2048 kB, SPI) on buspirate_spi.
===
This flash part has status UNTESTED for operations: ERASE WRITE
The test status of this chip may have been updated in the latest development
version of flashrom. If you are running the latest development version,
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, -Vr,
-VE, -Vw), and mention which mainboard or programmer you tested.
Please mention your board in the subject line. Thanks for your help!
Reading flash... done.
Wed Apr 4 08:48:54 CEST 2012
I also did a printout from flashrom about the clock setting and it seems to be correct (8M->0x67 and 4M->0x66). My scope indicates that 4M and 8M doesn't work though, so it seems to be a problem in the firmware.
hack:
--- buspirate_spi.c_org 2012-04-04 07:47:03.695354455 +0200
+++ buspirate_spi.c 2012-04-04 08:45:31.538215459 +0200
@@ -94,8 +94,8 @@
static const struct spi_programmer spi_programmer_buspirate = {
.type = SPI_CONTROLLER_BUSPIRATE,
- .max_data_read = 12,
- .max_data_write = 12,
+ .max_data_read = 4096,
+ .max_data_write = 4096,
.command = buspirate_spi_send_command,
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
@@ -304,29 +304,36 @@
unsigned int i = 0;
int ret = 0;
- if (writecnt > 16 || readcnt > 16 || (readcnt + writecnt) > 16)
+ if (writecnt > 4096 || readcnt > 4096)
return SPI_INVALID_LENGTH;
+
+ msg_pdbg("Reading %d bytes and writing %d bytesn", readcnt,writecnt);
- /* 3 bytes extra for CS#, len, CS#. */
- buf = realloc(buf, writecnt + readcnt + 3);
+ /* 5 bytes extra for cmd, wr length, re length */
+ buf = realloc(buf, max(writecnt,readcnt) + 5);
if (!buf) {
msg_perr("Out of memory!n");
exit(1); // -1
}
+
+ /* Write then read command */
+ buf[i++] = 0x04;
+
+ /*write bytes*/
+ buf[i++] = (writecnt >> 8) & 0xFF;
+ buf[i++] = (writecnt) & 0xFF;
+
+ /*read bytes*/
+ buf[i++] = (readcnt >> 8) & 0xFF;
+ buf[i++] = (readcnt) & 0xFF;
- /* Assert CS# */
- buf[i++] = 0x02;
- buf[i++] = 0x10 | (writecnt + readcnt - 1);
+
memcpy(buf + i, writearr, writecnt);
i += writecnt;
- memset(buf + i, 0, readcnt);
-
- i += readcnt;
- /* De-assert CS# */
- buf[i++] = 0x03;
-
- ret = buspirate_sendrecv(buf, i, i);
+
+ /*read one extra byte for status*/
+ ret = buspirate_sendrecv(buf,i ,readcnt+1 );
if (ret) {
msg_perr("Bus Pirate communication error!n");
@@ -334,22 +341,13 @@
}
if (buf[0] != 0x01) {
- msg_perr("Protocol error while lowering CS#!n");
+ msg_perr("Protocol error!n");
return SPI_GENERIC_ERROR;
}
- if (buf[1] != 0x01) {
- msg_perr("Protocol error while reading/writing SPI!n");
- return SPI_GENERIC_ERROR;
- }
-
- if (buf[i - 1] != 0x01) {
- msg_perr("Protocol error while raising CS#!n");
- return SPI_GENERIC_ERROR;
- }
- /* Skip CS#, length, writearr. */
- memcpy(readarr, buf + 2 + writecnt, readcnt);
+ /* Skip status byte */
+ memcpy(readarr, buf + 1, readcnt);
return ret;
}