[console speed] lock console speed to start up speed (#1734)

Auto negotiating console speed could cause sonic to lock on a wrong
speed under rare conditions. The only way to come out of the wrong
speed is to issue line break or restart console service with forced
speed, or reboot sonic.

Lock down the console speed to avoid these situations.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
This commit is contained in:
Ying Xie 2018-11-01 15:12:22 -07:00 committed by lguohan
parent a8fa7e4e43
commit 5cff136951

View File

@ -128,6 +128,19 @@ process_reboot_cause() {
echo "Unexpected reboot" > $REBOOT_CAUSE_FILE
}
program_console_speed()
{
speed=$(cat /proc/cmdline | grep -Eo 'console=ttyS[0-9]+,[0-9]+' | cut -d "," -f2)
if [ -z "$speed" ]; then
CONSOLE_SPEED=9600
else
CONSOLE_SPEED=$speed
fi
sed -i "s|\-\-keep\-baud .* %I| $CONSOLE_SPEED %I|g" /lib/systemd/system/serial-getty@.service
systemctl daemon-reload
}
#### Begin Main Body ####
# Set up previous and next reboot cause files
@ -209,6 +222,8 @@ fi
. /host/machine.conf
program_console_speed
if [ -f $FIRST_BOOT_FILE ]; then
echo "First boot detected. Performing first boot tasks..."