From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: George Chan via B4 Relay <devnull+gchan9527.gmail.com@kernel.org>,
Tom Rini <trini@konsulko.com>,
Casey Connolly <casey.connolly@linaro.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Sumit Garg <sumit.garg@kernel.org>,
Simon Glass <sjg@chromium.org>,
Mattijs Korpershoek <mkorpershoek@kernel.org>,
Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>
Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io, gchan9527@gmail.com
Subject: Re: [PATCH v2 1/5] image-android: Prepend/postpend default bootargs value with given bootcmd
Date: Thu, 12 Jun 2025 09:19:09 +0200 [thread overview]
Message-ID: <87wm9ha0lu.fsf@kernel.org> (raw)
In-Reply-To: <20250607-sc7180-android-boot-v2-1-2df5d7f61124@gmail.com>
Hi George,
Thank you for the patch.
I have a couple of small remarks on wording/spelling but the code
change looks good already.
On Sat, Jun 07, 2025 at 13:24, George Chan via B4 Relay <devnull+gchan9527.gmail.com@kernel.org> wrote:
> From: George Chan <gchan9527@gmail.com>
>
> Control how default bootargs is prepended or postpended to boot param found
> from androidboot img.
Let's rephrase to be slightly more accurate, and add a problem statement
first:
By default, the boot.img's cmdline are appended to the bootargs
environment.
If we take a cmdline example of:
* androidboot.hardware=warm (in U-Boot environment)
* androidboot.hardware=chilly (in boot.img's cmdline)
The resulting commandline will be:
androidboot.hardware=warm [...] androidboot.hardware=chilly.
Because of this, the U-Boot environment always take priority on the
boot.img.
If we want to have a single U-Boot binary that support multiple
board variants, we can't override androidboot.hardware via the boot.img.
Add a new Kconfig option, ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS that
reverse the logic.
with ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS=y, the resulting
commandline would be:
androidboot.hardware=chilly [...] androidboot.hardware=warm.
(feel free to rephrase some parts to your liking)
>
> Signed-off-by: George Chan <gchan9527@gmail.com>
> ---
> boot/Kconfig | 7 +++++++
> boot/image-android.c | 10 ++++++++--
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/boot/Kconfig b/boot/Kconfig
> index 30eb5b328d7..7b71a340620 100644
> --- a/boot/Kconfig
> +++ b/boot/Kconfig
> @@ -11,6 +11,13 @@ config ANDROID_BOOT_IMAGE
> This enables support for booting images which use the Android
> image format header.
>
> +config ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS
> + bool "Android Boot Image boot cmd param will prepend to env bootargs"
> + help
> + This control how androidboot img with bootcmd param integrate with u-boot
Please, no abbreviations and some minor spelling tweaks:
This controls how Android boot image embedded cmdline integrates
with U-Boot bootargs environment.
By enabling this, the boot.img's cmdline is prepended to the bootargs
environment. By default, when disabled, the cmdline is appended.
(Note: We use cmdline here since that's the terminology used by
Android's mkbootimg tool [1])
[1] https://android.googlesource.com/platform/system/tools/mkbootimg/+/refs/heads/main/mkbootimg.py#511
With the wording fixed, please add
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Also, Casey, feel free to pick of the reworded version through your tree !
> + env bootargs. By enable this, androidboot boot param will prepend to
> + head of bootargs env.
> +
> config TIMESTAMP
> bool "Show image date and time when displaying image information"
> default y if CMD_DATE
> diff --git a/boot/image-android.c b/boot/image-android.c
> index 1746b018900..fbcd2682a5e 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -347,14 +347,14 @@ int android_image_get_kernel(const void *hdr,
> len += strlen(img_data.kcmdline_extra) + (len ? 1 : 0); /* +1 for extra space */
> }
>
> - char *newbootargs = malloc(len + 1); /* +1 for the '\0' */
> + char *newbootargs = malloc(len + 2); /* +2 for 2x '\0' */
> if (!newbootargs) {
> puts("Error: malloc in android_image_get_kernel failed!\n");
> return -ENOMEM;
> }
> *newbootargs = '\0'; /* set to Null in case no components below are present */
>
> - if (bootargs)
> + if (bootargs && !IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS))
> strcpy(newbootargs, bootargs);
>
> if (img_data.kcmdline && *img_data.kcmdline) {
> @@ -369,6 +369,12 @@ int android_image_get_kernel(const void *hdr,
> strcat(newbootargs, img_data.kcmdline_extra);
> }
>
> + if (bootargs && IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS)) {
> + if (*newbootargs) /* If there is something in newbootargs, a space is needed */
> + strcat(newbootargs, " ");
> + strcat(newbootargs, bootargs);
> + }
> +
> env_set("bootargs", newbootargs);
> free(newbootargs);
>
>
> --
> 2.43.0
next prev parent reply other threads:[~2025-06-12 7:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-07 5:24 [PATCH v2 0/5] A series of patch for enable sc7180 android boot George Chan via B4 Relay
2025-06-07 5:24 ` [PATCH v2 1/5] image-android: Prepend/postpend default bootargs value with given bootcmd George Chan via B4 Relay
2025-06-12 7:19 ` Mattijs Korpershoek [this message]
2025-06-07 5:24 ` [PATCH v2 2/5] bootm: Append bootargs value when bootmeth_android provide cmdline George Chan via B4 Relay
2025-06-07 5:24 ` [PATCH v2 3/5] boot: bootmeth_android: Conditionally dependent on abootimg George Chan via B4 Relay
2025-06-12 7:35 ` Mattijs Korpershoek
2025-06-07 5:24 ` [PATCH v2 4/5] iommu: qcom-smmu: Introduce sc7180 compatible string George Chan via B4 Relay
2025-06-07 5:25 ` [PATCH v2 5/5] usb: gadget: Introduce usb gadget vendor/product default id for ARCH_QCOM George Chan via B4 Relay
2025-06-12 7:24 ` Mattijs Korpershoek
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=87wm9ha0lu.fsf@kernel.org \
--to=mkorpershoek@kernel.org \
--cc=casey.connolly@linaro.org \
--cc=devnull+gchan9527.gmail.com@kernel.org \
--cc=gchan9527@gmail.com \
--cc=lukma@denx.de \
--cc=marex@denx.de \
--cc=neil.armstrong@linaro.org \
--cc=sjg@chromium.org \
--cc=sumit.garg@kernel.org \
--cc=trini@konsulko.com \
--cc=u-boot-qcom@groups.io \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox