android: boot: support boot image header version 3 and 4

Enable the support for boot image header version 3 and 4
using abootimg command.

In order to use version 3 or 4:

1- Vendor boot image address should be given to abootimg cmd.

	abootimg addr $1 $vendor_boot_load_addr

2- "ramdisk_addr_r" env variable (ramdisk address) should be set to host
the ramdisk : generic ramdisk + vendor ramdisk

Replace "struct andr_boot_img_hdr_v0*" by "void *" in
some functions since v3 and v4 are now supported as well.

Signed-off-by: Safae Ouajih <souajih@baylibre.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
This commit is contained in:
Safae Ouajih 2023-02-06 00:50:17 +01:00 committed by Tom Rini
parent bc6413bdd9
commit 636da2039a
6 changed files with 99 additions and 23 deletions

View file

@ -113,6 +113,10 @@ static int bootm_find_os(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
const void *os_hdr;
#ifdef CONFIG_ANDROID_BOOT_IMAGE
const void *vendor_boot_img;
const void *boot_img;
#endif
bool ep_found = false;
int ret;
@ -181,14 +185,23 @@ static int bootm_find_os(struct cmd_tbl *cmdtp, int flag, int argc,
#endif
#ifdef CONFIG_ANDROID_BOOT_IMAGE
case IMAGE_FORMAT_ANDROID:
boot_img = os_hdr;
vendor_boot_img = NULL;
if (IS_ENABLED(CONFIG_CMD_ABOOTIMG)) {
boot_img = map_sysmem(get_abootimg_addr(), 0);
vendor_boot_img = map_sysmem(get_avendor_bootimg_addr(), 0);
}
images.os.type = IH_TYPE_KERNEL;
images.os.comp = android_image_get_kcomp(os_hdr, NULL);
images.os.comp = android_image_get_kcomp(boot_img, vendor_boot_img);
images.os.os = IH_OS_LINUX;
images.os.end = android_image_get_end(os_hdr, NULL);
images.os.load = android_image_get_kload(os_hdr, NULL);
images.os.end = android_image_get_end(boot_img, vendor_boot_img);
images.os.load = android_image_get_kload(boot_img, vendor_boot_img);
images.ep = images.os.load;
ep_found = true;
if (IS_ENABLED(CONFIG_CMD_ABOOTIMG)) {
unmap_sysmem(vendor_boot_img);
unmap_sysmem(boot_img);
}
break;
#endif
default:
@ -889,6 +902,10 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
int os_noffset;
#endif
#ifdef CONFIG_ANDROID_BOOT_IMAGE
const void *boot_img;
const void *vendor_boot_img;
#endif
img_addr = genimg_get_kernel_addr_fit(argc < 1 ? NULL : argv[0],
&fit_uname_config,
&fit_uname_kernel);
@ -964,10 +981,20 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
#endif
#ifdef CONFIG_ANDROID_BOOT_IMAGE
case IMAGE_FORMAT_ANDROID:
boot_img = buf;
vendor_boot_img = NULL;
if (IS_ENABLED(CONFIG_CMD_ABOOTIMG)) {
boot_img = map_sysmem(get_abootimg_addr(), 0);
vendor_boot_img = map_sysmem(get_avendor_bootimg_addr(), 0);
}
printf("## Booting Android Image at 0x%08lx ...\n", img_addr);
if (android_image_get_kernel(buf, NULL, images->verify,
if (android_image_get_kernel(boot_img, vendor_boot_img, images->verify,
os_data, os_len))
return NULL;
if (IS_ENABLED(CONFIG_CMD_ABOOTIMG)) {
unmap_sysmem(vendor_boot_img);
unmap_sysmem(boot_img);
}
break;
#endif
default: