[PATCH] boot: Pass baud rate to stdout-path
Mark Kettenis
mark.kettenis at xs4all.nl
Thu Apr 11 17:11:46 CEST 2024
> From: John Watts <contact at jookia.org>
> Date: Thu, 11 Apr 2024 15:03:20 +1000
>
> Linux might use the wrong baud rate such as 9600 by default, make sure
> to specify it when passing the serial port over.
>
> Signed-off-by: John Watts <contact at jookia.org>
> ---
> On my board at least (a sunxi T113) the serial console will initialize
> as 9600 baud instead of the set baud. Pass the baud with the serial
> device to Linux to solve this issue.
You probably should fix this by making sure the device tree you're
using has the appropriate stdout-path node. Because I think the
functionality you're trying to use here is deprecated:
* The linux,stdout-path property has been superseded by the
stdout-path property.
* The description of the OF_STDOUT_VIA_ALIAS option suggests that it
is seprecated as well:
This option currently references CONFIG_CONS_INDEX, which is
incorrect when used with device tree as this option does not
exist / should not be used.
It just happens that sunxi is one of the few remaining "modenr"
platforms that still uses CONFIG_CONS_INDEX.
That said, the diff is interesting. To me it doesn't really make
sense that you can change the serial port and its parameters in
U-Boot, but that this choice doesn't always make it into the device
tree that is passed to the OS.
A particular case that I'm dealing with is the default speed of
1500000 that the various Rockchip SoCs use. This doesn't work with
many of the USB-to-serial interfaces on the market and is also rather
susceptible to line noise. So for OpenBSD packages I've decide to use
115200 instead. But that means I have to patch all the device trees
in addition to changing the CONFIG_BAUDRATE setting. If U-Boot would
tweak the stdout-path property based on CONFIG_BAUDRATE that would
make things easier.
Cheers,
Mark
> ---
> boot/fdt_support.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/boot/fdt_support.c b/boot/fdt_support.c
> index 090d82ee80..83e62f47b5 100644
> --- a/boot/fdt_support.c
> +++ b/boot/fdt_support.c
> @@ -153,9 +153,9 @@ static int fdt_fixup_stdout(void *fdt, int chosenoff)
> }
>
> /* fdt_setprop may break "path" so we copy it to tmp buffer */
> - memcpy(tmp, path, len);
> + len = sprintf(tmp, "%.*s:%d", len, (char *)path, CONFIG_BAUDRATE);
>
> - err = fdt_setprop(fdt, chosenoff, "linux,stdout-path", tmp, len);
> + err = fdt_setprop(fdt, chosenoff, "linux,stdout-path", tmp, len + 1);
> if (err < 0)
> printf("WARNING: could not set linux,stdout-path %s.\n",
> fdt_strerror(err));
>
> ---
> base-commit: 777c28460947371ada40868dc994dfe8537d7115
> change-id: 20240411-stdout-4f91b566a0f2
>
> Best regards,
> --
> John Watts <contact at jookia.org>
>
>
More information about the U-Boot
mailing list