summaryrefslogtreecommitdiff
path: root/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console
diff options
context:
space:
mode:
Diffstat (limited to 'meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console')
-rw-r--r--meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh47
-rw-r--r--meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh27
-rw-r--r--meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh.socket10
-rw-r--r--meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh@.service12
-rw-r--r--meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console@.service17
-rw-r--r--meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/server.ttyS0.conf3
-rw-r--r--meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/server.ttyS1.conf4
7 files changed, 120 insertions, 0 deletions
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh
new file mode 100644
index 0000000000..387cfcf92c
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# shellcheck disable=SC2046
+
+if [ $# -lt 2 ]; then
+ exit 1
+fi
+
+case "$1" in
+ 1) GPIO_UARTx_MODE0="uart1-mode0"
+ GPIO_UARTx_MODE1="uart1-mode1"
+ # CPU0 UART0 connects to BMC UART1
+ CONSOLE_PORT=0
+ ;;
+ *) 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
+ echo "Please close all connected session to ttyS${CONSOLE_PORT} !"
+ exit 0
+fi
+
+echo "Ampere UART MUX CTRL UART port $1 to mode $2"
+
+case "$2" in
+ # To HDR
+ 1) gpioset $(gpiofind "$GPIO_UARTx_MODE0")=1
+ gpioset $(gpiofind "$GPIO_UARTx_MODE1")=0
+ exit 0
+ ;;
+ # To BMC
+ 2) gpioset $(gpiofind "$GPIO_UARTx_MODE0")=0
+ gpioset $(gpiofind "$GPIO_UARTx_MODE1")=1
+ exit 0
+ ;;
+ *) echo "Invalid UART mode selection"
+ exit 1
+ ;;
+esac
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh
new file mode 100644
index 0000000000..763161a24c
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh
@@ -0,0 +1,27 @@
+#!/bin/sh -e
+
+
+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-mitchell/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh.socket b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh.socket
new file mode 100644
index 0000000000..183a7a4f3c
--- /dev/null
+++ b/meta-ampere/meta-mitchell/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-mitchell/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh@.service b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh@.service
new file mode 100644
index 0000000000..f964454e0b
--- /dev/null
+++ b/meta-ampere/meta-mitchell/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-mitchell/recipes-phosphor/console/obmc-console/obmc-console@.service b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/obmc-console@.service
new file mode 100644
index 0000000000..22a5df2690
--- /dev/null
+++ b/meta-ampere/meta-mitchell/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-mitchell/recipes-phosphor/console/obmc-console/server.ttyS0.conf b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/server.ttyS0.conf
new file mode 100644
index 0000000000..4025be341d
--- /dev/null
+++ b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/server.ttyS0.conf
@@ -0,0 +1,3 @@
+local-tty = ttyS0
+local-tty-baud = 115200
+logfile = /var/log/obmc-console-boot.log
diff --git a/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/server.ttyS1.conf b/meta-ampere/meta-mitchell/recipes-phosphor/console/obmc-console/server.ttyS1.conf
new file mode 100644
index 0000000000..086ff94a84
--- /dev/null
+++ b/meta-ampere/meta-mitchell/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-mpro0.log