From b7ab6e41f8ec83d58ec74ef7e9c22e42e86ab1a7 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 12 May 2022 11:32:52 -0500 Subject: cmd: ab_select: Don't count boot-to-recovery as a boot attempt. The slot rollback system is intended for normal boot failures after an OTA, and therefore, we should not attempt to change slots based on a failure to boot to recovery (or any other non-normal boot sequence). Signed-off-by: Ram Muthiah Link: https://android-review.googlesource.com/c/platform/external/u-boot/+/1446441 Signed-off-by: Guillaume La Roque --- common/android_ab.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/android_ab.c b/common/android_ab.c index 4943f26d53..80aedfbef8 100644 --- a/common/android_ab.c +++ b/common/android_ab.c @@ -181,7 +181,8 @@ static int ab_compare_slots(const struct slot_metadata *a, return 0; } -int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info) +int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info, + bool normal_boot) { struct bootloader_control *abc = NULL; u32 crc32_le; @@ -268,7 +269,11 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info) } } - if (slot >= 0 && !abc->slot_info[slot].successful_boot) { + /* Note that we only count the boot attempt as a valid try when performing + * normal boots to Android. Booting to recovery or fastboot does not count + * as a normal boot. + */ + if (slot >= 0 && !abc->slot_info[slot].successful_boot && normal_boot) { log_err("ANDROID: Attempting slot %c, tries remaining %d\n", BOOT_SLOT_NAME(slot), abc->slot_info[slot].tries_remaining); -- cgit v1.2.3