Replace --mainboard with -p internal:mainboard
Corresponds to r1483 from upstream.
The --list-supported-wiki output changed to use -p internal:mainboard=
instead of -m
The --list-supported output changed the heading of the mainboard list
from:
Vendor Board Status Required option
to
Vendor Board Status Required value for
-p internal:mainboard=
Fixed lb_vendor_dev_from_string() not to write to the supplied string.
BUG=chromium:478356
BRANCH=none
TEST=needs testing
Change-Id: I15c9981e344c7fd75dc70ba6de94d459ad80e7b0
Signed-off-by: Souvik Ghosh <souvikghosh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/366031
Reviewed-by: David Hendricks <dhendrix@chromium.org>
diff --git a/board_enable.c b/board_enable.c
index c9dc713..1db1299 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -2070,7 +2070,8 @@
* The coreboot ids are used two fold. When running with a coreboot firmware,
* the ids uniquely matches the coreboot board identification string. When a
* legacy bios is installed and when autodetection is not possible, these ids
- * can be used to identify the board through the -m command line argument.
+ * can be used to identify the board through the -p internal:mainboard=
+ * programmer parameter.
*
* When a board is identified through its coreboot ids (in both cases), the
* main pci ids are still required to match, as a safeguard.
@@ -2245,7 +2246,7 @@
msg_pinfo("AMBIGUOUS BOARD NAME: %s\n", part);
msg_pinfo("At least vendors '%s' and '%s' match.\n",
partmatch->lb_vendor, board->lb_vendor);
- msg_perr("Please use the full -m vendor:part syntax.\n");
+ msg_perr("Please use the full -p internal:mainboard=vendor:part syntax.\n");
return NULL;
}
partmatch = board;
@@ -2259,7 +2260,7 @@
* coreboot table. If it was, the coreboot implementor is
* expected to fix flashrom, too.
*/
- msg_perr("\nUnknown vendor:board from -m option: %s:%s\n\n",
+ msg_perr("\nUnknown vendor:board from -p internal:mainboard= programmer parameter:\n%s:%s\n\n",
vendor, part);
}
return NULL;
diff --git a/cbtable.c b/cbtable.c
index 5361a3d..a91428a 100644
--- a/cbtable.c
+++ b/cbtable.c
@@ -33,18 +33,27 @@
char *lb_part = NULL, *lb_vendor = NULL;
int partvendor_from_cbtable = 0;
-void lb_vendor_dev_from_string(char *boardstring)
+/* Parse the [<vendor>:]<board> string specified by the user as part of
+ * -p internal:mainboard=[<vendor>:]<board> and set lb_vendor and lb_part
+ * to the extracted values.
+ * Note: strtok modifies the original string, so we work on a copy and allocate
+ * memory for lb_vendor and lb_part with strdup.
+ */
+void lb_vendor_dev_from_string(const char *boardstring)
{
+ /* strtok may modify the original string. */
+ char *tempstr = strdup(boardstring);
char *tempstr2 = NULL;
- strtok(boardstring, ":");
+ strtok(tempstr, ":");
tempstr2 = strtok(NULL, ":");
if (tempstr2) {
- lb_vendor = boardstring;
- lb_part = tempstr2;
+ lb_vendor = strdup(tempstr);
+ lb_part = strdup(tempstr2);
} else {
lb_vendor = NULL;
- lb_part = boardstring;
+ lb_part = strdup(tempstr);
}
+ free(tempstr);
}
static unsigned long compute_checksum(void *addr, unsigned long length)
diff --git a/cli_mfg.c b/cli_mfg.c
index d473004..367b2b0 100644
--- a/cli_mfg.c
+++ b/cli_mfg.c
@@ -121,8 +121,8 @@
"-z|"
#endif
"-E|-r <file>|-w <file>|-v <file>]\n"
- " [-i <image>[:<file>]] [-c <chipname>] [-o <file>]\n"
- "[-m [<vendor>:]<part>] [-l <file>]\n"
+ " [-i <image>[:<file>]] [-c <chipname>]\n"
+ "[-o <file>] [-l <file>]\n"
" [-p <programmer>[:<parameters>]]\n\n");
msg_ginfo("Please note that the command line interface for flashrom has "
@@ -145,11 +145,6 @@
" -V | --verbose more verbose output\n"
" -c | --chip <chipname> probe only for specified "
"flash chip\n"
-#if CONFIG_INTERNAL == 1
- /* FIXME: --mainboard should be a programmer parameter */
- " -m | --mainboard <[vendor:]part> override mainboard "
- "detection\n"
-#endif
" -f | --force force specific operations "
"(see man page)\n"
" -n | --noverify don't auto-verify\n"
@@ -255,7 +250,7 @@
int rc = 0;
int found_chip = 0;
- const char *optstring = "rRwvnVEfc:m:l:i:p:o:Lzhbx";
+ const char *optstring = "rRwvnVEfc:l:i:p:o:Lzhbx";
static struct option long_options[] = {
{"read", 0, 0, 'r'},
{"write", 0, 0, 'w'},
@@ -263,7 +258,6 @@
{"verify", 0, 0, 'v'},
{"noverify", 0, 0, 'n'},
{"chip", 1, 0, 'c'},
- {"mainboard", 1, 0, 'm'},
{"verbose", 0, 0, 'V'},
{"force", 0, 0, 'f'},
{"layout", 1, 0, 'l'},
@@ -383,17 +377,6 @@
broken_timer = 1;
#endif
break;
- case 'm':
-#if CONFIG_INTERNAL == 1
- tempstr = strdup(optarg);
- lb_vendor_dev_from_string(tempstr);
-#else
- msg_gerr("Error: Internal programmer support "
- "was not compiled in and --mainboard only\n"
- "applies to the internal programmer. Aborting.\n");
- cli_mfg_abort_usage(argv[0]);
-#endif
- break;
case 'f':
force = 1;
break;
@@ -657,13 +640,6 @@
if (prog == PROGRAMMER_INVALID)
prog = default_programmer;
-#if CONFIG_INTERNAL == 1
- if ((prog != PROGRAMMER_INTERNAL) && (lb_part || lb_vendor)) {
- msg_gerr("Error: --mainboard requires the internal "
- "programmer. Aborting.\n");
- cli_mfg_abort_usage(argv[0]);
- }
-#endif
#if USE_BIG_LOCK == 1
/* get lock before doing any work that touches hardware */
diff --git a/flashrom.8 b/flashrom.8
index 49ae1b5..a27024f 100644
--- a/flashrom.8
+++ b/flashrom.8
@@ -5,7 +5,7 @@
.B flashrom \fR[\fB\-n\fR] [\fB\-V\fR] [\fB\-f\fR] [\fB\-h\fR|\fB\-R\fR|\
\fB\-L\fR|\fB\-z\fR|\fB\-E\fR|\fB\-r\fR <file>|\fB\-w\fR <file>|\
\fB\-v\fR <file>]
- [\fB\-c\fR <chipname>] [\fB\-m\fR [<vendor>:]<board>] \
+ [\fB\-c\fR <chipname>] \
[\fB\-l\fR <file>]
[\fB\-i\fR <image>] [\fB\-p\fR <programmername>[:<parameters>]]
[\fB-o\fR <logfile>]
@@ -89,19 +89,6 @@
without the vendor name as parameter. Please note that the chip name is
case sensitive.
.TP
-.B "\-m, \-\-mainboard" [<vendor>:]<board>
-Override mainboard settings.
-.sp
-flashrom reads the coreboot table to determine the current mainboard. If no
-coreboot table could be read or if you want to override these values, you can
-specify \-m, e.g.:
-.sp
-.B " flashrom \-\-mainboard AGAMI:ARUMA \-w agami_aruma.rom"
-.sp
-See the 'Known boards' or 'Known laptops' section in the output
-of 'flashrom \-L' for a list of boards which require the specification of
-the board name, if no coreboot table is found.
-.TP
.B "\-f, \-\-force"
Force one or more of the following actions:
.sp
@@ -253,10 +240,15 @@
running coreboot, the mainboard type is determined from the coreboot table.
Otherwise, the mainboard is detected by examining the onboard PCI devices
and possibly DMI info. If PCI and DMI do not contain information to uniquely
-identify the mainboard (which is the exception), it might be necessary to
-specify the mainboard using the
-.B \-m
-switch (see above).
+identify the mainboard (which is the exception), or if you want to override
+the detected mainboard model, you can specify the mainboard using the
+.sp
+.B " flashrom \-p internal:mainboard=[<vendor>:]<board>"
+syntax.
+.sp
+See the 'Known boards' or 'Known laptops' section in the output
+of 'flashrom \-L' for a list of boards which require the specification of
+the board name, if no coreboot table is found.
.sp
Some of these board-specific flash enabling functions (called
.BR "board enables" )
diff --git a/internal.c b/internal.c
index 8b6daa2..aaa3a70 100644
--- a/internal.c
+++ b/internal.c
@@ -266,6 +266,16 @@
}
free(arg);
+ arg = extract_programmer_param("mainboard");
+ if (arg && strlen(arg)) {
+ lb_vendor_dev_from_string(arg);
+ } else if (arg && !strlen(arg)) {
+ msg_perr("Missing argument for mainboard.\n");
+ free(arg);
+ return 1;
+ }
+ free(arg);
+
arg = extract_programmer_param("bus");
if (arg) {
if (!strcasecmp(arg,"parallel")) {
diff --git a/layout.c b/layout.c
index 89b56b8..8a430a2 100644
--- a/layout.c
+++ b/layout.c
@@ -114,16 +114,16 @@
/*
* If lb_vendor is not set, the coreboot table was
- * not found. Nor was -m VENDOR:PART specified.
+ * not found. Nor was -p internal:mainboard=VENDOR:PART specified.
*/
if (!lb_vendor || !lb_part) {
- msg_pdbg("Note: If the following flash access fails, "
- "try -m <vendor>:<mainboard>.\n");
+ msg_pdbg("Note: If the following flash access fails, try"
+ "-p internal:mainboard= <vendor>:<mainboard>.\n");
return 0;
}
/* These comparisons are case insensitive to make things
- * a little less user^Werror prone.
+ * a little less user error prone.
*/
if (!strcasecmp(mainboard_vendor, lb_vendor) &&
!strcasecmp(mainboard_part, lb_part)) {
@@ -134,14 +134,17 @@
"seem to fit to this machine - forcing it.\n");
} else {
msg_pinfo("ERROR: Your firmware image (%s:%s) does not "
- "appear to\n be correct for the detected "
- "mainboard (%s:%s)\n\nOverride with -p internal:"
- "boardmismatch=force if you are absolutely sure "
- "that\nyou are using a correct "
- "image for this mainboard or override\nthe detected "
- "values with --mainboard <vendor>:<mainboard>.\n\n",
- mainboard_vendor, mainboard_part, lb_vendor,
- lb_part);
+ "appear to\n"
+ " be correct for the detected "
+ "mainboard (%s:%s)\n\n"
+ "Override with -p internal:boardmismatch="
+ "force to ignore the board name in the\n"
+ "firmware image or override the detected "
+ "mainboard with\n"
+ "-p internal:mainboard=<vendor>:<mainboard>."
+ "\n\n",
+ mainboard_vendor, mainboard_part, lb_vendor,
+ lb_part);
exit(1);
}
}
diff --git a/print.c b/print.c
index ae57eaa..f5b0f58 100644
--- a/print.c
+++ b/print.c
@@ -397,7 +397,10 @@
for (i = strlen("Board"); i < maxboardlen; i++)
msg_ginfo(" ");
- msg_ginfo("Status Required option\n\n");
+ msg_ginfo("Status Required value for\n");
+ for (i = 0; i < maxvendorlen + maxboardlen + strlen("Status "); i++)
+ msg_ginfo(" ");
+ msg_ginfo("-p internal:mainboard=\n");
for (b = boards; b->vendor != NULL; b++) {
msg_ginfo("%s", b->vendor);
@@ -415,7 +418,7 @@
if (e->lb_vendor == NULL)
msg_ginfo("(autodetected)");
else
- msg_ginfo("-m %s:%s", e->lb_vendor,
+ msg_ginfo("%s:%s", e->lb_vendor,
e->lb_part);
}
msg_ginfo("\n");
diff --git a/print_wiki.c b/print_wiki.c
index 57a27d8..78e58b3 100644
--- a/print_wiki.c
+++ b/print_wiki.c
@@ -167,7 +167,7 @@
boards[i].url ? boards[i].url : "",
boards[i].name,
boards[i].url ? "]" : "",
- b[k].lb_vendor ? "-m " : "—",
+ b[k].lb_vendor ? "-p internal:mainboards=" : "—",
b[k].lb_vendor ? b[k].lb_vendor : "",
b[k].lb_vendor ? ":" : "",
b[k].lb_vendor ? b[k].lb_part : "",
diff --git a/programmer.h b/programmer.h
index 4535247..191fb1e 100644
--- a/programmer.h
+++ b/programmer.h
@@ -290,7 +290,7 @@
void cleanup_cpu_msr(void);
/* cbtable.c */
-void lb_vendor_dev_from_string(char *boardstring);
+void lb_vendor_dev_from_string(const char *boardstring);
int coreboot_init(void);
extern char *lb_part, *lb_vendor;
extern int partvendor_from_cbtable;