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 --- .../flash/ampere-flash-utils/ampere_flash_bios.sh | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh') diff --git a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh index 7a9ace30e..b7f4bc52e 100755 --- a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh +++ b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh @@ -18,7 +18,7 @@ do_flash () { OFFSET=$1 # Check the PNOR partition available - HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p') + HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p') if [ -z "$HOST_MTD" ]; then # If the PNOR partition is not available, then bind again driver @@ -26,7 +26,7 @@ do_flash () { echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/bind sleep 2 - HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p') + HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p') if [ -z "$HOST_MTD" ]; then echo "Fail to probe Host SPI-NOR device" @@ -35,18 +35,17 @@ do_flash () { fi echo "--- Flashing firmware to @/dev/$HOST_MTD offset=$OFFSET" - flashcp -v $IMAGE /dev/$HOST_MTD $OFFSET + flashcp -v "$IMAGE" /dev/"$HOST_MTD" "$OFFSET" } if [ $# -eq 0 ]; then - echo "Usage: $(basename $0) " + echo "Usage: $(basename "$0") " exit 0 fi IMAGE="$1" -if [ ! -f $IMAGE ]; then - echo $IMAGE +if [ ! -f "$IMAGE" ]; then echo "The image file $IMAGE does not exist" exit 1 fi @@ -70,9 +69,7 @@ fi # Switch the host SPI bus to BMC" echo "--- Switch the host SPI bus to BMC." -gpioset 0 226=0 - -if [[ $? -ne 0 ]]; then +if ! gpioset 0 226=0; then echo "ERROR: Switch the host SPI bus to BMC. Please check gpio state" exit 1 fi @@ -82,9 +79,7 @@ do_flash 0x400000 # Switch the host SPI bus to HOST." echo "--- Switch the host SPI bus to HOST." -gpioset 0 226=1 - -if [[ $? -ne 0 ]]; then +if ! gpioset 0 226=1; then echo "ERROR: Switch the host SPI bus to HOST. Please check gpio state" exit 1 fi -- cgit v1.2.3