Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
cli_classic: Add convenient '--get-size' 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.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c 1 file changed, 12 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/1
diff --git a/cli_classic.c b/cli_classic.c index 4604043..52cea52 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -101,7 +101,7 @@ #if CONFIG_PRINT_WIKI == 1 int list_supported_wiki = 0; #endif - int flash_name = 0; + int flash_name = 0, get_size = 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; @@ -112,6 +112,7 @@ OPTION_FMAP_FILE, OPTION_FLASH_CONTENTS, OPTION_FLASH_NAME, + OPTION_GET_SIZE, }; int ret = 0;
@@ -133,6 +134,7 @@ {"image", 1, NULL, 'i'}, {"flash-contents", 1, NULL, OPTION_FLASH_CONTENTS}, {"flash-name", 0, NULL, OPTION_FLASH_NAME}, + {"get-size", 0, NULL, OPTION_GET_SIZE}, {"list-supported", 0, NULL, 'L'}, {"list-supported-wiki", 0, NULL, 'z'}, {"programmer", 1, NULL, 'p'}, @@ -302,6 +304,9 @@ case OPTION_FLASH_NAME: flash_name = 1; break; + case OPTION_GET_SIZE: + get_size = 1; + break; case 'L': if (++operation_specified > 1) { fprintf(stderr, "More than one operation " @@ -608,7 +613,7 @@ goto out_shutdown; }
- if (!(read_it | write_it | verify_it | erase_it | flash_name)) { + if (!(read_it | write_it | verify_it | erase_it | flash_name | get_size)) { msg_ginfo("No operations were specified.\n"); goto out_shutdown; } @@ -625,6 +630,11 @@ } }
+ if (get_size) { + msg_ginfo("%d\n", fill_flash->chip->total_size * 1024); + goto out_shutdown; + } + if (layoutfile) { layout = get_global_layout(); } else if (ifd && (flashrom_layout_read_from_ifd(&layout, fill_flash, NULL, 0) ||
Hello Alan Green, build bot (Jenkins), Nico Huber, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/35592
to look at the new patch set (#2).
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
cli_classic: Add convenient '--get-size' 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: Contrain number_of_operations to one as per Nico's comment.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c 1 file changed, 17 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/2
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 2: Code-Review+1
(1 comment)
https://review.coreboot.org/c/flashrom/+/35592/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/flashrom/+/35592/2//COMMIT_MSG@13 PS2, Line 13: Contrain nit: Constrain
Hello build bot (Jenkins), Alan Green, Nico Huber, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/35592
to look at the new patch set (#3).
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
cli_classic: Add convenient '--get-size' 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.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c 1 file changed, 17 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/3
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 3:
Patch Set 2: Code-Review+1
(1 comment)
Done.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 3: Code-Review+1
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 4: Code-Review+1
Stefan Reinauer has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/flashrom/+/35592/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/flashrom/+/35592/4//COMMIT_MSG@9 PS4, Line 9: We have this - What does it do? - How is it used? - What is it used for?
Hello Angel Pons, build bot (Jenkins), Alan Green, Nico Huber, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/35592
to look at the new patch set (#5).
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
cli_classic: Add convenient '--get-size' 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.
This option prints the detected flashchips size such as in the case of: `flashrom -p internal --get-size`. This is useful to validate we are using the right flash chip on a multi-chip board for example or to correctly partition a chip up to meet the detected size it provides.
V.2: Constrain number_of_operations to one as per Nico's comment.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c 1 file changed, 17 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/5
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 5:
(1 comment)
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/flashrom/+/35592/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/flashrom/+/35592/4//COMMIT_MSG@9 PS4, Line 9: We have this
- What does it do? […]
Done
Stefan Reinauer has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 5: Code-Review+2
Looks good to me if we agree that we want to merge this.
David Hendricks has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 5: Code-Review+1
(2 comments)
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c File cli_classic.c:
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c@137 PS5, Line 137: {"get-size", 0, NULL, OPTION_GET_SIZE}, Bike-shedding: Maybe this should be named "flash-size"? That will go better with "flash-name", I think. Up to you.
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c@315 PS5, Line 315: "specified. Aborting.\n"); Should fit on one line?
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--get-size' cli opt ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c File cli_classic.c:
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c@137 PS5, Line 137: {"get-size", 0, NULL, OPTION_GET_SIZE},
Bike-shedding: Maybe this should be named "flash-size"? That will go better with "flash-name", I thi […]
This would create a lot of frustration dealing with retooling chromiumos to handle two flashroms with different argument conventions for essentially no gain beyond the subjective. --help gives the user the option so it's not a huge deal.
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c@315 PS5, Line 315: "specified. Aborting.\n");
Should fit on one line?
Maybe but that is a style change that touches the convention of other options that do the same so would just introduce inconsistencies and/or scope run-away for this patch. I rather keep the patch to the point.
Hello Angel Pons, David Hendricks, Stefan Reinauer, build bot (Jenkins), Alan Green, Nico Huber, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/35592
to look at the new patch set (#6).
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
cli_classic: Add convenient '--{flash,get}-size' 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: Rename '--get-size' to '--flash-size' however keep old arg as 'undocumented' for back-compat.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c 1 file changed, 18 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/6
David Hendricks has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
Patch Set 6: Code-Review+1
(1 comment)
For upstream, you should probably also update cli_classic_usage() and the man page. For this patch I think adding --flash-size should be sufficient, but let's see what others have to say about this approach.
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c File cli_classic.c:
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c@137 PS5, Line 137: {"get-size", 0, NULL, OPTION_GET_SIZE},
This would create a lot of frustration dealing with retooling chromiumos to handle two flashroms wit […]
Does --help show the option? I don't see any changes to cli_classic_usage() in this patch (or the previous one).
Hello Angel Pons, David Hendricks, Stefan Reinauer, build bot (Jenkins), Alan Green, Nico Huber, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/35592
to look at the new patch set (#7).
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
cli_classic: Add convenient '--{flash,get}-size' 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: Rename '--get-size' to '--flash-size' however keep old arg as 'undocumented' for back-compat. V.4: Add missing --help line.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c 1 file changed, 19 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/7
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
Patch Set 7:
(1 comment)
Patch Set 6: Code-Review+1
(1 comment)
For upstream, you should probably also update cli_classic_usage() and the man page. For this patch I think adding --flash-size should be sufficient, but let's see what others have to say about this approach.
Done.
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c File cli_classic.c:
https://review.coreboot.org/c/flashrom/+/35592/5/cli_classic.c@137 PS5, Line 137: {"get-size", 0, NULL, OPTION_GET_SIZE},
Does --help show the option? I don't see any changes to cli_classic_usage() in this patch (or the pr […]
Done
Hello Angel Pons, David Hendricks, Stefan Reinauer, build bot (Jenkins), Alan Green, Nico Huber, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/35592
to look at the new patch set (#8).
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
cli_classic: Add convenient '--{flash,get}-size' 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: Rename '--get-size' to '--flash-size' however keep old arg as 'undocumented' for back-compat. V.4: Add missing --help line. V.5: Add man page entry.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c M flashrom.8.tmpl 2 files changed, 23 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/8
Hello Angel Pons, David Hendricks, Stefan Reinauer, build bot (Jenkins), Alan Green, Nico Huber, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/35592
to look at the new patch set (#9).
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
cli_classic: Add convenient '--{flash,get}-size' 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: Rename '--get-size' to '--flash-size' however keep old arg as 'undocumented' for back-compat. V.4: Add missing --help line. V.5: Add man page entry.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c M flashrom.8.tmpl 2 files changed, 23 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/9
Hello Angel Pons, David Hendricks, Stefan Reinauer, build bot (Jenkins), Alan Green, Nico Huber, Patrick Georgi,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/35592
to look at the new patch set (#10).
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
cli_classic: Add convenient '--{flash,get}-size' 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: Rename '--get-size' to '--flash-size' however keep old arg as 'undocumented' for back-compat. V.4: Add missing --help line. V.5: Add man page entry. V.6: Use printf() directly.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c M flashrom.8.tmpl 2 files changed, 23 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/10
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
Patch Set 10: Code-Review+2
(1 comment)
https://review.coreboot.org/c/flashrom/+/35592/10/cli_classic.c File cli_classic.c:
https://review.coreboot.org/c/flashrom/+/35592/10/cli_classic.c@629 PS10, Line 629: if (!(read_it | write_it | verify_it | erase_it | flash_name | flash_size)) { NB. I'm getting the feeling, we should just check `operation_specified` ^^
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
Patch Set 10:
(1 comment)
https://review.coreboot.org/c/flashrom/+/35592/10/cli_classic.c File cli_classic.c:
https://review.coreboot.org/c/flashrom/+/35592/10/cli_classic.c@629 PS10, Line 629: if (!(read_it | write_it | verify_it | erase_it | flash_name | flash_size)) {
NB. […]
Let me think about these cli clean ups in further follow ups. I think there is a couple more things to be done around the cli in general to make it more robust and maintainable.
Edward O'Callaghan has submitted this change. ( https://review.coreboot.org/c/flashrom/+/35592 )
Change subject: cli_classic: Add convenient '--{flash,get}-size' cli opt ......................................................................
cli_classic: Add convenient '--{flash,get}-size' 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: Rename '--get-size' to '--flash-size' however keep old arg as 'undocumented' for back-compat. V.4: Add missing --help line. V.5: Add man page entry. V.6: Use printf() directly.
Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6 Signed-off-by: Edward O'Callaghan quasisec@chromium.org Reviewed-on: https://review.coreboot.org/c/flashrom/+/35592 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Nico Huber nico.h@gmx.de --- M cli_classic.c M flashrom.8.tmpl 2 files changed, 23 insertions(+), 3 deletions(-)
Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
diff --git a/cli_classic.c b/cli_classic.c index 5dff904..d23298e 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -52,6 +52,7 @@ " -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" + " --flash-size read out the detected flash size\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" @@ -102,7 +103,7 @@ #if CONFIG_PRINT_WIKI == 1 int list_supported_wiki = 0; #endif - int flash_name = 0; + int flash_name = 0, flash_size = 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; @@ -113,6 +114,7 @@ OPTION_FMAP_FILE, OPTION_FLASH_CONTENTS, OPTION_FLASH_NAME, + OPTION_FLASH_SIZE, }; int ret = 0;
@@ -134,6 +136,8 @@ {"image", 1, NULL, 'i'}, {"flash-contents", 1, NULL, OPTION_FLASH_CONTENTS}, {"flash-name", 0, NULL, OPTION_FLASH_NAME}, + {"flash-size", 0, NULL, OPTION_FLASH_SIZE}, + {"get-size", 0, NULL, OPTION_FLASH_SIZE}, // (deprecated): back compatibility. {"list-supported", 0, NULL, 'L'}, {"list-supported-wiki", 0, NULL, 'z'}, {"programmer", 1, NULL, 'p'}, @@ -308,6 +312,14 @@ } flash_name = 1; break; + case OPTION_FLASH_SIZE: + if (++operation_specified > 1) { + fprintf(stderr, "More than one operation " + "specified. Aborting.\n"); + cli_classic_abort_usage(); + } + flash_size = 1; + break; case 'L': if (++operation_specified > 1) { fprintf(stderr, "More than one operation " @@ -614,7 +626,7 @@ goto out_shutdown; }
- if (!(read_it | write_it | verify_it | erase_it | flash_name)) { + if (!(read_it | write_it | verify_it | erase_it | flash_name | flash_size)) { msg_ginfo("No operations were specified.\n"); goto out_shutdown; } @@ -630,6 +642,11 @@ goto out_shutdown; }
+ if (flash_size) { + printf("%d\n", fill_flash->chip->total_size * 1024); + goto out_shutdown; + } + if (layoutfile) { layout = get_global_layout(); } else if (ifd && (flashrom_layout_read_from_ifd(&layout, fill_flash, NULL, 0) || diff --git a/flashrom.8.tmpl b/flashrom.8.tmpl index 7002c72..eb7fdec 100644 --- a/flashrom.8.tmpl +++ b/flashrom.8.tmpl @@ -46,7 +46,7 @@ .SH SYNOPSIS .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--flash-name\fR|\fB--flash-size\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])] @@ -247,6 +247,9 @@ .B "--flash-name" Prints out the detected flash chips name. .TP +.B "--flash-size" +Prints out the detected flash chips size. +.TP .B "-L, --list-supported" List the flash chips, chipsets, mainboards, and external programmers (including PCI, USB, parallel port, and serial port based devices)