Patchwork Broken OPMENUs (was: #flashrom talk (atomix vs. stefanct))

login
register
about
Submitter Stefan Tauner
Date 2013-08-08 14:38:58
Message ID <201308081438.r78EcwfQ021240@mail2.student.tuwien.ac.at>
Download mbox | patch
Permalink /patch/4006/
State New
Headers show

Comments

Stefan Tauner - 2013-08-08 14:38:58
I forgot to attach the patch that actually worked on the board. Here it
is.

Patch

From 51d82f7c36037daa359d8a2a4d14aeea5b4dbb24 Mon Sep 17 00:00:00 2001
From: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Date: Thu, 8 Aug 2013 14:09:49 +0200
Subject: [PATCH] Ugly hack for broken OPMENU rdid

Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
---
 flashchips.c | 2 +-
 ichspi.c     | 4 ++++
 spi25.c      | 4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/flashchips.c b/flashchips.c
index a693290..1ecb588 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -9294,7 +9294,7 @@  const struct flashchip flashchips[] = {
 		},
 		.printlock	= spi_prettyprint_status_register_sst25vf016,
 		.unlock		= spi_disable_blockprotect,
-		.write		= spi_aai_write,
+		.write		= spi_chip_write_1,
 		.read		= spi_chip_read,
 		.voltage	= {2700, 3600},
 	},
diff --git a/ichspi.c b/ichspi.c
index 4f6a1b1..ae1e79c 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1021,10 +1021,14 @@  static int ich_spi_send_command(struct flashctx *flash, unsigned int writecnt,
 	 */
 	if ((opcode->spi_type == SPI_OPCODE_TYPE_READ_WITH_ADDRESS) &&
 	    (writecnt != 4)) {
+		if (writecnt > 0 && writearr[0] == 0x9f)
+			writecnt = 4;
+		else {
 		msg_perr("%s: Internal command size error for opcode "
 			"0x%02x, got writecnt=%i, want =4\n", __func__, cmd,
 			writecnt);
 		return SPI_INVALID_LENGTH;
+		}
 	}
 	if ((opcode->spi_type == SPI_OPCODE_TYPE_READ_NO_ADDRESS) &&
 	    (writecnt != 1)) {
diff --git a/spi25.c b/spi25.c
index e001196..17782b9 100644
--- a/spi25.c
+++ b/spi25.c
@@ -31,11 +31,11 @@ 
 
 static int spi_rdid(struct flashctx *flash, unsigned char *readarr, int bytes)
 {
-	static const unsigned char cmd[JEDEC_RDID_OUTSIZE] = { JEDEC_RDID };
+	static const unsigned char cmd[4] = { JEDEC_RDID };
 	int ret;
 	int i;
 
-	ret = spi_send_command(flash, sizeof(cmd), bytes, cmd, readarr);
+	ret = spi_send_command(flash, 1, bytes, cmd, readarr);
 	if (ret)
 		return ret;
 	msg_cspew("RDID returned");
-- 
Kind regards, Stefan Tauner