diff options
author | Chau Ly <chaul@amperecomputing.com> | 2023-04-13 08:06:28 +0300 |
---|---|---|
committer | Chau Ly <chaul@amperecomputing.com> | 2023-04-18 08:28:51 +0300 |
commit | 0a0f3482710824c59b9d738cc22b45898f687e7a (patch) | |
tree | 8f3e1870c88f0ce87941a9b3def151ba912cb6fc /meta-ampere | |
parent | b10e6e7ed06314c8de2ec1918a3ee83f739ab6f2 (diff) | |
download | openbmc-0a0f3482710824c59b9d738cc22b45898f687e7a.tar.xz |
meta-ampere: mtjade: Refactor obmc-console setup
This commit refactors obmc-console setup for mtjade
Tested:
1. Successfully connects to host consoles via ssh sol
$ ssh root@${bmc} -p 220*
2. Successfully connects host consoles via ipmi sol
$ ipmitool -I lanplus -H ${bmc} -U root -P 0penBmc \
-C 17 sol activate
3. All the host console logs are in /var/log/
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Change-Id: Ie01361139644f5836646d1d98934cda52828ec70
Diffstat (limited to 'meta-ampere')
19 files changed, 90 insertions, 192 deletions
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init.bb b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init.bb index aaeb33ffe9..c20929510a 100644 --- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init.bb +++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init.bb @@ -14,6 +14,8 @@ RDEPENDS:${PN} += "bash" SRC_URI = " \ file://ampere_platform_init.sh \ + file://ampere_uart_console_setup.sh \ + file://ampere_uartmux_ctrl.sh \ file://ampere-platform-init.service \ " @@ -23,6 +25,8 @@ SYSTEMD_SERVICE:${PN} = "ampere-platform-init.service" do_install () { install -d ${D}${sbindir} install -m 0755 ${WORKDIR}/ampere_platform_init.sh ${D}${sbindir}/ + install -m 0755 ${WORKDIR}/ampere_uart_console_setup.sh ${D}${sbindir}/ + install -m 0755 ${WORKDIR}/ampere_uartmux_ctrl.sh ${D}/${sbindir}/ install -d ${D}${systemd_unitdir}/system/ install -m 0644 ${WORKDIR}/ampere-platform-init.service ${D}${systemd_unitdir}/system } diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh index 861b105354..0a14259086 100644 --- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh +++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh @@ -4,6 +4,7 @@ source /usr/sbin/gpio-lib.sh # shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-defs.sh source /usr/sbin/gpio-defs.sh +source /usr/sbin/ampere_uart_console_setup.sh # Configure to boot from MAIN SPI-HOST gpio_configure_output "$SPI0_BACKUP_SEL" 0 @@ -45,3 +46,6 @@ if [ "$bootstatus" == '32' ]; then fi gpio_configure_output "$BMC_READY" 1 +# ======================================================= +# Setting uart muxes to BMC as default +uart_console_setup diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uart_console_setup.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uart_console_setup.sh new file mode 100644 index 0000000000..fe8d20318a --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uart_console_setup.sh @@ -0,0 +1,57 @@ +#!/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. + +# shellcheck disable=SC2039 +# shellcheck disable=SC2112 +# shellcheck disable=SC3010 +# shellcheck disable=SC3030 +# shellcheck disable=SC3054 + +export obmc_console_tty=("ttyS0" "ttyS1" "ttyS2" "ttyS3") + +function get_uart_port() +{ + tty=$1 + 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 + echo $uart +} + +function uart_console_setup() +{ + # 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 + for tty in "${obmc_console_tty[@]}"; do + uart=$(get_uart_port "$tty") + if [ "${uart}" -ne 0 ] + then + /usr/sbin/ampere_uartmux_ctrl.sh "${uart}" 2 + fi + done +} diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uartmux_ctrl.sh index a464adc876..f28589894e 100755 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh +++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-platform-init/ampere_uartmux_ctrl.sh @@ -19,7 +19,7 @@ # <UARTx_MODE> of 1 sets CPU To HDR_CONN # <UARTx_MODE> of 2 sets BMC to CPU (eg dropbear ssh server on port 2200) -# shellcheck source=meta-ampere/meta-jade/recipes-ampere/platform/ampere-utils/gpio-lib.sh +# shellcheck source=/dev/null source /usr/sbin/gpio-lib.sh if [ $# -lt 2 ]; then diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2200.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2200.conf new file mode 100644 index 0000000000..901895bedb --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2200.conf @@ -0,0 +1 @@ +# socket-id is default to obmc-console diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2201.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2201.conf new file mode 100644 index 0000000000..f06d9fccd6 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2201.conf @@ -0,0 +1 @@ +socket-id = ttyS1 diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2202.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2202.conf new file mode 100644 index 0000000000..dba9b8d836 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2202.conf @@ -0,0 +1 @@ +socket-id = ttyS2 diff --git a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2203.conf b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2203.conf new file mode 100644 index 0000000000..0047b898fa --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/client.2203.conf @@ -0,0 +1 @@ +socket-id = ttyS3 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 deleted file mode 100644 index 4e0a01350d..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-server-setup.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/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. - -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 deleted file mode 100644 index 183a7a4f3c..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh.socket +++ /dev/null @@ -1,10 +0,0 @@ -[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 deleted file mode 100644 index f964454e0b..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS0-ssh@.service +++ /dev/null @@ -1,12 +0,0 @@ -[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 deleted file mode 100644 index bdbf562585..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS1-ssh.socket +++ /dev/null @@ -1,10 +0,0 @@ -[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 deleted file mode 100644 index 697c242711..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS1-ssh@.service +++ /dev/null @@ -1,12 +0,0 @@ -[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 deleted file mode 100644 index f8934fd41c..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS2-ssh.socket +++ /dev/null @@ -1,10 +0,0 @@ -[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 deleted file mode 100644 index 7d7f31490a..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS2-ssh@.service +++ /dev/null @@ -1,12 +0,0 @@ -[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 deleted file mode 100644 index fd7f3e3f97..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS3-ssh.socket +++ /dev/null @@ -1,10 +0,0 @@ -[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 deleted file mode 100644 index 261f3a12ef..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console-ttyS3-ssh@.service +++ /dev/null @@ -1,12 +0,0 @@ -[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 deleted file mode 100644 index 22a5df2690..0000000000 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/obmc-console@.service +++ /dev/null @@ -1,17 +0,0 @@ -[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_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console_%.bbappend index 655a44626b..60a26cea62 100644 --- a/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console_%.bbappend +++ b/meta-ampere/meta-jade/recipes-phosphor/console/obmc-console_%.bbappend @@ -3,52 +3,26 @@ RDEPENDS:${PN} += "bash" # Remove what installed by common recipe OBMC_CONSOLE_HOST_TTY = "" -SYSTEMD_SUBSTITUTIONS:remove = "OBMC_CONSOLE_HOST_TTY:${OBMC_CONSOLE_HOST_TTY}:${PN}-ssh@.service" SYSTEMD_SUBSTITUTIONS:remove = "OBMC_CONSOLE_HOST_TTY:${OBMC_CONSOLE_HOST_TTY}:${PN}-ssh.socket" -SYSTEMD_SERVICE:${PN}:remove = " \ - ${PN}-ssh.socket \ - ${PN}-ssh@.service \ - " - -# Declare port spcific conf and service files -HOST_CONSOLE_TTY = "ttyS0 ttyS1 ttyS2 ttyS3" - -CONSOLE_CONF_FMT = "file://server.{0}.conf" -SRC_URI += "${@compose_list(d, 'CONSOLE_CONF_FMT', 'HOST_CONSOLE_TTY')}" -SRC_URI += "file://${BPN}-server-setup.sh" -SRC_URI += "file://${BPN}@.service" -SRC_URI += "file://ampere_uartmux_ctrl.sh" - -CONSOLE_SSH_SOCKET_FILE_FMT = "file://${PN}-{0}-ssh.socket" -CONSOLE_SSH_SERVICE_FILE_FMT = "file://${PN}-{0}-ssh@.service" -SRC_URI += "${@compose_list(d, 'CONSOLE_SSH_SOCKET_FILE_FMT', 'HOST_CONSOLE_TTY')}" -SRC_URI += "${@compose_list(d, 'CONSOLE_SSH_SERVICE_FILE_FMT', 'HOST_CONSOLE_TTY')}" - -CONSOLE_SSH_SOCKET_FMT = "${PN}-{0}-ssh.socket" -CONSOLE_SSH_SERVICE_FMT = "${PN}-{0}-ssh@.service" - -SYSTEMD_SERVICE:${PN} = " \ - ${PN}@.service \ - ${@compose_list(d, 'CONSOLE_SSH_SOCKET_FMT', 'HOST_CONSOLE_TTY')} \ - ${@compose_list(d, 'CONSOLE_SSH_SERVICE_FMT', 'HOST_CONSOLE_TTY')} \ - " + +# Declare port spcific config files +OBMC_CONSOLE_TTYS = "ttyS0 ttyS1 ttyS2 ttyS3" +CONSOLE_CLIENT = "2200 2201 2202 2203" + +CONSOLE_SERVER_CONF_FMT = "file://server.{0}.conf" +CONSOLE_CLIENT_CONF_FMT = "file://client.{0}.conf" + +SRC_URI += " ${@compose_list(d, 'CONSOLE_SERVER_CONF_FMT', 'OBMC_CONSOLE_TTYS')} \ + ${@compose_list(d, 'CONSOLE_CLIENT_CONF_FMT', 'CONSOLE_CLIENT')} \ + " + +SYSTEMD_SERVICE:${PN}:remove = "obmc-console-ssh.socket" + +FILES:${PN}:remove = "${systemd_system_unitdir}/obmc-console-ssh@.service.d/use-socket.conf" + +EXTRA_OECONF:append = " --enable-concurrent-servers" + do_install:append() { - for i in ${HOST_CONSOLE_TTY} - do - install -m 0644 ${WORKDIR}/server.${i}.conf ${D}${sysconfdir}/${BPN}/server.${i}.conf - install -m 0644 ${WORKDIR}/${BPN}-${i}-ssh.socket ${D}${systemd_unitdir}/system/${BPN}-${i}-ssh.socket - install -m 0644 ${WORKDIR}/${BPN}-${i}-ssh@.service ${D}${systemd_unitdir}/system/${BPN}-${i}-ssh@.service - done - install -m 0755 ${WORKDIR}/${BPN}-server-setup.sh ${D}${sbindir}/${BPN}-server-setup.sh - - # Deal with files installed by the base package's .bb install function - rm -f ${D}${sysconfdir}/${BPN}.conf - rm -f ${D}${sysconfdir}/${BPN}/server.ttyVUART0.conf - rm -rf ${D}${systemd_unitdir}/system/${BPN}-ssh@.service.d/ - rm -f ${D}${systemd_unitdir}/system/${BPN}-ssh@.service - rm -f ${D}${systemd_unitdir}/system/${BPN}-ssh.socket - # Overwrite base package's obmc-console@.service with our own - install -m 0644 ${WORKDIR}/${BPN}@.service ${D}${systemd_unitdir}/system/${BPN}@.service - install -d ${D}/usr/sbin - install -m 0755 ${WORKDIR}/ampere_uartmux_ctrl.sh ${D}/${sbindir}/ampere_uartmux_ctrl.sh + # Install the console client configurations + install -m 0644 ${WORKDIR}/client.*.conf ${D}${sysconfdir}/${BPN}/ } |