diff options
author | Tung Nguyen <tungnguyen@os.amperecomputing.com> | 2020-12-16 11:11:51 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2021-02-01 16:44:47 +0300 |
commit | 189431e93efb0dfd7efa69c40fead8bd11a9b01a (patch) | |
tree | d19f0718d725fc300e4a1fe3966f9f29469a6f04 /meta-ampere/meta-jade/recipes-phosphor/console/obmc-console | |
parent | 44cf8fd254c30e94cf4f0b90608bd9b6ef2ae292 (diff) | |
download | openbmc-189431e93efb0dfd7efa69c40fead8bd11a9b01a.tar.xz |
meta-ampere: Support solssh
Support solssh for Mt.Jade system.
It opens these ssh ports:
2200 - CPU console
2201 - SCP 0 concole
2202 - ATF console
2203 - SCP 1 console
Tested:
- connect to ssh ports
- make sure the console are displayed correctly
Signed-off-by: Tung Nguyen <tungnguyen@os.amperecomputing.com>
Change-Id: Ic0be980f201c0176ca00fd07804c101f404e707a
Diffstat (limited to 'meta-ampere/meta-jade/recipes-phosphor/console/obmc-console')
15 files changed, 246 insertions, 0 deletions
diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh new file mode 100755 index 000000000..58fffd8fe --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# Copyright (c) 2020 Ampere Computing LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Ampere Computing LLC: UART MUX/DEMUX for CPU0 UART0,1,4 and CPU1 UART1 +# Usage: ampere_uartmux_ctrl.sh <CPU UART port number> <UARTx_MODE> +# <UARTx_MODE> of 1 sets CPU To HDR_CONN +# <UARTx_MODE> of 2 sets BMC to CPU (eg dropbear ssh server on port 2200) + +if [ $# -lt 2 ]; then + exit 1 +fi + +function set_gpio_active_low() { + if [ $# -ne 2 ]; then + echo "set_gpio_active_low: need both GPIO# and initial level"; + return; + fi + + if [ ! -d /sys/class/gpio/gpio$1 ]; then + echo $1 > /sys/class/gpio/export + fi + echo $2 > /sys/class/gpio/gpio$1/direction +} + +GPIO_BASE=$(cat /sys/class/gpio/gpio*/base) + +case "$1" in + 1) GPIO_UARTx_MODE0=56 + # CPU0 UART0 connects to BMC UART1 + CONSOLE_PORT=0 + ;; + 2) GPIO_UARTx_MODE0=57 + # CPU0 UART1 connects to BMC UART2 + CONSOLE_PORT=1 + ;; + 3) GPIO_UARTx_MODE0=58 + # CPU0 UART4 connects to BMC UART3 + CONSOLE_PORT=2 + ;; + 4) GPIO_UARTx_MODE0=59 + # CPU1 UART1 connects to BMC UART4 + CONSOLE_PORT=3 + ;; + *) echo "Invalid UART port selection" + exit 1 + ;; +esac + +# Only switch the MUX when there is no active connection. This means we only +# switch the MUX before the first session starts and after the last session +# closes. We do this by querying number of connected sessions to the socket +# of requested console port. +# Example format: Accepted: 1; Connected: 1; +CONNECTED=$(systemctl --no-pager status obmc-console-ttyS${CONSOLE_PORT}-ssh.socket | grep -w Connected | cut -d ':' -f 3 | tr -d ' ;') +if [ ! $CONNECTED -le 1 ]; then + exit 0 +fi + +echo "Ampere UART MUX CTRL UART port $1 to mode $2" + +case "$2" in + 1) set_gpio_active_low $((${GPIO_BASE} + ${GPIO_UARTx_MODE0})) low + exit 0 + ;; + 2) set_gpio_active_low $((${GPIO_BASE} + ${GPIO_UARTx_MODE0})) high + exit 0 + ;; + *) echo "Invalid UART mode selection" + exit 1 + ;; +esac diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh new file mode 100644 index 000000000..fe2d5ab03 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh @@ -0,0 +1,42 @@ +#!/bin/sh -e +# +# Copyright (c) 2020 Ampere Computing LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euo pipefail + +tty="$1" +uart=0 + +case "${tty}" in + "ttyS0") uart=1 + ;; + "ttyS1") uart=2 + ;; + "ttyS2") uart=3 + ;; + "ttyS3") uart=4 + ;; + *) echo "Invalid tty passed to $0. Exiting!" + exit 1; + ;; +esac + +# Default the host routing through the mux to use the BMC (2) +# This allows the SoL console in webui, and the ssh port 2200, to work +# upon startup. If UART transcievers are installed on the header and required, +# this value should be set to 1 +/usr/sbin/ampere_uartmux_ctrl.sh ${uart} 2 + +/usr/sbin/obmc-console-server --config /etc/obmc-console/server.${tty}.conf ${tty} diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh.socket b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh.socket new file mode 100644 index 000000000..183a7a4f3 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh.socket @@ -0,0 +1,10 @@ +[Unit] +Description=Phosphor Host Console SSH Per-Connection socket +Wants=obmc-console@ttyS0.service + +[Socket] +ListenStream=2200 +Accept=yes + +[Install] +WantedBy=sockets.target diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh@.service b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh@.service new file mode 100644 index 000000000..f964454e0 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh@.service @@ -0,0 +1,12 @@ +[Unit] +Description=Phosphor Host Console SSH Per-Connection +Wants=obmc-console@ttyS0.service + +[Service] +Environment="DROPBEAR_RSAKEY_DIR=/etc/dropbear" +EnvironmentFile=/etc/default/dropbear +ExecStart=/usr/sbin/dropbear -i -r ${DROPBEAR_RSAKEY_DIR}/dropbear_rsa_host_key -c "/usr/bin/obmc-console-client -c /etc/obmc-console/server.ttyS0.conf" -p ttyS0 -F $DROPBEAR_EXTRA_ARGS +SyslogIdentifier=dropbear +ExecReload=/bin/kill -HUP $MAINPID +StandardInput=socket +KillMode=process diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS1-ssh.socket b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS1-ssh.socket new file mode 100644 index 000000000..bdbf56258 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS1-ssh.socket @@ -0,0 +1,10 @@ +[Unit] +Description=Phosphor Host Console SSH Per-Connection socket +Wants=obmc-console@ttyS1.service + +[Socket] +ListenStream=2201 +Accept=yes + +[Install] +WantedBy=sockets.target diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS1-ssh@.service b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS1-ssh@.service new file mode 100644 index 000000000..697c24271 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS1-ssh@.service @@ -0,0 +1,12 @@ +[Unit] +Description=Phosphor Host Console SSH Per-Connection +Wants=obmc-console@ttyS1.service + +[Service] +Environment="DROPBEAR_RSAKEY_DIR=/etc/dropbear" +EnvironmentFile=/etc/default/dropbear +ExecStart=/usr/sbin/dropbear -i -r ${DROPBEAR_RSAKEY_DIR}/dropbear_rsa_host_key -c "/usr/bin/obmc-console-client -c /etc/obmc-console/server.ttyS1.conf" -p ttyS1 -F $DROPBEAR_EXTRA_ARGS +SyslogIdentifier=dropbear +ExecReload=/bin/kill -HUP $MAINPID +StandardInput=socket +KillMode=process diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS2-ssh.socket b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS2-ssh.socket new file mode 100644 index 000000000..f8934fd41 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS2-ssh.socket @@ -0,0 +1,10 @@ +[Unit] +Description=Phosphor Host Console SSH Per-Connection socket +Wants=obmc-console@ttyS2.service + +[Socket] +ListenStream=2202 +Accept=yes + +[Install] +WantedBy=sockets.target diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS2-ssh@.service b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS2-ssh@.service new file mode 100644 index 000000000..7d7f31490 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS2-ssh@.service @@ -0,0 +1,12 @@ +[Unit] +Description=Phosphor Host Console SSH Per-Connection +Wants=obmc-console@ttyS2.service + +[Service] +Environment="DROPBEAR_RSAKEY_DIR=/etc/dropbear" +EnvironmentFile=/etc/default/dropbear +ExecStart=/usr/sbin/dropbear -i -r ${DROPBEAR_RSAKEY_DIR}/dropbear_rsa_host_key -c "/usr/bin/obmc-console-client -c /etc/obmc-console/server.ttyS2.conf" -p ttyS2 -F $DROPBEAR_EXTRA_ARGS +SyslogIdentifier=dropbear +ExecReload=/bin/kill -HUP $MAINPID +StandardInput=socket +KillMode=process diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS3-ssh.socket b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS3-ssh.socket new file mode 100644 index 000000000..fd7f3e3f9 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS3-ssh.socket @@ -0,0 +1,10 @@ +[Unit] +Description=Phosphor Host Console SSH Per-Connection socket +Wants=obmc-console@ttyS3.service + +[Socket] +ListenStream=2203 +Accept=yes + +[Install] +WantedBy=sockets.target diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS3-ssh@.service b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS3-ssh@.service new file mode 100644 index 000000000..261f3a12e --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS3-ssh@.service @@ -0,0 +1,12 @@ +[Unit] +Description=Phosphor Host Console SSH Per-Connection +Wants=obmc-console@ttyS3.service + +[Service] +Environment="DROPBEAR_RSAKEY_DIR=/etc/dropbear" +EnvironmentFile=/etc/default/dropbear +ExecStart=/usr/sbin/dropbear -i -r ${DROPBEAR_RSAKEY_DIR}/dropbear_rsa_host_key -c "/usr/bin/obmc-console-client -c /etc/obmc-console/server.ttyS3.conf" -p ttyS3 -F $DROPBEAR_EXTRA_ARGS +SyslogIdentifier=dropbear +ExecReload=/bin/kill -HUP $MAINPID +StandardInput=socket +KillMode=process diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console@.service b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console@.service new file mode 100644 index 000000000..22a5df269 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console@.service @@ -0,0 +1,17 @@ +[Unit] +Description=Phosphor Console Muxer listening on device /dev/%I +BindsTo=dev-%i.device +After=dev-%i.device +StartLimitBurst=3 +StartLimitIntervalSec=300 + +[Service] +ExecStart=/usr/sbin/obmc-console-server-setup.sh %i +SyslogIdentifier=obmc-console-server +Restart=always +RestartSec=10 +TimeoutStartSec=60 +TimeoutStopSec=60 + +[Install] +WantedBy=multi-user.target diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS0.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS0.conf new file mode 100644 index 000000000..2d02a5138 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS0.conf @@ -0,0 +1,3 @@ +local-tty = ttyS0 +local-tty-baud = 115200 +logfile = /var/log/obmc-console-cpu.log diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS1.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS1.conf new file mode 100644 index 000000000..a77188412 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS1.conf @@ -0,0 +1,4 @@ +local-tty = ttyS1 +local-tty-baud = 115200 +socket-id = ttyS1 +logfile = /var/log/obmc-console-scp0.log diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS2.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS2.conf new file mode 100644 index 000000000..7ac6953e4 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS2.conf @@ -0,0 +1,4 @@ +local-tty = ttyS2 +local-tty-baud = 115200 +socket-id = ttyS2 +logfile = /var/log/obmc-console-atf.log diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS3.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS3.conf new file mode 100644 index 000000000..0ec1b693b --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/server.ttyS3.conf @@ -0,0 +1,4 @@ +local-tty = ttyS3 +local-tty-baud = 115200 +socket-id = ttyS3 +logfile = /var/log/obmc-console-scp1.log |