bootstd: android: don't read whole partition sizes

The current implementation is reading the whole partition for boot and
vendor_boot image which can be long following the size of the
partition or the time to read blocks (driver/SoC specific).

For example with mediatek mt8365 EVK board, we have a 64MiB boot
partition and the boot image flashed in this partition is only 42MiB.
It takes ~8-9 secs to read the boot partition.

Instead we can retrieved the boot image and vendor boot image size
with these new functions:
- android_image_get_bootimg_size
- android_image_get_vendor_bootimg_size
Use these information and read only the necessary.

By doing this with mt8365 EVK board, we read boot image in ~5 secs.

Signed-off-by: Julien Masson <jmasson@baylibre.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20241121-bootmeth-android-part-sizes-v1-1-25760bbd0f08@baylibre.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
This commit is contained in:
Julien Masson
2024-11-21 11:59:55 +01:00
committed by Mattijs Korpershoek
parent 126254ab97
commit abadcda24b
3 changed files with 92 additions and 5 deletions

View File

@@ -1801,6 +1801,30 @@ int fit_image_cipher_get_algo(const void *fit, int noffset, char **algo);
struct cipher_algo *image_get_cipher_algo(const char *full_name);
struct andr_image_data;
/**
* android_image_get_bootimg_size() - Extract size of Android boot image
*
* This is used to extract the size of an Android boot image
* from boot image header.
*
* @hdr: Pointer to boot image header
* @boot_img_size: On exit returns the size in bytes of the boot image
* Return: true if succeeded, false otherwise
*/
bool android_image_get_bootimg_size(const void *hdr, u32 *boot_img_size);
/**
* android_image_get_vendor_bootimg_size() - Extract size of Android vendor-boot image
*
* This is used to extract the size of an Android vendor-boot image
* from vendor-boot image header.
*
* @hdr: Pointer to vendor-boot image header
* @vendor_boot_img_size: On exit returns the size in bytes of the vendor-boot image
* Return: true if succeeded, false otherwise
*/
bool android_image_get_vendor_bootimg_size(const void *hdr, u32 *vendor_boot_img_size);
/**
* android_image_get_data() - Parse Android boot images
*