* [PATCH] boot: Pass baud rate to stdout-path
@ 2024-04-11 5:03 John Watts
2024-04-11 15:11 ` Mark Kettenis
0 siblings, 1 reply; 3+ messages in thread
From: John Watts @ 2024-04-11 5:03 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot, John Watts
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@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.
---
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@jookia.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] boot: Pass baud rate to stdout-path
2024-04-11 5:03 [PATCH] boot: Pass baud rate to stdout-path John Watts
@ 2024-04-11 15:11 ` Mark Kettenis
2024-04-11 21:03 ` John Watts
0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2024-04-11 15:11 UTC (permalink / raw)
To: John Watts; +Cc: trini, u-boot, contact
> From: John Watts <contact@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@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@jookia.org>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] boot: Pass baud rate to stdout-path
2024-04-11 15:11 ` Mark Kettenis
@ 2024-04-11 21:03 ` John Watts
0 siblings, 0 replies; 3+ messages in thread
From: John Watts @ 2024-04-11 21:03 UTC (permalink / raw)
To: Mark Kettenis; +Cc: trini, u-boot
On Thu, Apr 11, 2024 at 05:11:46PM +0200, Mark Kettenis wrote:
> 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:
Hi Mark,
Interesting, I'll go with that approach instead.
> ...
>
> 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.
That's an interesting use case! Would you mind testing this patch if possible?
> Cheers,
>
> Mark
John.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-11 21:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-11 5:03 [PATCH] boot: Pass baud rate to stdout-path John Watts
2024-04-11 15:11 ` Mark Kettenis
2024-04-11 21:03 ` John Watts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox