public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] android_ab: fix slot selection
@ 2026-03-13 20:14 Colin Pinnell McAllister
  2026-04-09 10:21 ` Mattijs Korpershoek
  0 siblings, 1 reply; 3+ messages in thread
From: Colin Pinnell McAllister @ 2026-03-13 20:14 UTC (permalink / raw)
  To: u-boot; +Cc: Colin Pinnell McAllister

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.

Update the selection logic so slots marked successful remain eligible
even when their tries counter is zero. Also include the successful_boot
state in the unbootable-slot debug output.

Signed-off-by: Colin Pinnell McAllister <colin.mcallister@garmin.com>
---

An alternative would be to keep the existing behavior and update the
comment in boot/android_ab.c:276 to remove the successful_boot
condition. I do prefer updating the logic to match the documented rules.
Currently, the userspace AB code will need to increment the tries
counter for a slot that has booted successfully but has no tries left.

 boot/android_ab.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/boot/android_ab.c b/boot/android_ab.c
index 13e82dbcb7f..93e74f81d4b 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, ",
--
2.53.0


________________________________

CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be Garmin confidential and/or Garmin legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.

________________________________

CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be Garmin confidential and/or Garmin legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-09 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-13 20:14 [PATCH] android_ab: fix slot selection Colin Pinnell McAllister
2026-04-09 10:21 ` Mattijs Korpershoek
2026-04-09 15:34   ` Pinnell McAllister, Colin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox