[PATCH 3/3] common: fdt: hand over original fdt bootargs into board chosen handler

Tom Rini trini at konsulko.com
Thu Jan 16 20:11:25 CET 2025


On Thu, Jan 16, 2025 at 04:11:40PM +0300, Dmitry Rokosov wrote:
> Hello Quentin,
> 
> On Tue, Jan 14, 2025 at 12:16:35PM +0100, Quentin Schulz wrote:
> > Hi Dmitry,
> > 
> > On 12/19/24 10:42 PM, Dmitry Rokosov wrote:
> > > 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.
> > > 
> > 
> > Can't you have both in bootargs to handle both versions of the kernel with
> > the same bootargs?
> > 
> 
> In this case, modifying the kernel source code is necessary, which falls
> outside the scope of this review.
> 
> > > 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
> > > + *
> > 
> > Missing leading /
> > 
> > /chosen/bootargs
> > 
> > +property
> > to highlight what this path refers to.
> > 
> 
> Agree with that, but looks like patch series is already applied...
> Sorry..

I saw that and made those changes in the merge commit.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20250116/b94b10ec/attachment-0001.sig>


More information about the U-Boot mailing list