summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Timohi <alexandru.timohi@intel.com>2016-04-26 11:26:16 +0300
committerMihai Serban <mihai.serban@intel.com>2016-05-10 15:53:18 +0300
commit996b9e71ca1a0e583da3e4ba6e18a44b4e7cacfc (patch)
tree897671c535685f5d15cafbd56cefbdaee2d1e803
parent5f995662ba1a032b678cd385444726cd3f24161a (diff)
downloadedison-u-boot-996b9e71ca1a0e583da3e4ba6e18a44b4e7cacfc.tar.gz
edison: Add variables to kernel command line
The boot loader shall also append the following options on the kernel command line: androidboot.bvb.device_state androidboot.bvb.slot_chosen highest -the booted slot was the one with the highest priority fallback -the booted slot was chosen as a fallback because the slot with the highest priority didn’t work recovery -there are no bootable slots and the recovery partition was loaded and executed androidboot.bvb.fallback_reason This must be set only set if slot_chosen is set to fallback or recovery and explains why the slot with the highest priority didn’t work. Change-Id: Ia6b2c422c0fe796cc078ea31cf5b81796e12afba Tracked-On: https://jira01.devtools.intel.com/browse/BP-375 Signed-off-by: Alexandru Timohi <alexandru.timohi@intel.com> Reviewed-on: https://android.intel.com/499691 Reviewed-by: Serban, Mihai <mihai.serban@intel.com> Tested-by: Serban, Mihai <mihai.serban@intel.com>
-rw-r--r--common/cmd_boot_brillo.c59
1 files changed, 55 insertions, 4 deletions
diff --git a/common/cmd_boot_brillo.c b/common/cmd_boot_brillo.c
index 87db21b1b9..28c6036c63 100644
--- a/common/cmd_boot_brillo.c
+++ b/common/cmd_boot_brillo.c
@@ -67,7 +67,10 @@
#define CONFIG_BRILLO_MMC_BOOT_DEVICE CONFIG_FASTBOOT_FLASH_MMC_DEV
#endif
-#define SLOT_SUFFIX_STR "androidboot.slot_suffix="
+#define BOOT_ARG_SLOT_SUFFIX_STR "androidboot.slot_suffix="
+#define BOOT_ARG_DEVICE_STATE_STR "androidboot.bvb.device_state="
+#define BOOT_ARG_SLOT_CHOSEN_STR "androidboot.bvb.slot_chosen="
+#define BOOT_ARG_FALLBACK_REASON_STR "androidboot.bvb.fallback_reason="
#define BOOTCTRL_SUFFIX_A "_a"
#define BOOTCTRL_SUFFIX_B "_b"
@@ -96,6 +99,7 @@ struct boot_ctrl {
} __attribute__((packed));
extern bool fb_get_wipe_userdata_response(void);
+int fb_read_lock_state(uint8_t* lock_state);
/* To be overridden by whatever the board's implementation is of
* 'adb reboot fastboot' and the like.
@@ -383,7 +387,7 @@ static void brillo_do_reset(void)
hang();
}
-static int brillo_setup_bootargs(void)
+static void brillo_setup_bootargs(void)
{
char serial_arg[56] = "androidboot.serialno=";
char *serial;
@@ -506,6 +510,20 @@ static void __mark_slot_as_failed(struct slot_metadata *slot, char *slot_name)
slot->priority = 0;
printf("WARNING: failed to boot %s slot!\n", slot_name);
}
+
+/* Fallback reasons
+ *
+ * This must be set only if slot_chosen is set to "fallback" or "recovery"
+ * and explains why the slot with the highest priority didn’t work. Possible values include:
+ */
+#define FBR_UNKOWN 0
+#define FBR_TRY_COUNT_EXHAUSTED 1
+#define FBR_READ_FAILED FBR_TRY_COUNT_EXHAUSTED << 1
+#define FBR_HASH_MISMATCH FBR_READ_FAILED << 1
+#define FBR_SIGNATURE_INVALID FBR_HASH_MISMATCH << 1
+#define FBR_UNKOWN_PUBLIC_KEY FBR_SIGNATURE_INVALID << 1
+#define FBR_INVALID_ROLLBACK_INDEX FBR_UNKOWN_PUBLIC_KEY << 1
+
static int brillo_boot_ab(void)
{
struct bootloader_message message;
@@ -517,6 +535,8 @@ static int brillo_boot_ab(void)
char boot_part[8];
char *old_bootargs;
struct mmc *mmc;
+ uint8_t lock_state = 0; /* Lock state is default unlocked */
+ uint8_t fallback_reason = FBR_UNKOWN;
if (!(dev = get_dev("mmc", CONFIG_BRILLO_MMC_BOOT_DEVICE)))
return -ENODEV;
@@ -548,6 +568,7 @@ static int brillo_boot_ab(void)
struct slot_metadata *slot = &metadata->slot_info[slot_num];
if (slot->successful_boot == 0 && slot->tries_remaining == 0) {
+ fallback_reason = FBR_TRY_COUNT_EXHAUSTED;
/* This is a failed slot, lower priority to zero */
slot->priority = 0;
} else {
@@ -561,17 +582,47 @@ static int brillo_boot_ab(void)
if (load_boot_image(dev, boot_part)) {
/* Failed to load, mark as failed */
__mark_slot_as_failed(slot, suffixes[slot_num]);
+ fallback_reason = FBR_READ_FAILED;
continue;
}
+
if (slot->tries_remaining > 0)
slot->tries_remaining--;
metadata->recovery_tries_remaining = 7;
+ ab_write_bootloader_message(dev, &misc_part, &message);
old_bootargs = strdup(getenv("bootargs"));
- append_to_bootargs(" " SLOT_SUFFIX_STR);
+ append_to_bootargs(" " BOOT_ARG_SLOT_SUFFIX_STR);
append_to_bootargs(suffixes[slot_num]);
- ab_write_bootloader_message(dev, &misc_part, &message);
+ fb_read_lock_state(&lock_state);
+
+ append_to_bootargs(" " BOOT_ARG_DEVICE_STATE_STR);
+
+ if (lock_state == 1)
+ append_to_bootargs("locked");
+ else
+ append_to_bootargs("unlocked");
+
+ append_to_bootargs(" " BOOT_ARG_SLOT_CHOSEN_STR);
+ if (slots_by_priority[index] == 0) {
+ append_to_bootargs("highest");
+ } else {
+ append_to_bootargs("fallback");
+ switch (fallback_reason) {
+ case FBR_READ_FAILED:
+ append_to_bootargs(" " BOOT_ARG_FALLBACK_REASON_STR);
+ append_to_bootargs("read_failed");
+ break;
+ case FBR_TRY_COUNT_EXHAUSTED:
+ append_to_bootargs(" " BOOT_ARG_FALLBACK_REASON_STR);
+ append_to_bootargs("try_count_exhausted");
+ break;
+ default:
+ break;
+ }
+ }
+
boot_image();
/* Failed to boot, mark as failed */