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>
This commit is contained in:
Randall Spangler
2012-07-25 15:52:51 -07:00
committed by Gerrit
parent 241de33bab
commit 09d0c2e487

View File

@@ -347,6 +347,18 @@ VbError_t VbBootRecovery(VbCommonParams* cparams, LoadKernelParams* p) {
return VBERROR_SUCCESS; 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) { VbError_t VbEcSoftwareSync(VbSharedDataHeader *shared) {
int in_rw = 0; int in_rw = 0;
@@ -394,12 +406,9 @@ VbError_t VbEcSoftwareSync(VbSharedDataHeader *shared) {
} }
/* Protect the RW flash and stay in EC-RO */ /* Protect the RW flash and stay in EC-RO */
rv = VbExEcProtectRW(); rv = EcProtectRW();
if (rv != VBERROR_SUCCESS) { if (rv != VBERROR_SUCCESS)
VBDEBUG(("VbEcSoftwareSync() - VbExEcProtectRW() returned %d\n", rv)); return rv;
VbSetRecoveryRequest(VBNV_RECOVERY_EC_SOFTWARE_SYNC);
return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
}
rv = VbExEcStayInRO(); rv = VbExEcStayInRO();
if (rv != VBERROR_SUCCESS) { if (rv != VBERROR_SUCCESS) {
@@ -485,7 +494,13 @@ VbError_t VbEcSoftwareSync(VbSharedDataHeader *shared) {
*/ */
rv = VbExEcUpdateRW(expected, expected_size); 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)); VBDEBUG(("VbEcSoftwareSync() - VbExEcUpdateRW() returned %d\n", rv));
VbSetRecoveryRequest(VBNV_RECOVERY_EC_SOFTWARE_SYNC); VbSetRecoveryRequest(VBNV_RECOVERY_EC_SOFTWARE_SYNC);
return VBERROR_EC_REBOOT_TO_RO_REQUIRED; return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
@@ -498,12 +513,9 @@ VbError_t VbEcSoftwareSync(VbSharedDataHeader *shared) {
} }
/* Protect EC-RW flash */ /* Protect EC-RW flash */
rv = VbExEcProtectRW(); rv = EcProtectRW();
if (rv != VBERROR_SUCCESS) { if (rv != VBERROR_SUCCESS)
VBDEBUG(("VbEcSoftwareSync() - VbExEcProtectRW() returned %d\n", rv)); return rv;
VbSetRecoveryRequest(VBNV_RECOVERY_EC_SOFTWARE_SYNC);
return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
}
/* Tell EC to jump to its RW code */ /* Tell EC to jump to its RW code */
VBDEBUG(("VbEcSoftwareSync() jumping to EC-RW\n")); VBDEBUG(("VbEcSoftwareSync() jumping to EC-RW\n"));