summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2022-02-25 12:48:34 +0800
committerCommit Bot <commit-bot@chromium.org>2022-03-01 02:41:44 +0000
commit37055cfb165e233a83820fd561b476edf966d2b0 (patch)
tree22dd0942e2590c2ea8b09bd8606689b6e5dc495c
parented3ae2dc822fc6607c0a669ab259424659c826f4 (diff)
downloadvboot-37055cfb165e233a83820fd561b476edf966d2b0.tar.gz
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 <hungte@chromium.org> Change-Id: Ifbc67327a02096e027c1e2025485ebb17645a71d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3490387 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r--futility/updater.c25
1 files 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, &sections[sections_start]))
return UPDATE_ERR_WRITE_FIRMWARE;
return UPDATE_ERR_DONE;