rockchip: add misc BCB message offset compatibility
Rockchip platforms defines BCB message at the 16KB offset of misc partition while the Google defines it at 0x0 offset. From Android-Q, the 0x0 offset is mandary on Google VTS, so this patch is a compatibility according to android image 'os_version'. Android os version >= 10 is at 0x0 offset, otherwise at 16KB offset. Change-Id: I54a7674e2dc2e0c29fc624f17b4453663c9ea462 Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
c092b1390d
commit
a84f21ebb8
|
|
@ -258,15 +258,14 @@ static int init_resource_list(struct resource_img_hdr *hdr)
|
|||
if (!hdr)
|
||||
return -ENOMEM;
|
||||
|
||||
/*
|
||||
* Anyway, we must read android hdr firstly from boot partition to get
|
||||
* the 'os_version' for android_bcb_msg_sector_offset() to confirm BCB
|
||||
* message offset of misc partition.
|
||||
*/
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
struct andr_img_hdr *andr_hdr;
|
||||
|
||||
/* Get boot mode from misc */
|
||||
#ifndef CONFIG_ANDROID_AB
|
||||
if (rockchip_get_boot_mode() == BOOT_MODE_RECOVERY)
|
||||
boot_partname = PART_RECOVERY;
|
||||
#endif
|
||||
|
||||
ret = part_get_info_by_name(dev_desc, boot_partname, &part_info);
|
||||
if (ret < 0) {
|
||||
printf("%s: failed to get %s part, ret=%d\n",
|
||||
|
|
@ -274,7 +273,6 @@ static int init_resource_list(struct resource_img_hdr *hdr)
|
|||
goto parse_resource_part;
|
||||
}
|
||||
|
||||
/* Try to find resource from android second position */
|
||||
andr_hdr = (void *)hdr;
|
||||
ret = blk_dread(dev_desc, part_info.start, cnt, andr_hdr);
|
||||
if (ret != cnt) {
|
||||
|
|
@ -289,14 +287,40 @@ static int init_resource_list(struct resource_img_hdr *hdr)
|
|||
u32 os_ver = andr_hdr->os_version >> 11;
|
||||
u32 os_lvl = andr_hdr->os_version & ((1U << 11) - 1);
|
||||
|
||||
#ifdef DEBUG
|
||||
android_print_contents(andr_hdr);
|
||||
#endif
|
||||
if (os_ver)
|
||||
if (os_ver) {
|
||||
gd->bd->bi_andr_version = andr_hdr->os_version;
|
||||
printf("Android %u.%u, Build %u.%u\n",
|
||||
(os_ver >> 14) & 0x7F, (os_ver >> 7) & 0x7F,
|
||||
(os_lvl >> 4) + 2000, os_lvl & 0x0F);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get boot mode from misc and read if recovery mode */
|
||||
#ifndef CONFIG_ANDROID_AB
|
||||
if (rockchip_get_boot_mode() == BOOT_MODE_RECOVERY) {
|
||||
boot_partname = PART_RECOVERY;
|
||||
|
||||
ret = part_get_info_by_name(dev_desc, boot_partname, &part_info);
|
||||
if (ret < 0) {
|
||||
printf("%s: failed to get %s part, ret=%d\n",
|
||||
__func__, boot_partname, ret);
|
||||
goto parse_resource_part;
|
||||
}
|
||||
|
||||
/* Try to find resource from android second position */
|
||||
andr_hdr = (void *)hdr;
|
||||
ret = blk_dread(dev_desc, part_info.start, cnt, andr_hdr);
|
||||
if (ret != cnt) {
|
||||
printf("%s: failed to read %s hdr, ret=%d\n",
|
||||
__func__, part_info.name, ret);
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = android_image_check_header(andr_hdr);
|
||||
if (!ret) {
|
||||
rsce_base = part_info.start * dev_desc->blksz;
|
||||
rsce_base += andr_hdr->page_size;
|
||||
rsce_base += ALIGN(andr_hdr->kernel_size, andr_hdr->page_size);
|
||||
|
|
|
|||
|
|
@ -42,8 +42,6 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
#define ANDROID_VERIFY_STATE "androidboot.verifiedbootstate="
|
||||
#ifdef CONFIG_ROCKCHIP_RESOURCE_IMAGE
|
||||
#define ANDROID_ARG_FDT_FILENAME "rk-kernel.dtb"
|
||||
#define BOOTLOADER_MESSAGE_OFFSET_IN_MISC (16 * 1024)
|
||||
#define BOOTLOADER_MESSAGE_BLK_OFFSET (BOOTLOADER_MESSAGE_OFFSET_IN_MISC >> 9)
|
||||
#else
|
||||
#define ANDROID_ARG_FDT_FILENAME "kernel.dtb"
|
||||
#endif
|
||||
|
|
@ -185,12 +183,8 @@ int android_bootloader_message_load(
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RKIMG_BOOTLOADER
|
||||
if (blk_dread(dev_desc, part_info->start + BOOTLOADER_MESSAGE_BLK_OFFSET,
|
||||
if (blk_dread(dev_desc, part_info->start + android_bcb_msg_sector_offset(),
|
||||
message_blocks, message) !=
|
||||
#else
|
||||
if (blk_dread(dev_desc, part_info->start, message_blocks, message) !=
|
||||
#endif
|
||||
message_blocks) {
|
||||
printf("Could not read from misc partition\n");
|
||||
return -1;
|
||||
|
|
@ -204,13 +198,9 @@ static int android_bootloader_message_write(
|
|||
const disk_partition_t *part_info,
|
||||
struct android_bootloader_message *message)
|
||||
{
|
||||
#ifdef CONFIG_RKIMG_BOOTLOADER
|
||||
ulong message_blocks = sizeof(struct android_bootloader_message) /
|
||||
part_info->blksz + BOOTLOADER_MESSAGE_BLK_OFFSET;
|
||||
#else
|
||||
ulong message_blocks = sizeof(struct android_bootloader_message) /
|
||||
part_info->blksz;
|
||||
#endif
|
||||
part_info->blksz + android_bcb_msg_sector_offset();
|
||||
|
||||
if (message_blocks > part_info->size) {
|
||||
printf("misc partition too small.\n");
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@
|
|||
#include <bootm.h>
|
||||
#include <boot_rkimg.h>
|
||||
#include <console.h>
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
#include <image.h>
|
||||
#endif
|
||||
#include <malloc.h>
|
||||
#include <mmc.h>
|
||||
#include <part.h>
|
||||
|
|
@ -306,6 +309,11 @@ static void rkloader_set_bootloader_msg(struct bootloader_message *bmsg)
|
|||
struct blk_desc *dev_desc;
|
||||
disk_partition_t part_info;
|
||||
int ret, cnt;
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
u32 bcb_offset = android_bcb_msg_sector_offset();
|
||||
#else
|
||||
u32 bcb_offset = BOOTLOADER_MESSAGE_BLK_OFFSET;
|
||||
#endif
|
||||
|
||||
dev_desc = rockchip_get_bootdev();
|
||||
if (!dev_desc) {
|
||||
|
|
@ -321,7 +329,7 @@ static void rkloader_set_bootloader_msg(struct bootloader_message *bmsg)
|
|||
|
||||
cnt = DIV_ROUND_UP(sizeof(struct bootloader_message), dev_desc->blksz);
|
||||
ret = blk_dwrite(dev_desc,
|
||||
part_info.start + BOOTLOADER_MESSAGE_BLK_OFFSET,
|
||||
part_info.start + bcb_offset,
|
||||
cnt, bmsg);
|
||||
if (ret != cnt)
|
||||
printf("%s: Wipe data failed\n", __func__);
|
||||
|
|
@ -390,6 +398,11 @@ int rockchip_get_boot_mode(void)
|
|||
char *env_reboot_mode;
|
||||
int clear_boot_reg = 0;
|
||||
int ret, cnt;
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
u32 bcb_offset = android_bcb_msg_sector_offset();
|
||||
#else
|
||||
u32 bcb_offset = BOOTLOADER_MESSAGE_BLK_OFFSET;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Here, we mainly check for:
|
||||
|
|
@ -428,7 +441,7 @@ int rockchip_get_boot_mode(void)
|
|||
cnt = DIV_ROUND_UP(sizeof(struct bootloader_message), dev_desc->blksz);
|
||||
bmsg = memalign(ARCH_DMA_MINALIGN, cnt * dev_desc->blksz);
|
||||
ret = blk_dread(dev_desc,
|
||||
part_info.start + BOOTLOADER_MESSAGE_BLK_OFFSET,
|
||||
part_info.start + bcb_offset,
|
||||
cnt, bmsg);
|
||||
if (ret != cnt) {
|
||||
free(bmsg);
|
||||
|
|
|
|||
Loading…
Reference in New Issue