From 34656085387c5a8d649011bc43c260651d9d8ba9 Mon Sep 17 00:00:00 2001 From: consts Date: Sat, 17 Jun 2017 23:28:55 +0300 Subject: Workaround for MX25 chips https://notabug.org/libreboot/libreboot/issues/193 --- .../0005-Workaround-MX25-reliable-operation.patch | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch (limited to 'projects') diff --git a/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch b/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch new file mode 100644 index 00000000..f46db48e --- /dev/null +++ b/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch @@ -0,0 +1,74 @@ +diff --git a/cli_classic.c b/cli_classic.c +index 0a09cfd..bba601d 100644 +--- a/cli_classic.c ++++ b/cli_classic.c +@@ -61,6 +61,7 @@ static void cli_classic_usage(const char *name) + " -i | --image only flash image from flash layout\n" + " -o | --output log output to \n" + " -L | --list-supported print supported devices\n" ++ " | --workaround-mx more reliable operations with MX25* chips\n" + #if CONFIG_PRINT_WIKI == 1 + " -z | --list-supported-wiki print supported devices in wiki syntax\n" + #endif +@@ -109,6 +110,7 @@ int main(int argc, char *argv[]) + struct flashrom_layout *layout = NULL; + enum programmer prog = PROGRAMMER_INVALID; + int ret = 0; ++ const int WORKAROUND_MX = 0x101; + + static const char optstring[] = "r:Rw:v:nNVEfc:l:i:p:Lzho:"; + static const struct option long_options[] = { +@@ -130,6 +132,7 @@ int main(int argc, char *argv[]) + {"help", 0, NULL, 'h'}, + {"version", 0, NULL, 'R'}, + {"output", 1, NULL, 'o'}, ++ {"workaround-mx", 0, NULL, WORKAROUND_MX}, + {NULL, 0, NULL, 0}, + }; + +@@ -337,6 +340,9 @@ int main(int argc, char *argv[]) + } + #endif /* STANDALONE */ + break; ++ case WORKAROUND_MX: ++ workaround_mx = 1; ++ break; + default: + cli_classic_abort_usage(); + break; +diff --git a/programmer.h b/programmer.h +index 1a6216a..6f97cfc 100644 +--- a/programmer.h ++++ b/programmer.h +@@ -650,6 +650,7 @@ enum ich_chipset { + CHIPSET_8_SERIES_WELLSBURG, + CHIPSET_9_SERIES_WILDCAT_POINT, + }; ++extern int workaround_mx; /* workaround for MX25* chips, makes flash operations more reliable, less failures */ + + /* ichspi.c */ + #if CONFIG_INTERNAL == 1 +diff --git a/spi.c b/spi.c +index 894f73f..05aa5d0 100644 +--- a/spi.c ++++ b/spi.c +@@ -30,10 +30,19 @@ + #include "programmer.h" + #include "spi.h" + ++int workaround_mx; /* Make operations with MX25* chips more reliable */ ++ + int spi_send_command(struct flashctx *flash, unsigned int writecnt, + unsigned int readcnt, const unsigned char *writearr, + unsigned char *readarr) + { ++ if (workaround_mx) { ++ const unsigned char cmd[JEDEC_READ_OUTSIZE] = {JEDEC_READ, 0, 0, 0}; ++ unsigned char buf[256]; ++ /* keep flash busy for some time, keep CS warm before sending actual command */ ++ flash->mst->spi.command(flash, sizeof(cmd), sizeof(buf), cmd, buf); ++ } ++ /* actual command */ + return flash->mst->spi.command(flash, writecnt, readcnt, writearr, + readarr); + } -- cgit v1.2.3-70-g09d2 From 7d727de8c330eab5a7ae725c65b7878685447070 Mon Sep 17 00:00:00 2001 From: consts Date: Sat, 17 Jun 2017 23:51:50 +0300 Subject: Fixed compile error --- .../0005-Workaround-MX25-reliable-operation.patch | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'projects') diff --git a/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch b/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch index f46db48e..b071e6b6 100644 --- a/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch +++ b/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch @@ -1,5 +1,5 @@ diff --git a/cli_classic.c b/cli_classic.c -index 0a09cfd..bba601d 100644 +index 0a09cfd..7bc8ea1 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -61,6 +61,7 @@ static void cli_classic_usage(const char *name) @@ -10,29 +10,21 @@ index 0a09cfd..bba601d 100644 #if CONFIG_PRINT_WIKI == 1 " -z | --list-supported-wiki print supported devices in wiki syntax\n" #endif -@@ -109,6 +110,7 @@ int main(int argc, char *argv[]) - struct flashrom_layout *layout = NULL; - enum programmer prog = PROGRAMMER_INVALID; - int ret = 0; -+ const int WORKAROUND_MX = 0x101; - - static const char optstring[] = "r:Rw:v:nNVEfc:l:i:p:Lzho:"; - static const struct option long_options[] = { -@@ -130,6 +132,7 @@ int main(int argc, char *argv[]) +@@ -130,6 +131,7 @@ int main(int argc, char *argv[]) {"help", 0, NULL, 'h'}, {"version", 0, NULL, 'R'}, {"output", 1, NULL, 'o'}, -+ {"workaround-mx", 0, NULL, WORKAROUND_MX}, ++ {"workaround-mx", 0, NULL, 0x0101}, {NULL, 0, NULL, 0}, }; -@@ -337,6 +340,9 @@ int main(int argc, char *argv[]) +@@ -337,6 +339,9 @@ int main(int argc, char *argv[]) } #endif /* STANDALONE */ break; -+ case WORKAROUND_MX: -+ workaround_mx = 1; -+ break; ++ case 0x0101: /* --workaround-mx */ ++ workaround_mx = 1; ++ break; default: cli_classic_abort_usage(); break; -- cgit v1.2.3-70-g09d2 From 2caaac00972d9ea56b0fcd7c95897e90283b05b8 Mon Sep 17 00:00:00 2001 From: consts Date: Sun, 18 Jun 2017 00:36:33 +0300 Subject: changed description of workaround option in help output --- .../flashrom/patches/0005-Workaround-MX25-reliable-operation.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'projects') diff --git a/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch b/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch index b071e6b6..472afd30 100644 --- a/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch +++ b/projects/flashrom/patches/0005-Workaround-MX25-reliable-operation.patch @@ -1,12 +1,12 @@ diff --git a/cli_classic.c b/cli_classic.c -index 0a09cfd..7bc8ea1 100644 +index 0a09cfd..9eeafe1 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -61,6 +61,7 @@ static void cli_classic_usage(const char *name) " -i | --image only flash image from flash layout\n" " -o | --output log output to \n" " -L | --list-supported print supported devices\n" -+ " | --workaround-mx more reliable operations with MX25* chips\n" ++ " | --workaround-mx keep flash busy before sending command\n" #if CONFIG_PRINT_WIKI == 1 " -z | --list-supported-wiki print supported devices in wiki syntax\n" #endif -- cgit v1.2.3-70-g09d2