Skip to content

Commit

Permalink
aboot: Fix A/B slot success logic
Browse files Browse the repository at this point in the history
It is enough just to set the success flag for the current slot instead
of touching the retry counter ourselves. The primary bootloader should
do that for us if it sees the success flag.

Also it appears we never actually wrote the flags to disk in the
original commit, so let's do that with attributes_updated variable and
the partition_mark_active_slot function.
  • Loading branch information
z3ntu authored and M0Rf30 committed Dec 11, 2023
1 parent 67401d5 commit ed70adf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/aboot/lk2nd-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,10 @@ static void lk2nd_handle_multislot(void)

if (strcmp(lk2nd_dev.slot_suffix, "_a") == 0) {
dprintf(INFO, "Marking Slot A as successful.\n");
partition_reset_retry_count(SLOT_A);
partition_set_successful(SLOT_A);
} else if (strcmp(lk2nd_dev.slot_suffix, "_b") == 0) {
dprintf(INFO, "Marking Slot B as successful.\n");
partition_reset_retry_count(SLOT_B);
partition_set_successful(SLOT_B);
} else {
dprintf(CRITICAL, "ERROR: Couldn't determine slot suffix of %s\n", lk2nd_dev.slot_suffix);
}
Expand Down
12 changes: 8 additions & 4 deletions platform/msm_shared/ab_partition_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,19 @@ partition_activate_slot(int slot)
return;
}

void partition_reset_retry_count(int slot)
void partition_set_successful(int slot)
{
struct partition_entry *partition_entries =
partition_get_partition_entries();
int slt_index = boot_slot_index[slot];

/* Set Max retry count and priority value */
partition_entries[slt_index].attribute_flag |= (PART_ATT_PRIORITY_VAL |
PART_ATT_MAX_RETRY_COUNT_VAL);
/* Set Success bit */
SET_BIT(partition_entries[slt_index].attribute_flag, PART_ATT_SUCCESS_BIT);

attributes_updated = true;

/* Make attributes persistant */
partition_mark_active_slot(active_slot);

return;
}
Expand Down
2 changes: 1 addition & 1 deletion platform/msm_shared/include/ab_partition_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void partition_fill_slot_meta(); /* Fill slot meta infomation */
void partition_switch_slots(); /* Switching slots */
void partition_deactivate_slot(int slot); /* Mark slot unbootable and reset other attributes*/
void partition_activate_slot(int slot); /* Mark slot bootable and set other attributes*/
void partition_reset_retry_count(int slot); /* Reset retry count of slot */
void partition_set_successful(int slot); /* Mark slot successful */
int partition_find_boot_slot(); /* Find bootable partition */
int partition_find_active_slot(); /* Find current active partition*/
int partition_fill_partition_meta(); /* Fill partition slot info meta*/
Expand Down

0 comments on commit ed70adf

Please sign in to comment.