Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Use the baud rate given on the cmdline for getty #701

Merged
merged 2 commits into from
Aug 21, 2021

Conversation

jbro
Copy link
Contributor

@jbro jbro commented May 14, 2021

Don't just default to 9600 Baud on serial consoles when given one with options on the Linux kernel command line.

Should work with the format given onhttps://www.kernel.org/doc/html/latest/admin-guide/serial-console.html

Don't just default to 9600 Baud on serial consoles when given one with
options on the Linux kernel commandline.

Should work with the format given on
https://www.kernel.org/doc/html/latest/admin-guide/serial-console.html
IFS=, read TTY BAUDRATE _ <<<"${CONSOLE_SPEC}"

if [ -n "$BAUDRATE" ]; then
BAUDRATE=$(grep -o '^[0-9]*' <<< "$BAUDRATE")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this restricting BAUDRATE to be only numbers? If so, I think this should support stuff like 9600n8 (like described in the kernel page you've linked).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for only matching the numbers is that getty only expects numbers as the parameter where $BAUDRATE is used. As far as I can tell from the manual, getty is able to infer stop bits, checksum etc.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFICT the serial port has no auto-negotiation feature, so I'm now wondering how it does that magic!

Copy link
Contributor Author

@jbro jbro Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, getty only has a flag for "assume 8bit clean", it doesn't have a flag for 7bit with odd, even, none or space parity, so maybe it guesses and things just work. Anyway, the patch still makes things better, even if it assumes 8bit. In my case I was using a machine with coreboot hard-coded to 115200 baud, meaning I had to start my term with that baud rate, and switch to 9600 when the kernel started to see a complete boot log.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it does, no doubt about that :-)

Coreboot? Woah! What machine do you have? I've very curious who is using coreboot :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an https://pcengines.ch/apu2c4.htm, it's a very nice machine I can only recommend them :-)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I've been looking at the apu4d4 model, but I still can't justify getting one eheh

@dweomer dweomer merged commit 1fa8606 into rancher:master Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants