summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Pinnell McAllister <[email protected]>2026-05-25 00:31:58 +0000
committerMattijs Korpershoek <[email protected]>2026-06-15 09:15:05 +0200
commite41e97e6e6061fec5a2fb069eaad662cf6359a93 (patch)
treee0ddcfb493a11c6c733a7b828b2f92f93a6ddb07
parent1bd1d033377796418008e9a2351f18dbdf88940c (diff)
android_ab: fix slot selection
The boot selection rules state that a slot is bootable if it is not corrupted and either has tries remaining or has already booted successfully. However, slots that have tries_remaining == 0 and successful_boot == 1 will be disregarded when picking the slot to attempt. Updates the selection logic so slots marked successful remain eligible even when their tries counter is zero. Debug message now also includes the successful_boot value. Signed-off-by: Colin Pinnell McAllister <[email protected]> Reviewed-by: Mattijs Korpershoek <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mattijs Korpershoek <[email protected]>
-rw-r--r--boot/android_ab.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/boot/android_ab.c b/boot/android_ab.c
index 13e82dbcb7f..f2b1110aa24 100644
--- a/boot/android_ab.c
+++ b/boot/android_ab.c
@@ -289,11 +289,14 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
slot = -1;
for (i = 0; i < abc->nb_slot; ++i) {
if (abc->slot_info[i].verity_corrupted ||
- !abc->slot_info[i].tries_remaining) {
+ (!abc->slot_info[i].tries_remaining &&
+ !abc->slot_info[i].successful_boot)) {
log_debug("ANDROID: unbootable slot %d tries: %d, ",
i, abc->slot_info[i].tries_remaining);
- log_debug("corrupt: %d\n",
+ log_debug("corrupt: %d, ",
abc->slot_info[i].verity_corrupted);
+ log_debug("successful: %d\n",
+ abc->slot_info[i].successful_boot);
continue;
}
log_debug("ANDROID: bootable slot %d pri: %d, tries: %d, ",