common: android: support boot recovery system
In android A/B system, there is no recovery partition, but in the linux system, we need the recovery to update system. Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com> Change-Id: Idac88720b260791b1ad4c51a5ebc7aae9c66ca67
This commit is contained in:
parent
66f2fdd9d8
commit
fc04460b2e
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <adc.h>
|
#include <adc.h>
|
||||||
|
#include <android_ab.h>
|
||||||
#include <android_bootloader.h>
|
#include <android_bootloader.h>
|
||||||
#include <android_image.h>
|
#include <android_image.h>
|
||||||
#include <boot_rkimg.h>
|
#include <boot_rkimg.h>
|
||||||
|
@ -416,13 +417,18 @@ static int get_resource_base_sector(struct blk_desc *dev_desc,
|
||||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||||
struct andr_img_hdr *hdr;
|
struct andr_img_hdr *hdr;
|
||||||
u32 os_ver = 0, os_lvl;
|
u32 os_ver = 0, os_lvl;
|
||||||
|
const char *part_boot = PART_BOOT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Anyway, we must read android hdr firstly from boot partition to get
|
* Anyway, we must read android hdr firstly from boot/recovery partition
|
||||||
* the 'os_version' for android_bcb_msg_sector_offset(), in order to
|
* to get the 'os_version' for android_bcb_msg_sector_offset(), in order
|
||||||
* confirm BCB message offset of *MISC* partition.
|
* to confirm BCB message offset of *MISC* partition.
|
||||||
*/
|
*/
|
||||||
if (part_get_info_by_name(dev_desc, PART_BOOT, &part) < 0)
|
#ifdef CONFIG_ANDROID_AB
|
||||||
|
part_boot = ab_can_find_recovery_part() ? PART_RECOVERY : PART_BOOT;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (part_get_info_by_name(dev_desc, part_boot, &part) < 0)
|
||||||
goto resource_part;
|
goto resource_part;
|
||||||
|
|
||||||
hdr = populate_andr_img_hdr(dev_desc, &part);
|
hdr = populate_andr_img_hdr(dev_desc, &part);
|
||||||
|
|
|
@ -795,23 +795,27 @@ int android_fdt_overlay_apply(void *fdt_addr)
|
||||||
{
|
{
|
||||||
struct andr_img_hdr *hdr;
|
struct andr_img_hdr *hdr;
|
||||||
struct blk_desc *dev_desc;
|
struct blk_desc *dev_desc;
|
||||||
const char *part_boot;
|
const char *part_boot = PART_BOOT;
|
||||||
disk_partition_t part_info;
|
disk_partition_t part_info;
|
||||||
char *fdt_backup;
|
char *fdt_backup;
|
||||||
char *part_dtbo;
|
char *part_dtbo = PART_DTBO;
|
||||||
char buf[32] = {0};
|
char buf[32] = {0};
|
||||||
ulong fdt_dtbo = -1;
|
ulong fdt_dtbo = -1;
|
||||||
u32 totalsize;
|
u32 totalsize;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_ANDROID_AB) ||
|
if (rockchip_get_boot_mode() == BOOT_MODE_RECOVERY) {
|
||||||
(rockchip_get_boot_mode() != BOOT_MODE_RECOVERY)) {
|
#ifdef CONFIG_ANDROID_AB
|
||||||
part_boot = PART_BOOT;
|
bool can_find_recovery;
|
||||||
part_dtbo = PART_DTBO;
|
|
||||||
} else {
|
can_find_recovery = ab_can_find_recovery_part();
|
||||||
|
part_boot = can_find_recovery ? PART_RECOVERY : PART_BOOT;
|
||||||
|
part_dtbo = can_find_recovery ? PART_RECOVERY : PART_DTBO;
|
||||||
|
#else
|
||||||
part_boot = PART_RECOVERY;
|
part_boot = PART_RECOVERY;
|
||||||
part_dtbo = PART_RECOVERY;
|
part_dtbo = PART_RECOVERY;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_desc = rockchip_get_bootdev();
|
dev_desc = rockchip_get_bootdev();
|
||||||
|
@ -978,10 +982,15 @@ int android_bootloader_boot_flow(struct blk_desc *dev_desc,
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case ANDROID_BOOT_MODE_RECOVERY:
|
case ANDROID_BOOT_MODE_RECOVERY:
|
||||||
/* In recovery mode we still boot the kernel from "boot" but
|
/*
|
||||||
* don't skip the initramfs so it boots to recovery.
|
* In recovery mode, if have recovery partition, we still boot the
|
||||||
|
* kernel from "recovery". If not, don't skip the initramfs so it
|
||||||
|
* boots to recovery from image in partition "boot".
|
||||||
*/
|
*/
|
||||||
#ifndef CONFIG_ANDROID_AB
|
#ifdef CONFIG_ANDROID_AB
|
||||||
|
boot_partname = ab_can_find_recovery_part() ?
|
||||||
|
ANDROID_PARTITION_RECOVERY : ANDROID_PARTITION_BOOT;
|
||||||
|
#else
|
||||||
boot_partname = ANDROID_PARTITION_RECOVERY;
|
boot_partname = ANDROID_PARTITION_RECOVERY;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue