Mike Banon has uploaded this change for review. ( https://review.coreboot.org/23262
Change subject: [v4,5/6] Add the hidden-from-probing chips category and make KB9012 hidden
......................................................................
[v4,5/6] Add the hidden-from-probing chips category and make KB9012 hidden
There are some chips like ENE KB9012, probing for which
could cause the other chips to misbehave. Therefore, such chips
should be "hidden" - not probed for unless the user wants
This commit introduces a new field to the "flashchip" structure:
int hidden;
Now it is possible to "hide" any chip by adding this line
.hidden = 1,
to the "struct flashchip flashchips[]" structure of a chip, like
.write = edi_chip_write,
.read = edi_chip_read,
.voltage = {2700, 3600},
.hidden = 1,
},
^^^ KB9012 has been "hidden" this way, and it will never be probed for
unless explicitly specified by its' chip name: --chip "KB9012 (EDI)"
Now, flashrom will probe for a chip only if one of these conditions is true:
1) no chip has been specified AND this chip is not "hidden"
2) this chip has been specified by -c | --chip <chipname>
Change-Id: I89a53ccaef2791a2ac32904d7ab813da7478a6f0
Signed-off-by: Mike Banon <mikebdp2(a)gmail.com>
---
M flash.h
M flashchips.c
M flashrom.c
3 files changed, 17 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/62/23262/1
diff --git a/flash.h b/flash.h
index a3aebc5..1c4a38c 100644
--- a/flash.h
+++ b/flash.h
@@ -190,6 +190,14 @@
enum test_state write;
} tested;
+ /*
+ * There are some chips, probing for which could cause the other chips to misbehave.
+ * Therefore, such chips should be "hidden" - not probed for unless the user wants
+ *
+ * If set to 1, do not probe for this chip unless specified by -c | --chip <chipname>
+ */
+ int hidden;
+
int (*probe) (struct flashctx *flash);
/* Delay after "enter/exit ID mode" commands in microseconds.
diff --git a/flashchips.c b/flashchips.c
index 866d8e1..7b82602 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -43,6 +43,7 @@
* .total_size = Total size in (binary) kbytes
* .page_size = Page or eraseblock(?) size in bytes
* .tested = Test status
+ * .hidden = If set to 1, do not probe unless specified
* .probe = Probe function
* .probe_timing = Probe function delay
* .block_erasers[] = Array of erase layouts and erase functions
@@ -3302,6 +3303,7 @@
.write = edi_chip_write,
.read = edi_chip_read,
.voltage = {2700, 3600},
+ .hidden = 1,
},
{
diff --git a/flashrom.c b/flashrom.c
index 361a44f..f699798 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1205,7 +1205,13 @@
char *tmp;
for (chip = flashchips + startchip; chip && chip->name; chip++) {
- if (chip_to_probe && strcmp(chip->name, chip_to_probe) != 0)
+ /*
+ * Probe for a chip only if one of these conditions is true:
+ * 1) no chip has been specified AND this chip is not "hidden"
+ * 2) this chip has been specified by -c | --chip <chipname>
+ */
+ if (!((!chip_to_probe && !chip->hidden) ||
+ (chip_to_probe && strcmp(chip->name, chip_to_probe) == 0)))
continue;
buses_common = mst->buses_supported & chip->bustype;
if (!buses_common)
--
To view, visit https://review.coreboot.org/23262
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I89a53ccaef2791a2ac32904d7ab813da7478a6f0
Gerrit-Change-Number: 23262
Gerrit-PatchSet: 1
Gerrit-Owner: Mike Banon <mikebdp2(a)gmail.com>
Mike Banon has uploaded this change for review. ( https://review.coreboot.org/23260
Change subject: [v4,3/6] ENE EDI - add dummy read to ensure proper detection of ENE chips
......................................................................
[v4,3/6] ENE EDI - add dummy read to ensure proper detection of ENE chips
ENE chips enable EDI by detecting a clock frequency between 1 MHz and 8 MHz.
In many cases, the chip won't be able to both detect the clock signal and
serve the associated request at the same time.
Thus, a dummy read has to be added to ensure that EDI is enabled and
operational starting from the next request.
Original patch has been created by Paul Kocialkowski, the previous version:
http://git.code.paulk.fr/gitweb/?p=flashrom.git;a=shortlog;h=refs/heads/next
Now it has been ported to the latest source code of flashrom master branch
Change-Id: I69ee71674649cd8ba4fc635f889cb39a1cd204b9
Signed-off-by: Mike Banon <mikebdp2(a)gmail.com>
---
M edi.c
1 file changed, 18 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/60/23260/1
diff --git a/edi.c b/edi.c
index 0ca1704..fde5ff1 100644
--- a/edi.c
+++ b/edi.c
@@ -163,6 +163,14 @@
return 0;
}
+static void edi_detect(struct flashctx *flash)
+{
+ unsigned char hwversion;
+
+ /* This dummy read ensures proper detection of EDI. */
+ edi_read(flash, ENE_EC_HWVERSION, &hwversion);
+}
+
static int edi_spi_enable(struct flashctx *flash)
{
unsigned char buffer;
@@ -481,6 +489,16 @@
int probe;
int rc;
+ /*
+ * ENE chips enable EDI by detecting a clock frequency between 1 MHz and
+ * 8 MHz. In many cases, the chip won't be able to both detect the clock
+ * signal and serve the associated request at the same time.
+ *
+ * Thus, a dummy read has to be added to ensure that EDI is enabled and
+ * operational starting from the next request.
+ */
+ edi_detect(flash);
+
probe = edi_chip_probe(flash, &ene_kb9012);
if (!probe)
return 0;
--
To view, visit https://review.coreboot.org/23260
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I69ee71674649cd8ba4fc635f889cb39a1cd204b9
Gerrit-Change-Number: 23260
Gerrit-PatchSet: 1
Gerrit-Owner: Mike Banon <mikebdp2(a)gmail.com>
Mike Banon has uploaded this change for review. ( https://review.coreboot.org/23258
Change subject: [v4,1/6] Add support for selecting the erased bit value with a flag
......................................................................
[v4,1/6] Add support for selecting the erased bit value with a flag
Most flash chips are erased to ones and programmed to zeros. However, some
other chips, such as the ENE KB9012 internal flash, work the opposite way.
Original patch has been created by Paul Kocialkowski, the previous version:
http://patchwork.coreboot.org/patch/4412/
Now it has been ported to the latest source code of flashrom master branch
Change-Id: Ia7b0de8568e31f9bf263ba0ad6b051e837477b6b
Signed-off-by: Mike Banon <mikebdp2(a)gmail.com>
---
M flash.h
M flashrom.c
2 files changed, 24 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/58/23258/1
diff --git a/flash.h b/flash.h
index d31b256..a3aebc5 100644
--- a/flash.h
+++ b/flash.h
@@ -130,6 +130,13 @@
#define FEATURE_4BA_NATIVE (FEATURE_4BA_READ | FEATURE_4BA_FAST_READ | FEATURE_4BA_WRITE)
#define FEATURE_4BA (FEATURE_4BA_ENTER | FEATURE_4BA_EXT_ADDR | FEATURE_4BA_NATIVE)
#define FEATURE_4BA_WREN (FEATURE_4BA_ENTER_WREN | FEATURE_4BA_EXT_ADDR | FEATURE_4BA_NATIVE)
+/*
+ * Most flash chips are erased to ones and programmed to zeros. However, some
+ * other flash chips, such as the ENE KB9012 internal flash, work the opposite way.
+ */
+#define FEATURE_ERASED_ZERO (1 << 16)
+
+#define ERASED_VALUE(flash) (((flash)->chip->feature_bits & FEATURE_ERASED_ZERO) ? 0x00 : 0xff)
enum test_state {
OK = 0,
@@ -298,7 +305,7 @@
int read_flash_to_file(struct flashctx *flash, const char *filename);
char *extract_param(const char *const *haystack, const char *needle, const char *delim);
int verify_range(struct flashctx *flash, const uint8_t *cmpbuf, unsigned int start, unsigned int len);
-int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len, enum write_granularity gran);
+int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len, enum write_granularity gran, const uint8_t erased_value);
void print_version(void);
void print_buildinfo(void);
void print_banner(void);
diff --git a/flashrom.c b/flashrom.c
index ac987fd..361a44f 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -700,12 +700,13 @@
{
int ret;
uint8_t *cmpbuf = malloc(len);
+ const uint8_t erased_value = ERASED_VALUE(flash);
if (!cmpbuf) {
msg_gerr("Could not allocate memory!\n");
exit(1);
}
- memset(cmpbuf, 0xff, len);
+ memset(cmpbuf, erased_value, len);
ret = verify_range(flash, cmpbuf, start, len);
free(cmpbuf);
return ret;
@@ -758,7 +759,7 @@
}
/* Helper function for need_erase() that focuses on granularities of gran bytes. */
-static int need_erase_gran_bytes(const uint8_t *have, const uint8_t *want, unsigned int len, unsigned int gran)
+static int need_erase_gran_bytes(const uint8_t *have, const uint8_t *want, unsigned int len, unsigned int gran, const uint8_t erased_value)
{
unsigned int i, j, limit;
for (j = 0; j < len / gran; j++) {
@@ -768,7 +769,7 @@
continue;
/* have needs to be in erased state. */
for (i = 0; i < limit; i++)
- if (have[j * gran + i] != 0xff)
+ if (have[j * gran + i] != erased_value)
return 1;
}
return 0;
@@ -788,7 +789,7 @@
* @gran write granularity (enum, not count)
* @return 0 if no erase is needed, 1 otherwise
*/
-int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len, enum write_granularity gran)
+int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len, enum write_granularity gran, const uint8_t erased_value)
{
int result = 0;
unsigned int i;
@@ -803,31 +804,31 @@
break;
case write_gran_1byte:
for (i = 0; i < len; i++)
- if ((have[i] != want[i]) && (have[i] != 0xff)) {
+ if ((have[i] != want[i]) && (have[i] != erased_value)) {
result = 1;
break;
}
break;
case write_gran_128bytes:
- result = need_erase_gran_bytes(have, want, len, 128);
+ result = need_erase_gran_bytes(have, want, len, 128, erased_value);
break;
case write_gran_256bytes:
- result = need_erase_gran_bytes(have, want, len, 256);
+ result = need_erase_gran_bytes(have, want, len, 256, erased_value);
break;
case write_gran_264bytes:
- result = need_erase_gran_bytes(have, want, len, 264);
+ result = need_erase_gran_bytes(have, want, len, 264, erased_value);
break;
case write_gran_512bytes:
- result = need_erase_gran_bytes(have, want, len, 512);
+ result = need_erase_gran_bytes(have, want, len, 512, erased_value);
break;
case write_gran_528bytes:
- result = need_erase_gran_bytes(have, want, len, 528);
+ result = need_erase_gran_bytes(have, want, len, 528, erased_value);
break;
case write_gran_1024bytes:
- result = need_erase_gran_bytes(have, want, len, 1024);
+ result = need_erase_gran_bytes(have, want, len, 1024, erased_value);
break;
case write_gran_1056bytes:
- result = need_erase_gran_bytes(have, want, len, 1056);
+ result = need_erase_gran_bytes(have, want, len, 1056, erased_value);
break;
case write_gran_1byte_implicit_erase:
/* Do not erase, handle content changes from anything->0xff by writing 0xff. */
@@ -1769,11 +1770,12 @@
ret = 1;
bool skipped = true;
uint8_t *const curcontents = info->curcontents + info->erase_start;
- if (need_erase(curcontents, newcontents, erase_len, flashctx->chip->gran)) {
+ const uint8_t erased_value = ERASED_VALUE(flashctx);
+ if (need_erase(curcontents, newcontents, erase_len, flashctx->chip->gran, erased_value)) {
if (erase_block(flashctx, info, erasefn))
goto _free_ret;
/* Erase was successful. Adjust curcontents. */
- memset(curcontents, 0xff, erase_len);
+ memset(curcontents, erased_value, erase_len);
skipped = false;
}
--
To view, visit https://review.coreboot.org/23258
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia7b0de8568e31f9bf263ba0ad6b051e837477b6b
Gerrit-Change-Number: 23258
Gerrit-PatchSet: 1
Gerrit-Owner: Mike Banon <mikebdp2(a)gmail.com>
Mike Banon has abandoned this change. ( https://review.coreboot.org/23257 )
Change subject: Insert the description of the change.
......................................................................
Abandoned
--
To view, visit https://review.coreboot.org/23257
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: abandon
Gerrit-Change-Id: Ieef213d92847d7452200cab929d49e16cb262c39
Gerrit-Change-Number: 23257
Gerrit-PatchSet: 1
Gerrit-Owner: Mike Banon <mikebdp2(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Mike Banon has restored this change. ( https://review.coreboot.org/23257 )
Change subject: Insert the description of the change.
......................................................................
Restored
--
To view, visit https://review.coreboot.org/23257
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: restore
Gerrit-Change-Id: Ieef213d92847d7452200cab929d49e16cb262c39
Gerrit-Change-Number: 23257
Gerrit-PatchSet: 1
Gerrit-Owner: Mike Banon <mikebdp2(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Mike Banon has abandoned this change. ( https://review.coreboot.org/23257 )
Change subject: Insert the description of the change.
......................................................................
Abandoned
--
To view, visit https://review.coreboot.org/23257
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: abandon
Gerrit-Change-Id: Ieef213d92847d7452200cab929d49e16cb262c39
Gerrit-Change-Number: 23257
Gerrit-PatchSet: 1
Gerrit-Owner: Mike Banon <mikebdp2(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Mike Banon has posted comments on this change. ( https://review.coreboot.org/23257 )
Change subject: Insert the description of the change.
......................................................................
Set Ready For Review
--
To view, visit https://review.coreboot.org/23257
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ieef213d92847d7452200cab929d49e16cb262c39
Gerrit-Change-Number: 23257
Gerrit-PatchSet: 1
Gerrit-Owner: Mike Banon <mikebdp2(a)gmail.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Sun, 14 Jan 2018 19:53:12 +0000
Gerrit-HasComments: No
Gerrit-HasLabels: No