Simon Buhrow has uploaded this change for review.

View Change

Change-Id: Ie4a07499ec5ef0af23818593f45dc427285a9e8a

Change-Id: I218856c79844b31b302ec06f03db5599d274712e
---
M ft2232_spi.c
1 file changed, 19 insertions(+), 4 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/21/40521/1
diff --git a/ft2232_spi.c b/ft2232_spi.c
index 520eb6e..9017a0f 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -398,7 +398,10 @@
msg_perr("Unable to set latency timer (%s).\n", ftdi_get_error_string(ftdic));
}

- if (ftdi_write_data_set_chunksize(ftdic, 270)) {
+ if (ftdi_write_data_set_chunksize(ftdic, 280)) {
+ /* 280 Byte = (9 Byte CMD + 1 Byte WREN) + (9 Byte CMD + 1 Byte op) + 4 Byte Addr
+ * + 256 Byte PageWrite-data
+ with op: PageProgram or Erase; CMD: FTDI-Chip commands*/
msg_perr("Unable to set chunk size (%s).\n", ftdi_get_error_string(ftdic));
}

@@ -467,7 +470,8 @@
struct ftdi_context *ftdic = &ftdic_context;
static unsigned char *buf = NULL;
/* failed is special. We use bitwise ops, but it is essentially bool. */
- int i = 0, ret = 0, failed = 0;
+ static int i = 0;
+ int ret = 0, failed = 0;
int bufsize;
static int oldbufsize = 0;

@@ -475,7 +479,10 @@
return SPI_INVALID_LENGTH;

/* buf is not used for the response from the chip. */
- bufsize = max(writecnt + 9, 260 + 9);
+ bufsize = max(writecnt + 9, 280);
+ /* 280 Byte = (9 Byte CMD + 1 Byte WREN) + (9 Byte CMD + 1 Byte op) + 4 Byte Addr
+ * + 256 Byte PageWrite-data
+ * with op: PageProgram or Erase; CMD: FTDI-Chip commands*/
/* Never shrink. realloc() calls are expensive. */
if (bufsize > oldbufsize) {
buf = realloc(buf, bufsize);
@@ -538,7 +545,15 @@
buf[i++] = SET_BITS_LOW;
buf[i++] = cs_bits;
buf[i++] = pindir;
- ret = send_buf(ftdic, buf, i);
+
+ if (writearr[0] == JEDEC_WREN) {
+ /* Return to get second op (Program or Erase) without resetting buf nor i*/
+ return 0;
+ } else {
+ ret = send_buf(ftdic, buf, i);
+ i = 0;
+ }
+
failed |= ret;
if (ret)
msg_perr("send_buf failed at end: %i\n", ret);

To view, visit change 40521. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I218856c79844b31b302ec06f03db5599d274712e
Gerrit-Change-Number: 40521
Gerrit-PatchSet: 1
Gerrit-Owner: Simon Buhrow
Gerrit-MessageType: newchange