From 66f2fdd9d85941bd4a3ac90df135883282ce6de3 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Mon, 8 Feb 2021 16:45:16 +0800 Subject: [PATCH] common: android_ab: add function ab_can_find_recovery_part Signed-off-by: Jason Zhu Change-Id: Ic8f225699915063b9a2e069a4cb248fd4d5a6976 --- common/android_ab.c | 26 ++++++++++++++++++++++++++ include/android_ab.h | 1 + 2 files changed, 27 insertions(+) diff --git a/common/android_ab.c b/common/android_ab.c index a80dc088eb..2182d3da50 100644 --- a/common/android_ab.c +++ b/common/android_ab.c @@ -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; +} diff --git a/include/android_ab.h b/include/android_ab.h index 921407b0f2..aa621ca426 100644 --- a/include/android_ab.h +++ b/include/android_ab.h @@ -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