From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Safae Ouajih <souajih@baylibre.com>, sjg@chromium.org
Cc: u-boot@lists.denx.de, sean.anderson@seco.com,
r.stratiienko@gmail.com, glaroque@baylibre.com,
khilman@baylibre.com
Subject: Re: [PATCH v3 10/19] android: boot: update android_image_get_data to support v3,v4
Date: Thu, 09 Feb 2023 15:32:54 +0100 [thread overview]
Message-ID: <871qmykiy1.fsf@baylibre.com> (raw)
In-Reply-To: <20230205235021.355410-11-souajih@baylibre.com>
On Mon, Feb 06, 2023 at 00:50, Safae Ouajih <souajih@baylibre.com> wrote:
> Since boot image header version 3 and 4 introduced vendor boot image,
> use the following functions to fill the generic android
> structure : andr_image_data:
>
> - android_boot_image_v3_v4_parse_hdr()
> - android_vendor_boot_image_v3_v4_parse_hdr()
>
> Update android_image_get_data() to support v3 and v4
>
> Signed-off-by: Safae Ouajih <souajih@baylibre.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> ---
> boot/image-android.c | 80 +++++++++++++++++++++++++++++++++++++++--
> include/android_image.h | 3 ++
> include/image.h | 11 ++++++
> 3 files changed, 91 insertions(+), 3 deletions(-)
>
> diff --git a/boot/image-android.c b/boot/image-android.c
> index f16eebff49..712d437766 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -18,6 +18,65 @@
>
> static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
>
> +static void android_boot_image_v3_v4_parse_hdr(const struct andr_boot_img_hdr_v3 *hdr,
> + struct andr_image_data *data)
> +{
> + ulong end;
> +
> + data->kcmdline = hdr->cmdline;
> + data->header_version = hdr->header_version;
> +
> + /*
> + * The header takes a full page, the remaining components are aligned
> + * on page boundary.
> + */
> + end = (ulong)hdr;
> + end += ANDR_GKI_PAGE_SIZE;
> + data->kernel_ptr = end;
> + data->kernel_size = hdr->kernel_size;
> + end += ALIGN(hdr->kernel_size, ANDR_GKI_PAGE_SIZE);
> + data->ramdisk_size = hdr->ramdisk_size;
> + data->boot_ramdisk_size = hdr->ramdisk_size;
> + end += ALIGN(hdr->ramdisk_size, ANDR_GKI_PAGE_SIZE);
> +
> + if (hdr->header_version > 3)
> + end += ALIGN(hdr->signature_size, ANDR_GKI_PAGE_SIZE);
> +
> + data->boot_img_total_size = end - (ulong)hdr;
> +}
> +
> +static void android_vendor_boot_image_v3_v4_parse_hdr(const struct andr_vnd_boot_img_hdr
> + *hdr, struct andr_image_data *data)
> +{
> + ulong end;
> +
> + /*
> + * The header takes a full page, the remaining components are aligned
> + * on page boundary.
> + */
> + data->tags_addr = hdr->tags_addr;
> + data->image_name = hdr->name;
> + data->kernel_addr = hdr->kernel_addr;
> + data->ramdisk_addr = hdr->ramdisk_addr;
> + data->dtb_load_addr = hdr->dtb_addr;
> + end = (ulong)hdr;
> + end += hdr->page_size;
> + if (hdr->vendor_ramdisk_size) {
> + data->vendor_ramdisk_ptr = end;
> + data->vendor_ramdisk_size = hdr->vendor_ramdisk_size;
> + data->ramdisk_size += hdr->vendor_ramdisk_size;
> + end += ALIGN(hdr->vendor_ramdisk_size, hdr->page_size);
> + }
> +
> + data->dtb_ptr = end;
> + data->dtb_size = hdr->dtb_size;
> +
> + end += ALIGN(hdr->dtb_size, hdr->page_size);
> + end += ALIGN(hdr->vendor_ramdisk_table_size, hdr->page_size);
> + end += ALIGN(hdr->bootconfig_size, hdr->page_size);
> + data->vendor_boot_img_total_size = end - (ulong)hdr;
> +}
> +
> static void android_boot_image_v0_v1_v2_parse_hdr(const struct andr_boot_img_hdr_v0 *hdr,
> struct andr_image_data *data)
> {
> @@ -79,10 +138,20 @@ bool android_image_get_data(const void *boot_hdr, const void *vendor_boot_hdr,
> return false;
> }
>
> - if (((struct andr_boot_img_hdr_v0 *)boot_hdr)->header_version > 2)
> - printf("Only boot image header version 2 and below are supported\n");
> - else
> + if (((struct andr_boot_img_hdr_v0 *)boot_hdr)->header_version > 2) {
> + if (!vendor_boot_hdr) {
> + printf("For boot header v3+ vendor boot image has to be provided\n");
> + return false;
> + }
> + if (!is_android_vendor_boot_image_header(vendor_boot_hdr)) {
> + printf("Incorrect vendor boot image header\n");
> + return false;
> + }
> + android_boot_image_v3_v4_parse_hdr(boot_hdr, data);
> + android_vendor_boot_image_v3_v4_parse_hdr(vendor_boot_hdr, data);
> + } else {
> android_boot_image_v0_v1_v2_parse_hdr(boot_hdr, data);
> + }
>
> return true;
> }
> @@ -200,6 +269,11 @@ int android_image_get_kernel(const struct andr_boot_img_hdr_v0 *hdr,
> return 0;
> }
>
> +bool is_android_vendor_boot_image_header(const void *vendor_boot_img)
> +{
> + return !memcmp(VENDOR_BOOT_MAGIC, vendor_boot_img, ANDR_VENDOR_BOOT_MAGIC_SIZE);
> +}
> +
> bool is_android_boot_image_header(const struct andr_boot_img_hdr_v0 *hdr)
> {
> return !memcmp(ANDR_BOOT_MAGIC, hdr, ANDR_BOOT_MAGIC_SIZE);
> diff --git a/include/android_image.h b/include/android_image.h
> index fb3a9d9858..99e7803508 100644
> --- a/include/android_image.h
> +++ b/include/android_image.h
> @@ -323,6 +323,8 @@ struct andr_image_data {
> ulong kernel_ptr; /* kernel address */
> u32 kernel_size; /* size in bytes */
> u32 ramdisk_size; /* size in bytes */
> + ulong vendor_ramdisk_ptr; /* vendor ramdisk address */
> + u32 vendor_ramdisk_size; /* vendor ramdisk size*/
> u32 boot_ramdisk_size; /* size in bytes */
> ulong second_ptr; /* secondary bootloader address */
> u32 second_size; /* secondary bootloader size */
> @@ -342,6 +344,7 @@ struct andr_image_data {
> ulong tags_addr; /* physical addr for kernel tags */
> u32 header_version; /* version of the boot image header */
> u32 boot_img_total_size; /* boot image size */
> + u32 vendor_boot_img_total_size; /* vendor boot image size */
> };
>
> #endif
> diff --git a/include/image.h b/include/image.h
> index f84c03f08f..c2e751c136 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -1876,6 +1876,17 @@ bool android_image_print_dtb_contents(ulong hdr_addr);
> */
> bool is_android_boot_image_header(const struct andr_boot_img_hdr_v0 *hdr);
>
> +/**
> + * is_android_vendor_boot_image_header() - Check the magic of vendor boot image
> + *
> + * This checks the header of Android vendor boot image and verifies the magic
> + * is "VNDRBOOT"
> + *
> + * @vendor_boot_img: Pointer to boot image
> + * Return: non-zero if the magic is correct, zero otherwise
> + */
> +bool is_android_vendor_boot_image_header(const void *vendor_boot_img);
> +
> /**
> * board_fit_config_name_match() - Check for a matching board name
> *
> --
> 2.34.1
next prev parent reply other threads:[~2023-02-09 14:33 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-05 23:50 [PATCH v3 00/19] Support android boot image v3/v4 Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 01/19] android: boot: rename andr_img_hdr -> andr_boot_img_hdr_v0 Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 02/19] android: boot: support vendor boot image in abootimg Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 03/19] android: boot: replace android_image_check_header Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 04/19] android: boot: add boot image header v3 and v4 structures Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 05/19] android: boot: kcomp: support andr_image_data Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 06/19] android: boot: move to andr_image_data structure Safae Ouajih
2023-02-07 4:02 ` Simon Glass
2023-02-09 16:30 ` Safae Ouajih
2023-02-09 14:26 ` Mattijs Korpershoek
2023-02-09 16:49 ` Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 07/19] android: boot: content print is not supported for v3, v4 header version Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 08/19] android: boot: boot image header v3, v4 do not support recovery DTBO Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 09/19] android: boot: add vendor boot image to prepare for v3, v4 support Safae Ouajih
2023-02-07 4:02 ` [PATCH v3 09/19] android: boot: add vendor boot image to prepare for v3,v4 support Simon Glass
2023-02-09 17:01 ` Safae Ouajih
2023-02-09 14:29 ` Mattijs Korpershoek
2023-02-09 14:30 ` Mattijs Korpershoek
2023-02-05 23:50 ` [PATCH v3 10/19] android: boot: update android_image_get_data to support v3, v4 Safae Ouajih
2023-02-09 14:32 ` Mattijs Korpershoek [this message]
2023-02-05 23:50 ` [PATCH v3 11/19] android: boot: ramdisk: support vendor ramdisk Safae Ouajih
2023-02-09 14:35 ` Mattijs Korpershoek
2023-04-07 8:56 ` Roman Stratiienko
2023-04-07 13:16 ` Mattijs Korpershoek
2023-02-05 23:50 ` [PATCH v3 12/19] android: boot: support extra command line Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 13/19] android: boot: update android_image_get_dtb_img_addr to support v3, v4 Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 14/19] drivers: fastboot: zImage flashing is not supported for " Safae Ouajih
2023-02-09 14:38 ` [PATCH v3 14/19] drivers: fastboot: zImage flashing is not supported for v3,v4 Mattijs Korpershoek
2023-02-05 23:50 ` [PATCH v3 15/19] android: boot: support boot image header version 3 and 4 Safae Ouajih
2023-02-09 14:46 ` Mattijs Korpershoek
2023-02-05 23:50 ` [PATCH v3 16/19] android: boot: support bootconfig Safae Ouajih
2023-02-05 23:50 ` [PATCH v3 17/19] doc: android: add documentation for v3, v4 boot image header Safae Ouajih
2023-02-07 4:02 ` [PATCH v3 17/19] doc: android: add documentation for v3,v4 " Simon Glass
2023-02-08 8:54 ` Mattijs Korpershoek
2023-02-05 23:50 ` [PATCH v3 18/19] test/py: android: extend abootimg test Safae Ouajih
2023-02-07 19:02 ` Tom Rini
2023-02-09 16:52 ` Safae Ouajih
2023-02-27 14:15 ` Safae Ouajih
2023-02-27 14:18 ` Tom Rini
2023-03-06 19:49 ` Safae Ouajih
2023-03-06 20:07 ` Tom Rini
2023-02-05 23:50 ` [PATCH v3 19/19] Dockerfile: add mkbootimg tool Safae Ouajih
2023-02-09 14:08 ` [PATCH v3 00/19] Support android boot image v3/v4 Mattijs Korpershoek
2023-04-05 14:41 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qmykiy1.fsf@baylibre.com \
--to=mkorpershoek@baylibre.com \
--cc=glaroque@baylibre.com \
--cc=khilman@baylibre.com \
--cc=r.stratiienko@gmail.com \
--cc=sean.anderson@seco.com \
--cc=sjg@chromium.org \
--cc=souajih@baylibre.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.