From dde1fede1f832f029742a1d27290cfe252ab1bc5 Mon Sep 17 00:00:00 2001 From: "Thang Q. Nguyen" Date: Thu, 4 Nov 2021 08:30:27 +0000 Subject: meta-ampere: fix shellcheck issues Fix all issues from the shellcheck checked on bash shells under meta-ampere. Tested: Verify the following features: 1. Power control (on,off, cycle, graceful shutdown, hard reset). 2. UART switching. 3. UEFI firmware update. Signed-off-by: Thang Q. Nguyen Change-Id: Idabf839b7521ecadb642230cc8bb3472c787002e --- .../console/obmc-console/ampere_uartmux_ctrl.sh | 25 ++++++---------------- 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'meta-ampere/meta-jade/recipes-phosphor/console/obmc-console/ampere_uartmux_ctrl.sh') 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 index 58fffd8fe..f28589894 100755 --- 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 @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2020 Ampere Computing LLC +# Copyright (c) 2021 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. @@ -19,24 +19,13 @@ # of 1 sets CPU To HDR_CONN # of 2 sets BMC to CPU (eg dropbear ssh server on port 2200) +# shellcheck source=/dev/null +source /usr/sbin/gpio-lib.sh + 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 @@ -65,17 +54,17 @@ esac # 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 +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 + 1) gpio_configure_output "${GPIO_UARTx_MODE0}" 0 exit 0 ;; - 2) set_gpio_active_low $((${GPIO_BASE} + ${GPIO_UARTx_MODE0})) high + 2) gpio_configure_output "${GPIO_UARTx_MODE0}" 1 exit 0 ;; *) echo "Invalid UART mode selection" -- cgit v1.2.3