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>
diff --git a/cmd/abootimg.c b/cmd/abootimg.c
index 4d6cf0f..2653b55 100644
--- a/cmd/abootimg.c
+++ b/cmd/abootimg.c
@@ -17,6 +17,16 @@
static ulong _abootimg_addr = -1;
static ulong _avendor_bootimg_addr = -1;
+ulong get_abootimg_addr(void)
+{
+ return (_abootimg_addr == -1 ? image_load_addr : _abootimg_addr);
+}
+
+ulong get_avendor_bootimg_addr(void)
+{
+ return _avendor_bootimg_addr;
+}
+
static int abootimg_get_ver(int argc, char *const argv[])
{
const struct andr_boot_img_hdr_v0 *hdr;
@@ -70,12 +80,21 @@
return CMD_RET_USAGE;
struct andr_image_data img_data = {0};
const struct andr_boot_img_hdr_v0 *hdr;
+ const struct andr_vnd_boot_img_hdr *vhdr;
hdr = map_sysmem(abootimg_addr(), sizeof(*hdr));
- if (!android_image_get_data(hdr, NULL, &img_data)) {
+ if (get_avendor_bootimg_addr() != -1)
+ vhdr = map_sysmem(get_avendor_bootimg_addr(), sizeof(*vhdr));
+
+ if (!android_image_get_data(hdr, vhdr, &img_data)) {
+ if (get_avendor_bootimg_addr() != -1)
+ unmap_sysmem(vhdr);
unmap_sysmem(hdr);
return CMD_RET_FAILURE;
}
+
+ if (get_avendor_bootimg_addr() != -1)
+ unmap_sysmem(vhdr);
unmap_sysmem(hdr);
if (img_data.header_version < 2) {
@@ -119,7 +138,8 @@
return CMD_RET_FAILURE;
}
- if (!android_image_get_dtb_by_index(abootimg_addr(), 0, num,
+ if (!android_image_get_dtb_by_index(abootimg_addr(),
+ get_avendor_bootimg_addr(), num,
&addr, &size)) {
return CMD_RET_FAILURE;
}