[PATCH v2 3/5] fdt_support: Add support for extra var for bootargs
George Chan via B4 Relay
devnull+gchan9527.gmail.com at kernel.org
Mon May 5 11:17:11 CEST 2025
From: George Chan <gchan9527 at gmail.com>
Introduce a new env var 'legacy_os_boot_param' to hold legacy OS
dependent boot param.
Signed-off-by: George Chan <gchan9527 at gmail.com>
---
boot/Kconfig | 9 +++++++++
boot/fdt_support.c | 20 +++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/boot/Kconfig b/boot/Kconfig
index 4bdac384181..80bb2eb7e77 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -17,6 +17,15 @@ config ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR
help
This ignore kernel/ramdisk load addr specified in androidboot header.
+config SUPPORT_LEGACY_OS_BOOTPARAM
+ bool "Extra var to append bootargs"
+ default n
+ help
+ This introduce env_var 'legacy_os_boot_param' to hold extra OS
+ dependent kernel boot param, and append to fdt bootargs when bootm
+ execute. The value is supposed to obtain from env file at compile time.
+ Board dependent callback will override it completely.
+
config TIMESTAMP
bool "Show image date and time when displaying image information"
default y if CMD_DATE
diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index 92f2f534ee0..cc4d808eaf1 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -322,9 +322,27 @@ int fdt_kaslrseed(void *fdt, bool overwrite)
* board_fdt_chosen_bootargs - boards may override this function to use
* alternative kernel command line arguments
*/
+#define COMMAND_LINE_SIZE 1024
+static char bootargs[COMMAND_LINE_SIZE] = { 0 };
__weak const char *board_fdt_chosen_bootargs(const struct fdt_property *fdt_ba)
{
- return env_get("bootargs");
+ if (IS_ENABLED(CONFIG_SUPPORT_LEGACY_OS_BOOTPARAM)) {
+ int j;
+ snprintf(bootargs, COMMAND_LINE_SIZE - 2, "%s %s",
+ env_get("bootargs"),
+ env_get("legacy_os_boot_param"));
+
+ /* remove all carriage return */
+ for (j = 0; j < COMMAND_LINE_SIZE; j++) {
+ if (bootargs[j] == '\0')
+ break;
+
+ if ((bootargs[j] == '\n') || (bootargs[j] == '\r'))
+ bootargs[j] = ' ';
+ }
+ return bootargs;
+ } else
+ return env_get("bootargs");
}
int fdt_chosen(void *fdt)
--
2.43.0
More information about the U-Boot
mailing list