From 270237687a7f550e86c01548550f25b1d0a31d65 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Wed, 28 Apr 2010 15:22:14 +0000 Subject: One of the problems is that --force had multiple meanings - Force chip read by faking probe success. - Force chip access even if the chip is bigger than max decode size for the flash bus. - Force erase even if erase is known bad. - Force write even if write is known bad. - Force writing even if cbtable tells us that this is the wrong image for this board. This patch cleans up --force usage: - Remove any suggestions to use --force for probe/read from flashrom output. - Don't talk about "success" or "Found chip" if the chip is forced. - Add a new internal programmer parameter boardmismatch=force. This overrides any mismatch detection from cbtable/image comparisons. - Add a new internal programmer parameter laptop=force_I_want_a_brick. - Adjust the documentation for --force. - Clean up the man page a bit whereever it talks about --force or laptops. Additional changes in this patch: - Add warnings about laptops to the documentation. - Abort if a laptop is detected. Can be overridden with the programmer parameter mentioned above. - Add "Portable" to the list of DMI strings indicating laptops. - Check if a chip specified with -c is known to flashrom. - Programmer parameter reliability and consistency fixes. - More paranoid self-checks. - Improve documentation. Corresponding to flashrom svn r996. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Michael Karcher --- cli_classic.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'cli_classic.c') diff --git a/cli_classic.c b/cli_classic.c index 6cb0578..24762fe 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -248,6 +248,10 @@ int cli_classic(int argc, char *argv[]) switch (optarg[namelen]) { case ':': programmer_param = strdup(optarg + namelen + 1); + if (!strlen(programmer_param)) { + free(programmer_param); + programmer_param = NULL; + } break; case '\0': break; @@ -303,6 +307,21 @@ int cli_classic(int argc, char *argv[]) cli_classic_usage(argv[0]); } + if (chip_to_probe) { + for (flash = flashchips; flash && flash->name; flash++) + if (!strcmp(flash->name, chip_to_probe)) + break; + if (!flash || !flash->name) { + fprintf(stderr, "Error: Unknown chip '%s' specified.\n", + chip_to_probe); + printf("Run flashrom -L to view the hardware supported " + "in this flashrom version.\n"); + exit(1); + } + /* Clean up after the check. */ + flash = NULL; + } + if (programmer_init()) { fprintf(stderr, "Error: Programmer initialization failed.\n"); exit(1); @@ -329,18 +348,14 @@ int cli_classic(int argc, char *argv[]) } else if (!flashes[0]) { printf("No EEPROM/flash device found.\n"); if (!force || !chip_to_probe) { - printf("If you know which flash chip you have, and if this version of flashrom\n"); - printf("supports a similar flash chip, you can try to force read your chip. Run:\n"); - printf("flashrom -f -r -c similar_supported_flash_chip filename\n"); - printf("\n"); - printf("Note: flashrom can never write when the flash chip isn't found automatically.\n"); + printf("Note: flashrom can never write if the flash chip isn't found automatically.\n"); } if (force && read_it && chip_to_probe) { - printf("Force read (-f -r -c) requested, forcing chip probe success:\n"); + printf("Force read (-f -r -c) requested, pretending the chip is there:\n"); flashes[0] = probe_flash(flashchips, 1); if (!flashes[0]) { - printf("flashrom does not support a flash chip named '%s'.\n", chip_to_probe); - printf("Run flashrom -L to view the hardware supported in this flashrom version.\n"); + printf("Probing for flash chip '%s' failed.\n", chip_to_probe); + programmer_shutdown(); exit(1); } printf("Please note that forced reads most likely contain garbage.\n"); -- cgit v1.1