summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-08-24 12:24:49 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-31 11:19:59 -0700
commit75e3c5bb621cf26d7fd774a6603e224ad4120f59 (patch)
treeac7473c8f871a5811ee3521f260cec50b9de8372
parent8d8acddf86a76702438aff5f2f8f57df3ff73dd8 (diff)
downloadvboot-75e3c5bb621cf26d7fd774a6603e224ad4120f59.tar.gz
futility: cmd_update: Add 'mainfw_act' system property
Add the system property 'mainfw_act'. In both vboot1 and vboot2, the try-rw update process will need to figure out what is current (active) firmware slot, which is the "mainfw_act" system property. BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility futility --debug update -i IMAGE --sys_prop 0; futility --debug update -i IMAGE --sys_prop 1; BRANCH=None Change-Id: Ie745726107bff416549ba095a3defdd4cc98d32d Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1183652 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--futility/cmd_update.c36
-rwxr-xr-xtests/futility/test_update.sh2
2 files changed, 36 insertions, 2 deletions
diff --git a/futility/cmd_update.c b/futility/cmd_update.c
index 97d63aad..c319275a 100644
--- a/futility/cmd_update.c
+++ b/futility/cmd_update.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "crossystem.h"
#include "fmap.h"
#include "futility.h"
#include "host_misc.h"
@@ -29,6 +30,10 @@ static const char * const FMAP_RO_FRID = "RO_FRID",
* const FMAP_RW_SHARED = "RW_SHARED",
* const FMAP_RW_LEGACY = "RW_LEGACY";
+/* System environment values. */
+static CONST_STRING FWACT_A = "A",
+ FWACT_B = "B";
+
/* flashrom programmers. */
static const char * const PROG_HOST = "host",
* const PROG_EMULATE = "dummy:emulate",
@@ -40,6 +45,17 @@ enum wp_state {
WP_ENABLED,
};
+enum target_type {
+ TARGET_SELF,
+ TARGET_UPDATE,
+};
+
+enum active_slot {
+ SLOT_UNKNOWN = -1,
+ SLOT_A = 0,
+ SLOT_B,
+};
+
enum flashrom_ops {
FLASHROM_READ,
FLASHROM_WRITE,
@@ -67,8 +83,7 @@ struct system_property {
};
enum system_property_type {
- /* TODO(hungte) Remove SYS_PROP_TEST* when we have more properties. */
- SYS_PROP_TEST1,
+ SYS_PROP_MAINFW_ACT,
SYS_PROP_WP_HW,
SYS_PROP_WP_SW,
SYS_PROP_MAX
@@ -81,6 +96,22 @@ struct updater_config {
struct system_property system_properties[SYS_PROP_MAX];
};
+/* An helper function to return "mainfw_act" system property. */
+static int host_get_mainfw_act()
+{
+ char buf[VB_MAX_STRING_PROPERTY];
+
+ if (!VbGetSystemPropertyString("mainfw_act", buf, sizeof(buf)))
+ return SLOT_UNKNOWN;
+
+ if (strcmp(buf, FWACT_A) == 0)
+ return SLOT_A;
+ else if (strcmp(buf, FWACT_B) == 0)
+ return SLOT_B;
+
+ return SLOT_UNKNOWN;
+}
+
/* A helper function to return the "hardware write protection" status. */
static int host_get_wp_hw()
{
@@ -719,6 +750,7 @@ static int do_update(int argc, char *argv[])
.pd_image = { .programmer = PROG_PD, },
.emulate = 0,
.system_properties = {
+ [SYS_PROP_MAINFW_ACT] = {.getter = host_get_mainfw_act},
[SYS_PROP_WP_HW] = {.getter = host_get_wp_hw},
[SYS_PROP_WP_SW] = {.getter = host_get_wp_sw},
},
diff --git a/tests/futility/test_update.sh b/tests/futility/test_update.sh
index e06bbc59..873a6f56 100755
--- a/tests/futility/test_update.sh
+++ b/tests/futility/test_update.sh
@@ -67,6 +67,8 @@ test_update() {
cmp "${TMP}.emu" "${expected}"
}
+# --sys_props: mainfw_act, [wp_hw, wp_sw]
+
# Test Full update.
test_update "Full update" \
"${FROM_IMAGE}" "${TMP}.expected.full" \