[PATCH v2 2/5] bootm: Append bootargs value when bootmeth_android provide cmdline
George Chan via B4 Relay
devnull+gchan9527.gmail.com at kernel.org
Sat Jun 7 07:24:57 CEST 2025
From: George Chan <gchan9527 at gmail.com>
Old logic wipe bootargs env with cmdline, new logic maintain the
value by prepending cmdline value to bootargs.
Signed-off-by: George Chan <gchan9527 at gmail.com>
---
boot/bootm.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/boot/bootm.c b/boot/bootm.c
index f6aa32746b7..888684a91f5 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1152,11 +1152,38 @@ int bootm_boot_start(ulong addr, const char *cmdline)
snprintf(addr_str, sizeof(addr_str), "%lx", addr);
- ret = env_set("bootargs", cmdline);
+ if (IS_ENABLED(CONFIG_ANDROID_BOOT_IMAGE_PREPEND_ENV_BOOTARGS)) {
+ char *bootargs;
+ char *newbootargs;
+ bootargs = env_get("bootargs");
+ ret = strlen(bootargs) + strlen(cmdline) + 2;
+
+ newbootargs = malloc(ret);
+
+ *newbootargs = '\0';
+
+ if (*newbootargs) /* If there is something in newbootargs, a space is needed */
+ strcat(newbootargs, " ");
+ strcat(newbootargs, cmdline);
+
+ if (*newbootargs) /* If there is something in newbootargs, a space is needed */
+ strcat(newbootargs, " ");
+ strcat(newbootargs, bootargs);
+
+ /* force to terminate the string */
+ memset(newbootargs + MAX_CMDLINE_SIZE - 2, '\0', 1);
+
+ ret = env_set("bootargs", newbootargs);
+
+ free(newbootargs);
+ } else
+ ret = env_set("bootargs", cmdline);
+
if (ret) {
printf("Failed to set cmdline\n");
return ret;
}
+
bootm_init(&bmi);
bmi.addr_img = addr_str;
bmi.cmd_name = "bootm";
--
2.43.0
More information about the U-Boot
mailing list