boot: Pass baud rate to stdout-path
PATCH 1/1 boot: Pass baud rate to stdout-path
Linux might use the wrong baud rate such as 9600 by default, make sure to specify it when passing the serial port over.
---
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(-)
boot/fdt_support.c +2 -2
@@ -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,
Signature · 1 line
John Watts <[email protected]>
Quoted 11 lines
From: John Watts <[email protected]>
Date: Thu, 11 Apr 2024 15:03:20 +1000Linux 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 <[email protected]>---
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
Quoted 30 lines
--- boot/fdt_support.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)boot/fdt_support.c +2
-3@@ -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-4f91b566a0f2Best regards,
Signature · 1 line
John Watts <[email protected]>
Quoted 3 lines · Mark Kettenis
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.
Quoted 10 lines
...
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_BAUDRATEsetting. If U-Boot would tweak the stdout-path property based onCONFIG_BAUDRATEthat would make things easier.
That's an interesting use case! Would you mind testing this patch if possible?
Quoted 3 lines
Cheers,
Mark
John.