mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
cli_classic: Add convenient '--flash-name' cli opt
We have this in the ChromiumOS fork of flashrom which we rely on to obtain the current flash chip in use. This ports it for upstream consumption. V.2: Constrain number_of_operations to one as per Nico's comment. V.3: Move two goto's outside inner if-else block. V.4: Add missing --help line. V.5: Add man page entry. v.6: Use printf() directly. Change-Id: I23d574a2f8eaf809a5c0524490db9e3a560ede56 Signed-off-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/35591 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
ca598dabc3
commit
0cd11d8919
@ -51,6 +51,7 @@ static void cli_classic_usage(const char *name)
|
||||
" -n | --noverify don't auto-verify\n"
|
||||
" -N | --noverify-all verify included regions only (cf. -i)\n"
|
||||
" -l | --layout <layoutfile> read ROM layout from <layoutfile>\n"
|
||||
" --flash-name read out the detected flash name\n"
|
||||
" --fmap read ROM layout from fmap embedded in ROM\n"
|
||||
" --fmap-file <fmapfile> read ROM layout from fmap in <fmapfile>\n"
|
||||
" --ifd read layout from an Intel Firmware Descriptor\n"
|
||||
@ -101,6 +102,7 @@ int main(int argc, char *argv[])
|
||||
#if CONFIG_PRINT_WIKI == 1
|
||||
int list_supported_wiki = 0;
|
||||
#endif
|
||||
int flash_name = 0;
|
||||
int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
|
||||
int dont_verify_it = 0, dont_verify_all = 0, list_supported = 0, operation_specified = 0;
|
||||
struct flashrom_layout *layout = NULL;
|
||||
@ -110,6 +112,7 @@ int main(int argc, char *argv[])
|
||||
OPTION_FMAP,
|
||||
OPTION_FMAP_FILE,
|
||||
OPTION_FLASH_CONTENTS,
|
||||
OPTION_FLASH_NAME,
|
||||
};
|
||||
int ret = 0;
|
||||
|
||||
@ -130,6 +133,7 @@ int main(int argc, char *argv[])
|
||||
{"fmap-file", 1, NULL, OPTION_FMAP_FILE},
|
||||
{"image", 1, NULL, 'i'},
|
||||
{"flash-contents", 1, NULL, OPTION_FLASH_CONTENTS},
|
||||
{"flash-name", 0, NULL, OPTION_FLASH_NAME},
|
||||
{"list-supported", 0, NULL, 'L'},
|
||||
{"list-supported-wiki", 0, NULL, 'z'},
|
||||
{"programmer", 1, NULL, 'p'},
|
||||
@ -296,6 +300,14 @@ int main(int argc, char *argv[])
|
||||
case OPTION_FLASH_CONTENTS:
|
||||
referencefile = strdup(optarg);
|
||||
break;
|
||||
case OPTION_FLASH_NAME:
|
||||
if (++operation_specified > 1) {
|
||||
fprintf(stderr, "More than one operation "
|
||||
"specified. Aborting.\n");
|
||||
cli_classic_abort_usage();
|
||||
}
|
||||
flash_name = 1;
|
||||
break;
|
||||
case 'L':
|
||||
if (++operation_specified > 1) {
|
||||
fprintf(stderr, "More than one operation "
|
||||
@ -602,11 +614,22 @@ int main(int argc, char *argv[])
|
||||
goto out_shutdown;
|
||||
}
|
||||
|
||||
if (!(read_it | write_it | verify_it | erase_it)) {
|
||||
if (!(read_it | write_it | verify_it | erase_it | flash_name)) {
|
||||
msg_ginfo("No operations were specified.\n");
|
||||
goto out_shutdown;
|
||||
}
|
||||
|
||||
if (flash_name) {
|
||||
if (fill_flash->chip->vendor && fill_flash->chip->name) {
|
||||
printf("vendor=\"%s\" name=\"%s\"\n",
|
||||
fill_flash->chip->vendor,
|
||||
fill_flash->chip->name);
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
goto out_shutdown;
|
||||
}
|
||||
|
||||
if (layoutfile) {
|
||||
layout = get_global_layout();
|
||||
} else if (ifd && (flashrom_layout_read_from_ifd(&layout, fill_flash, NULL, 0) ||
|
||||
|
@ -44,10 +44,12 @@
|
||||
.SH NAME
|
||||
flashrom \- detect, read, write, verify and erase flash chips
|
||||
.SH SYNOPSIS
|
||||
.B flashrom \fR[\fB\-h\fR|\fB\-R\fR|\fB\-L\fR|\fB\-z\fR|\fB\-p\fR <programmername>[:<parameters>]
|
||||
[\fB\-E\fR|\fB\-r\fR <file>|\fB\-w\fR <file>|\fB\-v\fR <file>] [\fB\-c\fR <chipname>]
|
||||
[(\fB\-l\fR <file>|\fB\-\-ifd|\fB \-\-fmap\fR|\fB\-\-fmap-file\fR <file>) [\fB\-i\fR <image>]]
|
||||
[\fB\-n\fR] [\fB\-N\fR] [\fB\-f\fR]]
|
||||
.B flashrom \fR[\fB\-h\fR|\fB\-R\fR|\fB\-L\fR|\fB\-z\fR|
|
||||
\fB\-p\fR <programmername>[:<parameters>] [\fB\-c\fR <chipname>]
|
||||
(\fB\-\-flash\-name\fR|
|
||||
[\fB\-E\fR|\fB\-r\fR <file>|\fB\-w\fR <file>|\fB\-v\fR <file>]
|
||||
[(\fB\-l\fR <file>|\fB\-\-ifd|\fB \-\-fmap\fR|\fB\-\-fmap-file\fR <file>) [\fB\-i\fR <image>]]
|
||||
[\fB\-n\fR] [\fB\-N\fR] [\fB\-f\fR])]
|
||||
[\fB\-V\fR[\fBV\fR[\fBV\fR]]] [\fB-o\fR <logfile>]
|
||||
.SH DESCRIPTION
|
||||
.B flashrom
|
||||
@ -242,6 +244,9 @@ Only flash region/image
|
||||
.B <imagename>
|
||||
from flash layout.
|
||||
.TP
|
||||
.B "\-\-flash\-name"
|
||||
Prints out the detected flash chips name.
|
||||
.TP
|
||||
.B "\-L, \-\-list\-supported"
|
||||
List the flash chips, chipsets, mainboards, and external programmers
|
||||
(including PCI, USB, parallel port, and serial port based devices)
|
||||
@ -1335,6 +1340,8 @@ David Hendricks
|
||||
.br
|
||||
Dominik Geyer
|
||||
.br
|
||||
Edward O'Callaghan
|
||||
.br
|
||||
Eric Biederman
|
||||
.br
|
||||
Giampiero Giancipoli
|
||||
|
Loading…
x
Reference in New Issue
Block a user