common: android_ab: add function ab_can_find_recovery_part

Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Ic8f225699915063b9a2e069a4cb248fd4d5a6976
This commit is contained in:
Jason Zhu 2021-02-08 16:45:16 +08:00 committed by Jianhong Chen
parent 9876686da0
commit 66f2fdd9d8
2 changed files with 27 additions and 0 deletions

View File

@ -505,3 +505,29 @@ int ab_decrease_tries(void)
return 0;
}
/*
* In android A/B system, there is no recovery partition,
* but in the linux system, we need the recovery to update system.
* This function is used to find firmware in recovery partition
* when enable CONFIG_ANDROID_AB.
*/
bool ab_can_find_recovery_part(void)
{
disk_partition_t part_info;
struct blk_desc *dev_desc;
int part_num;
dev_desc = rockchip_get_bootdev();
if (!dev_desc) {
printf("%s: Could not find device\n", __func__);
return false;
}
part_num = part_get_info_by_name(dev_desc, ANDROID_PARTITION_RECOVERY,
&part_info);
if (part_num < 0)
return false;
else
return true;
}

View File

@ -51,5 +51,6 @@ void ab_update_root_uuid(void);
int ab_get_slot_suffix(char *slot_suffix);
int ab_is_support_dynamic_partition(struct blk_desc *dev_desc);
int ab_decrease_tries(void);
bool ab_can_find_recovery_part(void);
#endif