From 37055cfb165e233a83820fd561b476edf966d2b0 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Fri, 25 Feb 2022 12:48:34 +0800 Subject: futility: updater: write multiple sections in recovery RW update The write_firmware_sections now supports writing multiple sections in one invocation so we can pass all RW sections to it for the recovery update. On Brya, the total execution time may be reduced from 4 mins to 1.5 mins. BUG=b:221137867 TEST=build and run test BRANCH=None Signed-off-by: Hung-Te Lin Change-Id: Ifbc67327a02096e027c1e2025485ebb17645a71d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3490387 Reviewed-by: Edward O'Callaghan --- futility/updater.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/futility/updater.c b/futility/updater.c index 788e0e34..06a696c3 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -1144,6 +1144,15 @@ static enum updater_error_codes update_rw_firmware( struct firmware_image *image_from, struct firmware_image *image_to) { + int sections_start = 0; + static const char * const sections[] = { + FMAP_RW_LEGACY, + FMAP_RW_SECTION_A, + FMAP_RW_SECTION_B, + FMAP_RW_SHARED, + NULL, + }; + STATUS("RW UPDATE: Updating RW sections (%s, %s, %s, and %s).\n", FMAP_RW_SECTION_A, FMAP_RW_SECTION_B, FMAP_RW_SHARED, FMAP_RW_LEGACY); @@ -1153,14 +1162,18 @@ static enum updater_error_codes update_rw_firmware( return UPDATE_ERR_ROOT_KEY; if (check_compatible_tpm_keys(cfg, image_to)) return UPDATE_ERR_TPM_ROLLBACK; + /* - * TODO(hungte) Speed up by flashing multiple sections in one - * command, or provide diff file. + * We may also consider only updating legacy if legacy_needs_update() + * returns true. However, given this is for 'recovery', it is probably + * better to restore everything to the default states. We may revisit + * this if a new scenario is found. */ - if (write_firmware(cfg, image_to, FMAP_RW_SECTION_A) || - write_firmware(cfg, image_to, FMAP_RW_SECTION_B) || - write_firmware(cfg, image_to, FMAP_RW_SHARED) || - write_optional_firmware(cfg, image_to, FMAP_RW_LEGACY, 0, 1)) + if (!firmware_section_exists(image_from, sections[sections_start]) || + !firmware_section_exists(image_to, sections[sections_start])) + sections_start++; + + if (write_firmware_sections(cfg, image_to, §ions[sections_start])) return UPDATE_ERR_WRITE_FIRMWARE; return UPDATE_ERR_DONE; -- cgit v1.2.1