summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/2lib/2ec_sync.c19
-rw-r--r--firmware/2lib/include/2struct.h4
2 files changed, 22 insertions, 1 deletions
diff --git a/firmware/2lib/2ec_sync.c b/firmware/2lib/2ec_sync.c
index 0bc58a85..979c0a5d 100644
--- a/firmware/2lib/2ec_sync.c
+++ b/firmware/2lib/2ec_sync.c
@@ -479,8 +479,18 @@ static vb2_error_t ec_sync_phase3(struct vb2_context *ctx)
vb2_error_t vb2api_ec_sync(struct vb2_context *ctx)
{
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
vb2_error_t rv;
+ /*
+ * If the flags indicate that the EC has already gone through
+ * software sync this boot, then don't do it again.
+ */
+ if (sd->flags & VB2_SD_STATUS_EC_SYNC_COMPLETE) {
+ VB2_DEBUG("EC software sync already performed this boot, skipping\n");
+ return VB2_SUCCESS;
+ }
+
/* Phase 1; this determines if we need an update */
vb2_error_t phase1_rv = ec_sync_phase1(ctx);
int need_wait_screen = ec_will_update_slowly(ctx);
@@ -500,5 +510,12 @@ vb2_error_t vb2api_ec_sync(struct vb2_context *ctx)
return rv;
/* Phase 3; Completes sync and handles battery cutoff */
- return ec_sync_phase3(ctx);
+ rv = ec_sync_phase3(ctx);
+ if (rv)
+ return rv;
+
+ /* Establish that EC software sync is complete and successful */
+ sd->flags |= VB2_SD_STATUS_EC_SYNC_COMPLETE;
+
+ return VB2_SUCCESS;
}
diff --git a/firmware/2lib/include/2struct.h b/firmware/2lib/include/2struct.h
index a9fb000c..a992d7ab 100644
--- a/firmware/2lib/include/2struct.h
+++ b/firmware/2lib/include/2struct.h
@@ -78,6 +78,10 @@ enum vb2_shared_data_status {
/* FWMP secure data initialized */
VB2_SD_STATUS_SECDATA_FWMP_INIT = (1 << 5),
+
+ /* EC Sync completed successfully */
+ VB2_SD_STATUS_EC_SYNC_COMPLETE = (1 << 6),
+
};
/* "V2SD" = vb2_shared_data.magic */