summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-06-11 16:53:07 -0700
committerChromeBot <chrome-bot@google.com>2013-06-12 09:22:32 -0700
commitf2a1dc0a54ec542dd4be7b634483de317c89a2a2 (patch)
treeef2d7fcc9afd482f30db7be0f976cdb77030945e
parent19c996909d8cae46ee3ee6d4319abd9f72ab53e1 (diff)
downloadvboot-factory-skate-4262.459.B.tar.gz
Add GBB flags for disabling software sync and defaulting to legacy bootfactory-spring-4262.Bfactory-skate-4262.459.B
1) GBB flag to skip EC software sync, so EC will be untouched. Needed for EC development. 2) GBB flag to default to booting legacy at end of dev screen timeout. Very handy for booting Ubuntu (or other OS). Also added unit tests for the new flags. BUG=chrome-os-partner:20111 BRANCH=none TEST=make runtests Change-Id: I9da87d87014881a1b1393b0b4a5acb921d080066 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/58270 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--firmware/include/gbb_header.h4
-rw-r--r--firmware/lib/vboot_api_kernel.c21
-rwxr-xr-xscripts/image_signing/set_gbb_flags.sh2
-rw-r--r--tests/vboot_api_kernel2_tests.c14
-rw-r--r--tests/vboot_api_kernel4_tests.c6
5 files changed, 45 insertions, 2 deletions
diff --git a/firmware/include/gbb_header.h b/firmware/include/gbb_header.h
index 43aa3e76..86aa12a6 100644
--- a/firmware/include/gbb_header.h
+++ b/firmware/include/gbb_header.h
@@ -58,6 +58,10 @@
#define GBB_FLAG_FORCE_DEV_BOOT_LEGACY 0x00000080
/* Allow booting using alternate keys for FAFT servo testing */
#define GBB_FLAG_FAFT_KEY_OVERIDE 0x00000100
+/* Disable EC software sync */
+#define GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC 0x00000200
+/* Default to booting legacy OS when dev screen times out */
+#define GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY 0x00000400
#ifdef __cplusplus
extern "C" {
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index a1d83b11..64f600ae 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -177,7 +177,7 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p)
(GoogleBinaryBlockHeader *)cparams->gbb_data;
VbSharedDataHeader *shared =
(VbSharedDataHeader *)cparams->shared_data_blob;
- uint32_t allow_usb = 0, allow_legacy = 0;
+ uint32_t allow_usb = 0, allow_legacy = 0, ctrl_d_pressed = 0;
VbAudioContext *audio = 0;
VBDEBUG(("Entering %s()\n", __func__));
@@ -287,6 +287,7 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p)
/* Ctrl+D = dismiss warning; advance to timeout */
VBDEBUG(("VbBootDeveloper() - "
"user pressed Ctrl+D; skip delay\n"));
+ ctrl_d_pressed = 1;
goto fallout;
break;
case 0x0c:
@@ -370,6 +371,19 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p)
} while(VbAudioLooping(audio));
fallout:
+
+ /* If defaulting to legacy boot, try that unless Ctrl+D was pressed */
+ if ((gbb->flags & GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY) &&
+ !ctrl_d_pressed) {
+ VBDEBUG(("VbBootDeveloper() - defaulting to legacy\n"));
+ VbExLegacy();
+
+ /* If that fails, beep and fall through to fixed disk */
+ VbExBeep(120, 400);
+ VbExSleepMs(120);
+ VbExBeep(120, 400);
+ }
+
/* Timeout or Ctrl+D; attempt loading from fixed disk */
VBDEBUG(("VbBootDeveloper() - trying fixed disk\n"));
VbAudioClose(audio);
@@ -798,6 +812,8 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
{
VbSharedDataHeader *shared =
(VbSharedDataHeader *)cparams->shared_data_blob;
+ GoogleBinaryBlockHeader *gbb =
+ (GoogleBinaryBlockHeader *)cparams->gbb_data;
VbError_t retval = VBERROR_SUCCESS;
LoadKernelParams p;
uint32_t tpm_status = 0;
@@ -816,7 +832,8 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
Memset(kparams->partition_guid, 0, sizeof(kparams->partition_guid));
/* Do EC software sync if necessary */
- if (shared->flags & VBSD_EC_SOFTWARE_SYNC) {
+ if ((shared->flags & VBSD_EC_SOFTWARE_SYNC) &&
+ !(gbb->flags & GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)) {
retval = VbEcSoftwareSync(cparams);
if (retval != VBERROR_SUCCESS)
goto VbSelectAndLoadKernel_exit;
diff --git a/scripts/image_signing/set_gbb_flags.sh b/scripts/image_signing/set_gbb_flags.sh
index ac52432d..5469f1a0 100755
--- a/scripts/image_signing/set_gbb_flags.sh
+++ b/scripts/image_signing/set_gbb_flags.sh
@@ -31,6 +31,8 @@ GBBFLAGS_DESCRIPTION="
GBB_FLAG_ENTER_TRIGGERS_TONORM 0x00000040
GBB_FLAG_FORCE_DEV_BOOT_LEGACY 0x00000080
GBB_FLAG_FAFT_KEY_OVERIDE 0x00000100
+ GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC 0x00000200
+ GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY 0x00000400
To get a developer-friendly device, try 0x11 (short_delay + boot_usb).
For factory-related tests (always DEV), try 0x39.
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index aa3e20dc..c1572c2f 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -220,6 +220,12 @@ static void VbBootDevTest(void)
TEST_EQ(u, 0, " recovery reason");
TEST_EQ(audio_looping_calls_left, 0, " used up audio");
+ /* Proceed to legacy after timeout if GBB flag set */
+ ResetMocks();
+ gbb.flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY;
+ TEST_EQ(VbBootDeveloper(&cparams, &lkp), 1002, "Timeout");
+ TEST_EQ(vbexlegacy_called, 1, " try legacy");
+
/* Up arrow is uninteresting / passed to VbCheckDisplayKey() */
ResetMocks();
mock_keypress[0] = VB_KEY_UP;
@@ -313,6 +319,14 @@ static void VbBootDevTest(void)
VbNvGet(VbApiKernelGetVnc(), VBNV_RECOVERY_REQUEST, &u);
TEST_EQ(u, 0, " recovery reason");
TEST_NEQ(audio_looping_calls_left, 0, " aborts audio");
+ TEST_EQ(vbexlegacy_called, 0, " not legacy");
+
+ /* Ctrl+D doesn't boot legacy even if GBB flag is set */
+ ResetMocks();
+ mock_keypress[0] = 0x04;
+ gbb.flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY;
+ TEST_EQ(VbBootDeveloper(&cparams, &lkp), 1002, "Ctrl+D");
+ TEST_EQ(vbexlegacy_called, 0, " not legacy");
/* Ctrl+L tries legacy boot mode only if enabled */
ResetMocks();
diff --git a/tests/vboot_api_kernel4_tests.c b/tests/vboot_api_kernel4_tests.c
index af8d2b67..81628a44 100644
--- a/tests/vboot_api_kernel4_tests.c
+++ b/tests/vboot_api_kernel4_tests.c
@@ -155,6 +155,12 @@ static void VbSlkTest(void)
ecsync_retval = VBERROR_SIMULATED;
test_slk(0, 0, "EC sync not done");
+ ResetMocks();
+ shared->flags |= VBSD_EC_SOFTWARE_SYNC;
+ gbb.flags |= GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC;
+ ecsync_retval = VBERROR_SIMULATED;
+ test_slk(0, 0, "EC sync disabled by GBB");
+
/* Rollback kernel version */
ResetMocks();
rkr_retval = 123;