summaryrefslogtreecommitdiff
path: root/util/flashrom
diff options
context:
space:
mode:
authorClaus Gindhart <claus.gindhart@kontron.com>2008-05-08 00:31:44 +0000
committerPeter Stuge <peter@stuge.se>2008-05-08 00:31:44 +0000
commit15da8ed98b7e82303a9e9ad633b3cbb42f40f4f5 (patch)
treed47b7bb2568466007f3b1e855d7a74bf81eb30eb /util/flashrom
parent83a965d2efb778c05e080862f77701c9c034c13f (diff)
downloadcoreboot-15da8ed98b7e82303a9e9ad633b3cbb42f40f4f5.tar.xz
flashrom: Probe for up to 3 flash chips.
Currently there is an ongoing technology migration from LPC/FWH to SPI chips. For this reason some boards have multiple chips of different technologies onboard. This patch makes flashrom probe for up to 3 chips and if more than one chip is found flashrom exits, asking the user to specify -c. [root@localhost src]# ./flashrom ... Multiple flash chips were detected: SST49LF008A M25P16@ICH9 Please specify which chip to use with the -c <chipname> option. [root@localhost src]# Signed-off-by: Claus Gindhart <claus.gindhart@kontron.com> Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Claus Gindhart <claus.gindhart@kontron.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3291 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/flashrom')
-rw-r--r--util/flashrom/flashrom.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/util/flashrom/flashrom.c b/util/flashrom/flashrom.c
index 2f3d7c9083..dce303ed3f 100644
--- a/util/flashrom/flashrom.c
+++ b/util/flashrom/flashrom.c
@@ -246,11 +246,12 @@ int main(int argc, char *argv[])
uint8_t *buf;
unsigned long size;
FILE *image;
- struct flashchip *flash;
+ /* Probe for up to three flash chips. */
+ struct flashchip *flash, *flashes[3];
int opt;
int option_index = 0;
int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
- int ret = 0;
+ int ret = 0, i;
static struct option long_options[] = {
{"read", 0, 0, 'r'},
@@ -405,12 +406,27 @@ int main(int argc, char *argv[])
board_flash_enable(lb_vendor, lb_part);
- if ((flash = probe_flash(flashchips)) == NULL) {
+ for (i = 0; i < ARRAY_SIZE(flashes); i++) {
+ flashes[i] = probe_flash(i ? flashes[i - 1] + 1 : flashchips);
+ if (!flashes[i])
+ for (i++; i < ARRAY_SIZE(flashes); i++)
+ flashes[i] = NULL;
+ }
+
+ if (flashes[1]) {
+ printf("Multiple flash chips were detected:");
+ for (i = 0; i < ARRAY_SIZE(flashes) && flashes[i]; i++)
+ printf(" %s", flashes[i]->name);
+ printf("\nPlease specify which chip to use with the -c <chipname> option.\n");
+ exit(1);
+ } else if (!flashes[0]) {
printf("No EEPROM/flash device found.\n");
// FIXME: flash writes stay enabled!
exit(1);
}
+ flash = flashes[0];
+
printf("Flash part is %s (%d KB).\n", flash->name, flash->total_size);
if (TEST_OK_MASK != (flash->tested & TEST_OK_MASK)) {
printf("===\n");