Setting the baud rate of pre login prompt and post login prompt differently for a serial console

1

On a DragonBoard 410, I have connected a serial console to UART0.

If I want to see the kernel boot messages up to the login prompt, including LKs prints, I need to set a baud rate of 115200 on minicom, but as soon as the root login comes up I need to switch it to 57600.

This is causing me inconvenience.

How do I fix this to preserve this setting across boots?

yashC

Posted 2018-08-21T06:14:48.787

Reputation: 113

Answers

1

Linux uses the getty service to show console login prompts (and to reinitialize the ports). You need to specify the correct bitrate in the service's command line for each port. (If the system uses the standard util-linux agetty you may also add the --keep-baud option to avoid switching rates at all.)

How to do this depends on your Linux distribution (and which init system it uses):

  • If SysV init is being used, edit /etc/inittab. Find the line which mentions "ttyS0", add parameters to the end, then either reboot or live-reload the file with telinit q.

  • If systemd is being used, edit serial-getty@ttyS0.service. But you shouldn't need to, because the stock service file already specifies 115200,38400,9600 and even --keep-baud.

    (But if you do need to edit the unit file, use systemctl edit --full and adjust the ExecStart line. After saving and exiting, restart the service.)

    As a side note, make sure you're actually using serial-getty@.service (optimized for serial ports) and not the main getty@.service (optimized for local consoles).

  • If another init system is being used... see its documentation.

user1686

Posted 2018-08-21T06:14:48.787

Reputation: 283 655