Skip to content

Commit

Permalink
[console speed] Inherit console speed from install environment (#1987)
Browse files Browse the repository at this point in the history
* pick up console speed from install enviroment

* get console speed from /proc/cmdline

* add CONSOLE_PORT handle
  • Loading branch information
keboliu authored and lguohan committed Sep 1, 2018
1 parent 14a0b8c commit fd5a3cf
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions installer/x86_64/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ fi

echo "onie_platform: $onie_platform"

# default console settings
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
CONSOLE_SPEED=9600

# Get platform specific linux kernel command line arguments
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX=""

Expand All @@ -77,6 +72,36 @@ VAR_LOG_SIZE=4096

[ -r platforms/$onie_platform ] && . platforms/$onie_platform

# Pick up console port and speed from install enviroment if not defined yet.
# Console port and speed setting in cmdline is like "console=ttyS0,9600n",
# so we can use pattern 'console=ttyS[0-9]+,[0-9]+' to match it.
# If failed to get the speed and ttyS from cmdline then set them to default: ttyS0 and 9600
if [ -z "$CONSOLE_PORT" ]; then
console_ttys=$(cat /proc/cmdline | grep -Eo 'console=ttyS[0-9]+' | cut -d "=" -f2)
if [ -z "$console_ttys" -o "$console_ttys" = "ttyS0" ]; then
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
elif [ "$console_ttys" = "ttyS1" ]; then
CONSOLE_PORT=0x2f8
CONSOLE_DEV=1
elif [ "$console_ttys" = "ttyS2" ]; then
CONSOLE_PORT=0x3e8
CONSOLE_DEV=2
elif [ "$console_ttys" = "ttyS3" ]; then
CONSOLE_PORT=0x2e8
CONSOLE_DEV=3
fi
fi

if [ -z "$CONSOLE_SPEED" ]; then
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
fi

# Install demo on same block device as ONIE
if [ "$install_env" != "build" ]; then
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
Expand Down

0 comments on commit fd5a3cf

Please sign in to comment.