From 876b03102d6ebc39728e44a9418e525f4973c68b Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 31 Oct 2018 23:48:15 +0000 Subject: [PATCH] [console speed] lock console speed to start up speed 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 --- files/image_config/platform/rc.local | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 0db4278932f6..acac42e326e1 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -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..."