summaryrefslogtreecommitdiffstats
path: root/cli_classic.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2021-01-15 09:48:12 +0000
committerEdward O'Callaghan <quasisec@chromium.org>2022-05-25 08:08:13 +0000
commit40892b0c08fbc8029921e91511dd3f91fc956f90 (patch)
tree56b6fccd5c99c00649369fcf097c4555313b753c /cli_classic.c
parentb86ae179adfb4acb4190ef2abe2ee8905c44f26a (diff)
downloadflashrom-40892b0c08fbc8029921e91511dd3f91fc956f90.tar.gz
flashrom-40892b0c08fbc8029921e91511dd3f91fc956f90.tar.bz2
flashrom-40892b0c08fbc8029921e91511dd3f91fc956f90.zip
libflashrom: Return progress state to the library user
Projects using libflashrom like fwupd expect the user to wait for the operation to complete. To avoid the user thinking the process has "hung" or "got stuck" report back the progress complete of the erase, write and read operations. Add a new --progress flag to the CLI to report progress of operations. Include a test for the dummy spi25 device. TEST=./test_build.sh; ./flashrom -p lspcon_i2c_spi:bus=7 -r /dev/null --progress Change-Id: I7197572bb7f19e3bdb2bde855d70a0f50fd3854c Signed-off-by: Richard Hughes <richard@hughsie.com> Signed-off-by: Daniel Campello <campello@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/49643 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
Diffstat (limited to 'cli_classic.c')
-rw-r--r--cli_classic.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/cli_classic.c b/cli_classic.c
index 83ac5383e..212534c94 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -79,6 +79,7 @@ static void cli_classic_usage(const char *name)
#if CONFIG_PRINT_WIKI == 1
" -z | --list-supported-wiki print supported devices in wiki syntax\n"
#endif
+ " --progress show progress percentage on the standard output\n"
" -p | --programmer <name>[:<param>] specify the programmer device. One of\n");
list_programmers_linebreak(4, 80, 0);
printf(".\n\nYou can specify one of -h, -R, -L, "
@@ -472,6 +473,7 @@ int main(int argc, char *argv[])
uint32_t wp_start = 0, wp_len = 0;
int read_it = 0, extract_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;
+ int show_progress = 0;
struct flashrom_layout *layout = NULL;
static const struct programmer_entry *prog = NULL;
enum {
@@ -487,6 +489,7 @@ int main(int argc, char *argv[])
OPTION_WP_ENABLE,
OPTION_WP_DISABLE,
OPTION_WP_LIST,
+ OPTION_PROGRESS,
};
int ret = 0;
@@ -523,6 +526,7 @@ int main(int argc, char *argv[])
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'R'},
{"output", 1, NULL, 'o'},
+ {"progress", 0, NULL, OPTION_PROGRESS},
{NULL, 0, NULL, 0},
};
@@ -763,6 +767,9 @@ int main(int argc, char *argv[])
cli_classic_abort_usage("No log filename specified.\n");
}
break;
+ case OPTION_PROGRESS:
+ show_progress = 1;
+ break;
default:
cli_classic_abort_usage(NULL);
break;
@@ -934,6 +941,13 @@ int main(int argc, char *argv[])
fill_flash = &flashes[0];
+ unsigned int progress_user_data[FLASHROM_PROGRESS_NR];
+ struct flashrom_progress progress_state = {
+ .user_data = progress_user_data
+ };
+ if (show_progress)
+ flashrom_set_progress_callback(fill_flash, &flashrom_progress_cb, &progress_state);
+
print_chip_support_status(fill_flash->chip);
unsigned int limitexceeded = count_max_decode_exceedings(fill_flash);