diff options
author | Hung-Te Lin <hungte@chromium.org> | 2018-12-12 17:52:54 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-01-03 15:04:14 -0800 |
commit | ed4a54ba7e71dedca0cd6e728a88fbcc2da132ca (patch) | |
tree | 3fccb1db83f6f3e24f4fad05359b0ac60937e21e /futility/updater.c | |
parent | a32c930e8c46424a3bba3c296fd78b3e60f50aeb (diff) | |
download | vboot-ed4a54ba7e71dedca0cd6e728a88fbcc2da132ca.tar.gz |
futility: updater: Add '--fast' for quick developmentstabilize-11554.B
When using 'futility update' with Servo Micro or CCD, the programmer is
pretty slow that every invocation of flashrom would take a very long
time, so re-reading firmware contents when writing (flashrom -w) seems
redundant. For such usage, a '--fast' would be helpful that
- Uses the last read image (image_current) as --diff
- Add --noverify
BUG=None
TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility
BRANCH=None
Change-Id: I1ad57185160a082ea6b5c94b837a4d3ba708b587
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1375495
Diffstat (limited to 'futility/updater.c')
-rw-r--r-- | futility/updater.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/futility/updater.c b/futility/updater.c index ab5cba4b..d16fe38a 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -244,10 +244,10 @@ static int host_get_platform_version() */ static int host_flashrom(enum flashrom_ops op, const char *image_path, const char *programmer, int verbose, - const char *section_name) + const char *section_name, const char *extra) { char *command, *result; - const char *op_cmd, *dash_i = "-i", *postfix = "", *ignore_lock = ""; + const char *op_cmd, *dash_i = "-i", *postfix = ""; int r; switch (verbose) { @@ -297,9 +297,12 @@ static int host_flashrom(enum flashrom_ops op, const char *image_path, return -1; } + if (!extra) + extra = ""; + /* TODO(hungte) In future we should link with flashrom directly. */ ASPRINTF(&command, "flashrom %s %s -p %s %s %s %s %s", op_cmd, - image_path, programmer, dash_i, section_name, ignore_lock, + image_path, programmer, dash_i, section_name, extra, postfix); if (verbose) @@ -329,7 +332,8 @@ static int host_flashrom(enum flashrom_ops op, const char *image_path, /* Helper function to return write protection status via given programmer. */ static int host_get_wp(const char *programmer) { - return host_flashrom(FLASHROM_WP_STATUS, NULL, programmer, 0, NULL); + return host_flashrom(FLASHROM_WP_STATUS, NULL, programmer, 0, NULL, + NULL); } /* Helper function to return host software write protection status. */ @@ -665,7 +669,7 @@ int load_system_firmware(struct updater_config *cfg, return -1; RETURN_ON_FAILURE(host_flashrom( FLASHROM_READ, tmp_file, image->programmer, - cfg->verbosity, NULL)); + cfg->verbosity, NULL, NULL)); return load_firmware_image(image, tmp_file, NULL); } @@ -831,7 +835,10 @@ static int write_firmware(struct updater_config *cfg, const char *section_name) { const char *tmp_file = updater_create_temp_file(cfg); + const char *tmp_diff_file = NULL; const char *programmer = image->programmer; + char *extra = NULL; + int r; if (!tmp_file) return -1; @@ -850,8 +857,20 @@ static int write_firmware(struct updater_config *cfg, ERROR("Cannot write temporary file for output: %s", tmp_file); return -1; } - return host_flashrom(FLASHROM_WRITE, tmp_file, programmer, - cfg->verbosity + 1, section_name); + if (cfg->fast_update && image == &cfg->image && cfg->image_current.data) + { + tmp_diff_file = updater_create_temp_file(cfg); + if (vb2_write_file(tmp_diff_file, cfg->image_current.data, + cfg->image_current.size) != VB2_SUCCESS) { + ERROR("Cannot write temporary file for diff image"); + return -1; + } + ASPRINTF(&extra, "--noverify --diff=%s", tmp_diff_file); + } + r = host_flashrom(FLASHROM_WRITE, tmp_file, programmer, + cfg->verbosity + 1, section_name, extra); + free(extra); + return r; } /* @@ -1897,6 +1916,7 @@ int updater_setup_config(struct updater_config *cfg, /* Setup values that may change output or decision of other argument. */ cfg->verbosity = arg->verbosity; + cfg->fast_update = arg->fast_update; cfg->factory_update = arg->is_factory; if (arg->force_update) cfg->force_update = 1; |