Bug 229976 - Make it easier to disable the serial console on arm
Summary: Make it easier to disable the serial console on arm
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: arm Any
: --- Affects Only Me
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-23 08:39 UTC by peo
Modified: 2022-06-28 08:24 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description peo 2018-07-23 08:39:26 UTC
The serial console is enabled by default on ARM for obvious reasons.
However, if you need the uart for other tasks, it is very complicated to disable the serial console when it is hardwired in more than one place.

I wish we could have something similar to Linux where you can just edit config.txt and cmdline.txt to achieve this.

This thread pretty much sums it up:
http://freebsd.1045724.x6.nabble.com/Adding-a-GPS-Module-hat-shield-on-a-Raspberry-Pi-td6236680.html
Comment 1 Jorge Schrauwen 2018-08-20 20:02:26 UTC
I am running into the same problem and made a tiny bit of progress on this.

echo 'hw.fdt.console="NO"' >> /boot/loader.conf.local

Will disable the serial console! uart0 aka /dev/cuau0 is now not used by the FreeBSD console. This of course still needs a u-boot compiled with nulldev for stdin, stdout, and stderr.

I came upon this undocumented (?) kernel tunable after a long search and someone mentioning on twitter to clear the fdt's /chosen/stdout-path entry.

Setting this tunable to a non existing device will also skip the hardcoded fallback. see /usr/src/sys/dev/uart/uart_cpu_fdt.c

This still results in a unusable /dev/cuau0 for me though I think it might be because 112500 buadrate is hardcoded in the PL011 driver. (Still looking into this.)

Hopefully this is of some use to someone.
Comment 2 peo 2018-08-20 20:43:55 UTC
I will try you tip, thank you.

The string 115200 (not 112500, probably a typo?) is found in many places in src and I think you may be right, for example 
sys/dev/uart/uart_dev_pl011.c:

        case UART_IOCTL_BAUD:
                *(int*)data = 115200;
                break;

However, I think the uart will ajust to your preferred speed if you ask it to, at least ntpd manages to set it to 9600 but then in my case the serial console interferred with the output from the GPS and made the result just gibberish.
Comment 3 Jorge Schrauwen 2018-08-20 20:59:53 UTC
Yes, that was a typo. I think that ioctl just returns the 'current set baudrate' to always be 115200 regardless of what it actually is.

I looked at the PL011 code a bit more, although I'm not that good at reading C I think it gets the speed it runs at from the FDT. So some patching there to set it to the one required might be needed. My GPS runs at 9600 so that is a bit problematic :(
Comment 4 Jorge Schrauwen 2018-12-16 12:13:02 UTC
After a lot more tinkering and some help on twitter...

the PL011 UART driver does NOT allow setting of baudrate when running on aarch64 on raspberry pi's... probably all devices that boot via u-boot.

If you just need a fixed baudrate you can work around it by having u-boot set it. If you need to switch it while in use, you seem to be out of luck.

Add the following to /boot/msdos/config.txt

init_baudrate="9600" 

I will file a followup ticket.