summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-25 15:52:51 -0700
committerGerrit <chrome-bot@google.com>2012-07-25 18:07:20 -0700
commit09d0c2e487653ada95768abe5cb9bfbf8dbfe6bb (patch)
treef4cfd9415e60b34e2ba6d91ede99cc3b95e4ad3e
parent241de33babbb13eec2ca2d1f7bc86964f7b3258f (diff)
downloadvboot-09d0c2e487653ada95768abe5cb9bfbf8dbfe6bb.tar.gz
Handle reboots required to protect/unprotect RW firmware
Necessary for updating snow EC BUG=chrome-os-partner:11087 TEST=force an EC update by loading a slightly old EC and then a new BIOS Change-Id: Id00257f8a67c08077a5b396cf120a056a7601671 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28436 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--firmware/lib/vboot_api_kernel.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index c87a05af..e38a949c 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -347,6 +347,18 @@ VbError_t VbBootRecovery(VbCommonParams* cparams, LoadKernelParams* p) {
return VBERROR_SUCCESS;
}
+/* Wrapper around VbExEcProtectRW() which sets recovery reason on error */
+static VbError_t EcProtectRW(void) {
+ int rv = VbExEcProtectRW();
+
+ if (rv == VBERROR_EC_REBOOT_TO_RO_REQUIRED) {
+ VBDEBUG(("VbExEcProtectRW() needs reboot\n"));
+ } else if (rv != VBERROR_SUCCESS) {
+ VBDEBUG(("VbExEcProtectRW() returned %d\n", rv));
+ VbSetRecoveryRequest(VBNV_RECOVERY_EC_SOFTWARE_SYNC);
+ }
+ return rv;
+}
VbError_t VbEcSoftwareSync(VbSharedDataHeader *shared) {
int in_rw = 0;
@@ -394,12 +406,9 @@ VbError_t VbEcSoftwareSync(VbSharedDataHeader *shared) {
}
/* Protect the RW flash and stay in EC-RO */
- rv = VbExEcProtectRW();
- if (rv != VBERROR_SUCCESS) {
- VBDEBUG(("VbEcSoftwareSync() - VbExEcProtectRW() returned %d\n", rv));
- VbSetRecoveryRequest(VBNV_RECOVERY_EC_SOFTWARE_SYNC);
- return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
- }
+ rv = EcProtectRW();
+ if (rv != VBERROR_SUCCESS)
+ return rv;
rv = VbExEcStayInRO();
if (rv != VBERROR_SUCCESS) {
@@ -485,7 +494,13 @@ VbError_t VbEcSoftwareSync(VbSharedDataHeader *shared) {
*/
rv = VbExEcUpdateRW(expected, expected_size);
- if (rv != VBERROR_SUCCESS) {
+ if (rv == VBERROR_EC_REBOOT_TO_RO_REQUIRED) {
+ /* Reboot required. May need to unprotect RW before updating,
+ * or may need to reboot after RW updated. Either way, it's not
+ * an error requiring recovery mode. */
+ VBDEBUG(("VbEcSoftwareSync() - VbExEcUpdateRW() needs reboot\n"));
+ return rv;
+ } else if (rv != VBERROR_SUCCESS) {
VBDEBUG(("VbEcSoftwareSync() - VbExEcUpdateRW() returned %d\n", rv));
VbSetRecoveryRequest(VBNV_RECOVERY_EC_SOFTWARE_SYNC);
return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
@@ -498,12 +513,9 @@ VbError_t VbEcSoftwareSync(VbSharedDataHeader *shared) {
}
/* Protect EC-RW flash */
- rv = VbExEcProtectRW();
- if (rv != VBERROR_SUCCESS) {
- VBDEBUG(("VbEcSoftwareSync() - VbExEcProtectRW() returned %d\n", rv));
- VbSetRecoveryRequest(VBNV_RECOVERY_EC_SOFTWARE_SYNC);
- return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
- }
+ rv = EcProtectRW();
+ if (rv != VBERROR_SUCCESS)
+ return rv;
/* Tell EC to jump to its RW code */
VBDEBUG(("VbEcSoftwareSync() jumping to EC-RW\n"));