[PATCH 3/3] common: fdt: hand over original fdt bootargs into board chosen handler
Dmitry Rokosov
ddrokosov at salutedevices.com
Thu Dec 19 22:42:10 CET 2024
Sometimes, it is necessary to provide an additional bootargs string to
the kernel command line.
We have a real scenario where one U-Boot blob needs to boot several
kernel images: the vendor-patched kernel image and the latest upstream
kernel image. The Amlogic (Meson architecture) tty driver has different
tty suffixes in these kernels: the vendor uses 'ttySx', while the
upstream implementation uses 'ttyAMLx'. The initial console setup is
provided to the kernel using the kernel command line (bootargs). For the
vendor kernel, we should use 'console=ttyS0,115200', while for the
upstream kernel, it must be 'console=ttyAML0,115200'. This means we have
to use different command line strings depending on the kernel version.
To resolve this issue, we cannot use the CMDLINE_EXTEND kernel
configuration because it is considered legacy and is not supported for
the arm64 architecture. CMDLINE_EXTEND is outdated primarily because we
can provide additional command line strings through the
'chosen/bootargs' FDT node. However, U-Boot uses this node to inject the
U-Boot bootargs environment variable content, which results in U-Boot
silently overriding all data in the 'chosen/bootargs' node. While we do
have the board_fdt_chosen_bootargs() board hook to address such issues,
this function lacks any FDT context, such as the original value of the
'chosen/bootargs' node.
This patch introduces a read-only (RO) fdt_property argument to
board_fdt_chosen_bootargs() to share the original 'chosen/bootargs' data
with the board code. Consequently, the board developer can decide how to
handle this information for their board setup: whether to drop it or
merge it with the bootargs environment.
Signed-off-by: Dmitry Rokosov <ddrokosov at salutedevices.com>
---
boot/fdt_support.c | 5 +++--
include/fdt_support.h | 4 +++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index 2c39b2dd14b7c447bc4c7c8fad64e22cb00e88e0..49efeec3681f7c97341ccdce596bcaa4e1f037eb 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -321,7 +321,7 @@ int fdt_kaslrseed(void *fdt, bool overwrite)
* board_fdt_chosen_bootargs - boards may override this function to use
* alternative kernel command line arguments
*/
-__weak const char *board_fdt_chosen_bootargs(void)
+__weak const char *board_fdt_chosen_bootargs(const struct fdt_property *fdt_ba)
{
return env_get("bootargs");
}
@@ -364,7 +364,8 @@ int fdt_chosen(void *fdt)
}
}
- str = board_fdt_chosen_bootargs();
+ str = board_fdt_chosen_bootargs(fdt_get_property(fdt, nodeoffset,
+ "bootargs", NULL));
if (str) {
err = fdt_setprop(fdt, nodeoffset, "bootargs", str,
diff --git a/include/fdt_support.h b/include/fdt_support.h
index f481881ce640797e0f6204d599f008d0e5dc2bf7..7731feba5f068f82c8ee25f18a9f0e57729e2bd8 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -231,12 +231,14 @@ int board_rng_seed(struct abuf *buf);
/**
* board_fdt_chosen_bootargs() - arbitrarily amend fdt kernel command line
*
+ * @fdt_ba: FDT chosen/bootargs from the kernel image if available
+ *
* This is used for late modification of kernel command line arguments just
* before they are added into the /chosen node in flat device tree.
*
* Return: pointer to kernel command line arguments in memory
*/
-const char *board_fdt_chosen_bootargs(void);
+const char *board_fdt_chosen_bootargs(const struct fdt_property *fdt_ba);
/*
* The keystone2 SOC requires all 32 bit aliased addresses to be converted
--
2.43.0
More information about the U-Boot
mailing list