All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: "Guillaume La Roque (TI.com)" <glaroque@baylibre.com>,
	Tom Rini <trini@konsulko.com>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>
Cc: Julien Masson <jmasson@baylibre.com>,
	Guillaume La Roque <glaroque@baylibre.com>,
	u-boot@lists.denx.de, Simon Glass <sjg@chromium.org>,
	Nicolas Belin <nbelin@baylibre.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Andrew Goodbody <andrew.goodbody@linaro.org>,
	Aaron Kling <webgeek1234@gmail.com>,
	George Chan <gchan9527@gmail.com>, Sam Day <me@samcday.com>,
	Jerome Forissier <jerome.forissier@linaro.org>,
	Maxime Fournier <mfournier@baylibre.com>
Subject: Re: [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP
Date: Fri, 31 Oct 2025 16:39:22 +0100	[thread overview]
Message-ID: <87ikfv5bdh.fsf@kernel.org> (raw)
In-Reply-To: <20251017-bootconfig-v2-1-8c7c2f2e5474@baylibre.com>

Hi Guillaume,

Thank you for the patch.

On Fri, Oct 17, 2025 at 15:19, "Guillaume La Roque (TI.com)" <glaroque@baylibre.com> wrote:

> From: "Mattijs Korpershoek (TI.com)" <mkorpershoek@kernel.org>
>
> To properly implement Android boot image v4, U-Boot must be able to
> add additional entries to the bootconfig.
>
> Add `add_bootconfig_parameters()` to do so.
>
> This has been imported from Google's U-Boot source[1]
> The variables/function names have been reworked to be
> compliant with U-Boot's coding style.
>
> [1] https://android.googlesource.com/platform/external/u-boot/+/7af0a0506d4de6f5ea147d10fb0664a8af07d326
> Signed-off-by: Mattijs Korpershoek (TI.com) <mkorpershoek@kernel.org>
> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---
>  boot/image-android.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>
> diff --git a/boot/image-android.c b/boot/image-android.c
> index e46dee0d9b3..3a0a934acc7 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -57,6 +57,44 @@ static ulong add_trailer(ulong bootconfig_start_addr, ulong bootconfig_size)
>  	return BOOTCONFIG_TRAILER_SIZE;
>  }
>  
> +/*
> + * Add a string of boot config parameters to memory appended by the trailer.
> + * NOTE: This function expects bootconfig_start_addr to be already mapped.
> + *       It works directly with the mapped pointer, not a physical address.
> + */
> +u32 add_bootconfig_parameters(char *params, ulong params_size,
> +			      ulong bootconfig_start_addr, u32 bootconfig_size)
> +{
> +	if (!params || !bootconfig_start_addr)
> +		return -1;
> +
> +	if (params_size == 0)
> +		return 0;
> +
> +	u32 applied_bytes = 0;
> +	u32 new_size = 0;
> +	ulong end = bootconfig_start_addr + bootconfig_size;
> +
> +	if (is_trailer_present(end)) {
> +		end -= BOOTCONFIG_TRAILER_SIZE;
> +		applied_bytes -= BOOTCONFIG_TRAILER_SIZE;
> +		memcpy(&new_size, (void *)end, BOOTCONFIG_SIZE_SIZE);
> +	} else {
> +		/*
> +		 * When no trailer is present, the bootconfig_size includes the actual content.
> +		 * We should write new parameters right after the existing content.
> +		 */
> +		end = bootconfig_start_addr + bootconfig_size;
> +		new_size = bootconfig_size;
> +	}
> +
> +	memcpy((void *)end, params, params_size);
> +	applied_bytes += params_size;
> +	applied_bytes += add_trailer(bootconfig_start_addr,
> +				     bootconfig_size + applied_bytes);
> +	return applied_bytes;
> +}
> +
>  __weak ulong get_avendor_bootimg_addr(void)
>  {
>  	return -1;
>
> -- 
> 2.34.1

  reply	other threads:[~2025-10-31 15:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17 13:19 [PATCH v2 0/5] android: add bootconfig support Guillaume La Roque (TI.com)
2025-10-17 13:19 ` [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP Guillaume La Roque (TI.com)
2025-10-31 15:39   ` Mattijs Korpershoek [this message]
2025-10-17 13:19 ` [PATCH v2 2/5] boot: android: Add sandbox memory mapping support Guillaume La Roque (TI.com)
2025-10-31 15:49   ` Mattijs Korpershoek
2025-10-17 13:19 ` [PATCH v2 3/5] boot: android: Add bootconfig support Guillaume La Roque (TI.com)
2025-10-31 15:58   ` Mattijs Korpershoek
2025-11-03 18:52     ` Guillaume La Roque
2025-11-07 14:52       ` Mattijs Korpershoek
2025-10-17 13:19 ` [PATCH v2 4/5] cmd: abootimg: Add 'get ramdisk' command Guillaume La Roque (TI.com)
2025-10-31 16:13   ` Mattijs Korpershoek
2025-10-17 13:19 ` [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling Guillaume La Roque (TI.com)
2025-10-19 13:06   ` Simon Glass
2025-10-19 16:01     ` Tom Rini
2025-10-20  5:18       ` Simon Glass
2025-10-24 15:09         ` Guillaume La Roque
2025-10-24 15:20           ` Tom Rini
2025-10-31 16:27   ` Mattijs Korpershoek
2025-11-05 18:14     ` Guillaume La Roque
2025-11-07 14:52       ` Mattijs Korpershoek
2025-10-18  6:07 ` [PATCH v2 0/5] android: add bootconfig support george chan
2025-10-20 13:58   ` Guillaume La Roque
2025-10-20 15:45     ` george chan

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=87ikfv5bdh.fsf@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=andrew.goodbody@linaro.org \
    --cc=gchan9527@gmail.com \
    --cc=glaroque@baylibre.com \
    --cc=jerome.forissier@linaro.org \
    --cc=jmasson@baylibre.com \
    --cc=me@samcday.com \
    --cc=mfournier@baylibre.com \
    --cc=nbelin@baylibre.com \
    --cc=neil.armstrong@linaro.org \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=webgeek1234@gmail.com \
    /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.