meta-fii: meta-kudo: Fix shellcheck errors
Fixes bash shellcheck errors so that the exemptions in run-repotest
can be removed.
Signed-off-by: Charles Boyer <Charles.Boyer@fii-usa.com>
Change-Id: I6afb059cf1151c871ddfcaf67efc6a63183f7130
diff --git a/meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh b/meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh
index 8779513..8b2ce0b 100644
--- a/meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/host/files/ampere_power_util.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+# Provide source directive to shellcheck.
+# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
source /usr/libexec/kudo-fw/kudo-lib.sh
# Usage of this utility
@@ -35,7 +37,7 @@
power_status() {
st=$(busctl get-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | cut -d "." -f6)
- if [ "$st" == "On\"" ]; then
+ if [ "${st}" == "On\"" ]; then
echo "on"
else
echo "off"
@@ -45,7 +47,7 @@
host_status() {
BOOT_OK=$(get_gpio_ctrl 194)
S5_N=$(get_gpio_ctrl 204)
- if [ $S5_N == 1 ] || [ $BOOT_OK == 1 ]; then
+ if [ "$S5_N" == 1 ] || [ "$BOOT_OK" == 1 ]; then
echo "on"
else
echo "off"
@@ -63,7 +65,7 @@
else
echo "Triggering graceful shutdown"
mkdir /run/openbmc
- echo "$(timestamp)" > "/run/openbmc/host@0-shutdown-req-time"
+ timestamp > "/run/openbmc/host@0-shutdown-req-time"
set_gpio_ctrl 70 out 0
sleep 3
set_gpio_ctrl 70 out 1
@@ -71,7 +73,7 @@
}
host_reset() {
- if [ $(host_status) == "on" ]; then
+ if [ "$(host_status)" == "on" ]; then
echo "Triggering sysreset pin"
busctl set-property xyz.openbmc_project.Watchdog /xyz/openbmc_project/watchdog/host0 xyz.openbmc_project.State.Watchdog ExpireAction s xyz.openbmc_project.State.Watchdog.Action.None
set_gpio_ctrl 65 out 0
@@ -114,7 +116,7 @@
rm "/run/openbmc/power-button"
else
echo "Power button pressed"
- echo "$(timestamp)" > "/run/openbmc/power-button"
+ timestamp > "/run/openbmc/power-button"
fi
}
@@ -125,36 +127,36 @@
exit 0;
fi
-if [ $1 != "mb" ]; then
+if [ "$1" != "mb" ]; then
echo "Invalid parameter1=$1"
usage;
exit 0;
fi
-if [ $2 = "on" ]; then
+if [ "$2" = "on" ]; then
sleep 3
- if [ $(power_status) == "off" ]; then
+ if [ "$(power_status)" == "off" ]; then
power_on
fi
-elif [ $2 = "off" ]; then
- if [ $(power_status) == "on" ]; then
+elif [ "$2" = "off" ]; then
+ if [ "$(power_status)" == "on" ]; then
power_off
sleep 6
- if [ $(host_status) == "on" ]; then
+ if [ "$(host_status)" == "on" ]; then
force_off
fi
fi
-elif [[ $2 == "hotswap" ]]; then
+elif [ "$2" == "hotswap" ]; then
hotswap
-elif [[ $2 == "graceful_shutdown" ]]; then
+elif [ "$2" == "graceful_shutdown" ]; then
graceful_shutdown
-elif [ $2 == "host_reset" ]; then
+elif [ "$2" == "host_reset" ]; then
host_reset
-elif [ $2 == "host_cycle" ]; then
+elif [ "$2" == "host_cycle" ]; then
host_cycle
-elif [ $2 == "shutdown_ack" ]; then
+elif [ "$2" == "shutdown_ack" ]; then
shutdown_ack
-elif [ $2 == "power_button" ]; then
+elif [ "$2" == "power_button" ]; then
power_button
else
echo "Invalid parameter2=$2"
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh
index 90ec84a..23a65c1 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+# Disable check for splitting
+# shellcheck disable=SC2207
+
BMC_CPLD_VER_FILE="/run/cpld0.version"
MB_CPLD_VER_FILE="/run/cpld1.version"
ver=''
@@ -8,12 +11,12 @@
case $1 in
cpldb)
rsp=($(i2cget -y -f -a 13 0x76 0x00 i 5))
- ver=$(printf '%d.%d.%d.%d' ${rsp[5]} ${rsp[4]} ${rsp[3]} ${rsp[2]})
+ ver=$(printf '%d.%d.%d.%d' "${rsp[5]}" "${rsp[4]}" "${rsp[3]}" "${rsp[2]}")
;;
cpldm)
I2C_BUS_DEV=$(readlink "/sys/bus/i2c/devices/4-0077/channel-2" | cut -c 8-)
- rsp=($(i2cget -y -f -a $I2C_BUS_DEV 0x76 0x00 i 5))
- ver=$(printf '%d.%d.%d.%d' ${rsp[5]} ${rsp[4]} ${rsp[3]} ${rsp[2]})
+ rsp=($(i2cget -y -f -a "$I2C_BUS_DEV" 0x76 0x00 i 5))
+ ver=$(printf '%d.%d.%d.%d' "${rsp[5]}" "${rsp[4]}" "${rsp[3]}" "${rsp[2]}")
;;
*)
;;
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh
index 0f8868f..6231aeb 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh
@@ -1,9 +1,13 @@
#!/bin/bash
-devpath="/sys/bus/i2c/devices/13-0077/driver"
-
+# Provide source directive to shellcheck.
+# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
+# Disable check for globbing and word splitting within double quotes
+# shellcheck disable=SC2086
source /usr/libexec/kudo-fw/kudo-lib.sh
+devpath="/sys/bus/i2c/devices/13-0077/driver"
+
function fwbios() {
KERNEL_FIU_ID="c0000000.spi"
KERNEL_SYSFS_FIU="/sys/bus/platform/drivers/NPCM-FIU"
@@ -19,16 +23,15 @@
echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/bind
# write to the mtd device
- BIOS_MTD=$(cat /proc/mtd | grep "bios" | sed -n 's/^\(.*\):.*/\1/p')
+ BIOS_MTD=$(grep "bios" /proc/mtd | sed -n 's/^\(.*\):.*/\1/p')
- if [ ! -f $1 ]; then
- echo " Cannot find the" $1 "image file"
+ if [ ! -f "$1" ]; then
+ echo " Cannot find the" "$1" "image file"
return 1
fi
- echo "Flashing BIOS @/dev/$BIOS_MTD"
- flashcp -v $1 /dev/$BIOS_MTD
- if [ $? -ne 0 ]; then
+ echo "Flashing BIOS @/dev/${BIOS_MTD}"
+ if [ "$(flashcp -v $1 /dev/${BIOS_MTD})" -ne 0 ]; then
echo "Flashing the bios failed " >&2
return 1
fi
@@ -41,22 +44,26 @@
i2cset -y -f -a 13 0x76 0x10 0x00
# Disable LPI mode NV_SI_CPU_LPI_FREQ_DISABLE for SCP 1.06 and older.
- nvparm -s 0x1 -o 0x114090
-
- # Disable LPI mode NV_SI_CPU_LPI_FREQ_DISABLE for SCP 1.07 and newer
- nvparm -s 0x1 -o 0x02A8
-
- # Disable toggling of SMPro heartbeat
- nvparm -s 0x0 -o 0x5F0638
-
- if [ $? -ne 0 ]; then
- echo "Setting default nvparms failed " >&2
+ if [ "$(nvparm -s 0x1 -o 0x114090)" -ne 0 ]; then
+ echo "Setting LPI mode for SCP 1.06 and older failed " >&2
return 1
fi
- if [[ $(find ${1} -type f -size +17156k 2>/dev/null) ]]; then
+ # Disable LPI mode NV_SI_CPU_LPI_FREQ_DISABLE for SCP 1.07 and newer
+ if [ "$(nvparm -s 0x1 -o 0x02A8)" -ne 0 ]; then
+ echo "Setting LPI mode for SCP 1.07 and newer failed " >&2
+ return 1
+ fi
+
+ # Disable toggling of SMPro heartbeat
+ if [ "$(nvparm -s 0x0 -o 0x5F0638)" -ne 0 ]; then
+ echo "Setting SMpro heartbeat failed " >&2
+ return 1
+ fi
+
+ if [[ $(find "$1" -type f -size +17156k 2>/dev/null) ]]; then
echo "Extracting the SCP from the image"
- dd if=$1 bs=1024 skip=17156 count=256 of=/run/initramfs/myscp.img
+ dd if="$1" bs=1024 skip=17156 count=256 of=/run/initramfs/myscp.img
# Update both primary and backup EEPROM
fwscp /run/initramfs/myscp.img
fwscpback /run/initramfs/myscp.img
@@ -69,8 +76,7 @@
function fwbmccpld() {
# BMC_JTAG_MUX_1 #218 0:BMC 1:MB
set_gpio_ctrl 218 out 0
- loadsvf -d /dev/jtag0 -s $1 -m 0
- if [ $? -ne 0 ]; then
+ if [ "$(loadsvf -d /dev/jtag0 -s $1 -m 0)" -ne 0 ]; then
echo "BMC CPLD update failed" >&2
return 1
fi
@@ -85,8 +91,7 @@
# BMC_JTAG_SEL #164 0:BMC 1:CPU
set_gpio_ctrl 218 out 1
set_gpio_ctrl 164 out 1
- loadsvf -d /dev/jtag0 -s $1 -m 0
- if [ $? -ne 0 ]; then
+ if [ "$(loadsvf -d /dev/jtag0 -s $1 -m 0)" -ne 0 ]; then
echo "Mobo CPLD update failed" >&2
return 1
fi
@@ -98,18 +103,18 @@
function fwscp() {
# BMC_I2C_BACKUP_SEL #168 0:failover, 1:main
# BMC_CPU_EEPROM_I2C_SEL #85 0:BMC, 1:CPU
- scp_eeprom_sel=`get_gpio_ctrl 168`
+ scp_eeprom_sel=$(get_gpio_ctrl 168)
set_gpio_ctrl 168 out 1
set_gpio_ctrl 85 out 0
+ #shellcheck disable=SC2010
I2C_BUS_DEV=$(ls -l $devpath/"13-0077/" | grep channel-0 | awk '{ print $11}' | cut -c 8-)
- ampere_eeprom_prog -b $I2C_BUS_DEV -s 0x50 -p -f $1
- if [ $? -ne 0 ]; then
+ if [ "$(ampere_eeprom_prog -b $I2C_BUS_DEV -s 0x50 -p -f $1)" -ne 0 ]; then
echo "SCP eeprom update failed" >&2
return 1
fi
wait
set_gpio_ctrl 85 out 1
- set_gpio_ctrl 168 out $scp_eeprom_sel
+ set_gpio_ctrl 168 out "$scp_eeprom_sel"
return 0
}
@@ -117,18 +122,18 @@
function fwscpback() {
# BMC_I2C_BACKUP_SEL #168 0:failover, 1:main
# BMC_CPU_EEPROM_I2C_SEL #85 0:BMC, 1:CPU
- scp_eeprom_sel=`get_gpio_ctrl 168`
+ scp_eeprom_sel=$(get_gpio_ctrl 168)
set_gpio_ctrl 168 out 0
set_gpio_ctrl 85 out 0
+ #shellcheck disable=SC2010
I2C_BUS_DEV=$(ls -l $devpath/"13-0077/" | grep channel-0 | awk '{ print $11}' | cut -c 8-)
- ampere_eeprom_prog -b $I2C_BUS_DEV -s 0x50 -p -f $1
- if [ $? -ne 0 ]; then
+ if [ "$(ampere_eeprom_prog -b $I2C_BUS_DEV -s 0x50 -p -f $1)" -ne 0 ]; then
echo "SCP BACKUP eeprom update failed" >&2
return 1
fi
wait
set_gpio_ctrl 85 out 1
- set_gpio_ctrl 168 out $scp_eeprom_sel
+ set_gpio_ctrl 168 out "$scp_eeprom_sel"
return 0
}
@@ -136,18 +141,17 @@
function fwmb_pwr_seq(){
#$1 0x40 seq config file
#$2 0x41 seq config file
- if [[ ! -e $1 ]]; then
- echo "$1 file does not exist"
+ if [[ ! -e "$1" ]]; then
+ echo "The file $1 does not exist"
return 1
fi
- if [[ ! -e $2 ]]; then
- echo "$2 file does not exist"
+ if [[ ! -e "$2" ]]; then
+ echo "The file $2 file does not exist"
return 1
fi
echo 32-0040 > /sys/bus/i2c/drivers/adm1266/unbind
echo 32-0041 > /sys/bus/i2c/drivers/adm1266/unbind
- adm1266_fw_fx $1 $2
- if [ $? -ne 0 ]; then
+ if [ "$(adm1266_fw_fx $1 $2)" -ne 0 ]; then
echo "The power seq flash failed" >&2
return 1
fi
@@ -176,28 +180,28 @@
case $1 in
bios)
- fwbios $2
+ fwbios "$2"
;;
bmccpld)
- fwbmccpld $2
+ fwbmccpld "$2"
;;
mbcpld)
- fwmbcpld $2
+ fwmbcpld "$2"
;;
scp)
- fwscp $2
+ fwscp "$2"
;;
scpback)
- fwscpback $2
+ fwscpback "$2"
;;
mbseq)
- fwmb_pwr_seq $2 $3
+ fwmb_pwr_seq "$2" "$3"
;;
*)
;;
esac
ret=$?
-rm -f $2 $3
+rm -f "$2" "$3"
exit $ret
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
index 377257e..503e413 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
@@ -3,17 +3,17 @@
# set_gpio_ctrl
# pin #, direction, high(1)/low(0)
function set_gpio_ctrl() {
- echo $1 > /sys/class/gpio/export
- echo $2 > /sys/class//gpio/gpio$1/direction
- echo $3 > /sys/class/gpio/gpio$1/value
- echo $1 > /sys/class/gpio/unexport
+ echo "$1" > /sys/class/gpio/export
+ echo "$2" > /sys/class//gpio/gpio"$1"/direction
+ echo "$3" > /sys/class/gpio/gpio"$1"/value
+ echo "$1" > /sys/class/gpio/unexport
sleep 1
}
# get_gpio_ctrl
# pin #
function get_gpio_ctrl() {
- echo $1 > /sys/class/gpio/export
- echo $(cat /sys/class/gpio/gpio$1/value)
- echo $1 > /sys/class/gpio/unexport
+ echo "$1" > /sys/class/gpio/export
+ cat /sys/class/gpio/gpio"$1"/value
+ echo "$1" > /sys/class/gpio/unexport
}
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh
index ea13b17..cd80674 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+# Provide source directive to shellcheck.
+# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
source /usr/libexec/kudo-fw/kudo-lib.sh
function set_mux_default(){
@@ -24,7 +26,7 @@
# 0 - 63 EVT
# 64 + DVT/PVT
-boardver=$(printf '%d' `cat /sys/bus/i2c/drivers/fiicpld/34-0076/CMD00 | awk '{print $6}'`)
+boardver=$(printf '%d' "$(awk '{print $6}' /sys/bus/i2c/drivers/fiicpld/34-0076/CMD00)")
# On EVT machines, the secondary SCP EEPROM is used.
# Set BMC_I2C_BACKUP_SEL to secondary.
@@ -54,9 +56,9 @@
if [[ $CPU1_STATUS_N == 1 ]]; then
#Execute this only on DVT systems
if [[ $boardver -lt 64 ]]; then
- echo EVT system $boardver
+ echo EVT system "$boardver"
else
- echo DVT system $boardver
+ echo DVT system "$boardver"
i2cset -y -a -f 37 0x68 0x05 0x03
fi
#These i2c deviecs are already installed on EVT systems
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
index af1b0a4..551192d 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
@@ -241,7 +241,7 @@
-if [ -z $powerState ]
+if [ -z "${powerState}" ]
then
echo "System is currently Powered off S6"
else
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
index d8b92b5..694c23c 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
@@ -1,6 +1,8 @@
#!/bin/bash
# help information
+# Provide source directive to shellcheck.
+# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
source /usr/libexec/kudo-fw/kudo-lib.sh
function usage_rst() {
@@ -71,10 +73,10 @@
set_gpio_ctrl 203 out 0
;;
display)
- echo "Virtual reset #94" $(get_gpio_ctrl 94)
- echo "S0 System reset #65" $(get_gpio_ctrl 65)
- echo "Power Button #203" $(get_gpio_ctrl 203)
- echo "BMC_CPU SHD Req #70" $(get_gpio_ctrl 70)
+ echo "Virtual reset #94" "$(get_gpio_ctrl 94)"
+ echo "S0 System reset #65" "$(get_gpio_ctrl 65)"
+ echo "Power Button #203" "$(get_gpio_ctrl 203)"
+ echo "BMC_CPU SHD Req #70" "$(get_gpio_ctrl 70)"
;;
*)
usage_rst
@@ -86,15 +88,15 @@
BMC_CPLD_VER_FILE="/run/cpld0.version"
MB_CPLD_VER_FILE="/run/cpld1.version"
- cmd=$(cat $BMC_CPLD_VER_FILE)
- echo " BMC_CPLD: " $cmd
- cmd=$(cat $MB_CPLD_VER_FILE)
- echo " MB_CPLD: " $cmd
+ cmd=$(cat ${BMC_CPLD_VER_FILE})
+ echo " BMC_CPLD: " "${cmd}"
+ cmd=$(cat ${MB_CPLD_VER_FILE})
+ echo " MB_CPLD: " "${cmd}"
# BMC Version
# Save VERSION_ID line in string "VERSION_ID=vXX.XX-XX-kudo"
- StringVersion=$(cat /etc/os-release | awk '/VERSION_ID/')
+ StringVersion=$(awk '/VERSION_ID/' /etc/os-release)
#Save Major Version value between v and . "vXX." then convert Hex to Decimal
MajorVersion=${StringVersion#*v}
@@ -131,7 +133,7 @@
function uartmux() {
case $1 in
host)
- if [ `tty` == "/dev/ttyS0" ]; then
+ if [ "$(tty)" == "/dev/ttyS0" ]; then
echo "Couldn't redirect to the host console within BMC local console"
else
echo "Entering Console use 'shift ~~..' to quit"
@@ -139,7 +141,7 @@
fi
;;
scp)
- if [ `tty` == "/dev/ttyS0" ]; then
+ if [ "$(tty)" == "/dev/ttyS0" ]; then
echo "Couldn't redirect to the scp console within BMC local console"
else
echo "Entering Console use 'shift ~~..' to quit"
@@ -167,29 +169,29 @@
set_gpio_ctrl 177 out 0
;;
display)
- if [ $(get_gpio_ctrl 167) -eq 1 ]; then
+ if [ "$(get_gpio_ctrl 167)" -eq 1 ]; then
echo " CPU host to BMC console"
else
echo " CPU host to header"
fi
- if [ $(get_gpio_ctrl 161) -eq 1 ] && [ $(get_gpio_ctrl 177) -eq 1 ]; then
- if [ $(get_gpio_ctrl 198) -eq 1 ]; then
+ if [ "$(get_gpio_ctrl 161)" -eq 1 ] && [ "$(get_gpio_ctrl 177)" -eq 1 ]; then
+ if [ "$(get_gpio_ctrl 198)" -eq 1 ]; then
echo " SCP2 host to BMC console"
else
echo " SCP1 host to BMC console"
fi
- elif [ $(get_gpio_ctrl 161) -eq 0 ] && [ $(get_gpio_ctrl 177) -eq 0 ]; then
- if [ $(get_gpio_ctrl 198) -eq 1 ]; then
+ elif [ "$(get_gpio_ctrl 161)" -eq 0 ] && [ "$(get_gpio_ctrl 177)" -eq 0 ]; then
+ if [ "$(get_gpio_ctrl 198)" -eq 1 ]; then
echo " SCP2 host to Header"
else
echo " SCP1 host to Header"
fi
else
echo "It's unknown status"
- echo "167" $(get_gpio_ctrl 167)
- echo "161" $(get_gpio_ctrl 161)
- echo "177" $(get_gpio_ctrl 177)
- echo "198" $(get_gpio_ctrl 198)
+ echo "167" "$(get_gpio_ctrl 167)"
+ echo "161" "$(get_gpio_ctrl 161)"
+ echo "177" "$(get_gpio_ctrl 177)"
+ echo "198" "$(get_gpio_ctrl 198)"
fi
;;
*)
@@ -203,26 +205,26 @@
CurrentLED=$( i2cget -y -f -a 34 0x76 0x05 i 1 | cut -d ' ' -f 2)
case $1 in
boot)
- cmd=$((($CurrentLED & 0x40) != 0))
+ cmd=$(((CurrentLED & 0x40) != 0))
case $2 in
on)
#turn on LED
if [[ $cmd -eq 0 ]]; then
- setValue=$(( 0x40 + $CurrentLED ))
- i2cset -y -f -a 34 0x76 0x10 $setValue
+ setValue=$(( 0x40 + CurrentLED ))
+ i2cset -y -f -a 34 0x76 0x10 "$setValue"
fi
;;
off)
#turn off led
if [[ $cmd -eq 1 ]]; then
- setValue=$(( 0x80 & $CurrentLED ))
- i2cset -y -f -a 34 0x76 0x10 $setValue
+ setValue=$(( 0x80 & CurrentLED ))
+ i2cset -y -f -a 34 0x76 0x10 "$setValue"
fi
;;
toggle)
#turn on LED
- setValue=$(( 0x40 ^ $CurrentLED ))
- i2cset -y -f -a 34 0x76 0x10 $setValue
+ setValue=$(( 0x40 ^ CurrentLED ))
+ i2cset -y -f -a 34 0x76 0x10 "$setValue"
;;
status)
#displayLED status
@@ -238,26 +240,26 @@
esac
;;
att)
- cmd=$((($CurrentLED & 0x80) != 0))
+ cmd=$(((CurrentLED & 0x80) != 0))
case $2 in
on)
#turn on LED
if [[ $cmd -eq 0 ]]; then
- setValue=$(( 0x80 + $CurrentLED ))
- i2cset -y -f -a 34 0x76 0x10 $setValue
+ setValue=$(( 0x80 + CurrentLED ))
+ i2cset -y -f -a 34 0x76 0x10 "$setValue"
fi
;;
off)
#turn off led
if [[ $cmd -eq 1 ]]; then
- setValue=$(( 0x40 & $CurrentLED ))
- i2cset -y -f -a 34 0x76 0x10 $setValue
+ setValue=$(( 0x40 & CurrentLED ))
+ i2cset -y -f -a 34 0x76 0x10 "$setValue"
fi
;;
toggle)
#turn on LED
- setValue=$(( 0x80 ^ $CurrentLED ))
- i2cset -y -f -a 34 0x76 0x10 $setValue
+ setValue=$(( 0x80 ^ CurrentLED ))
+ i2cset -y -f -a 34 0x76 0x10 "$setValue"
;;
status)
#displayLED status
@@ -281,27 +283,27 @@
function usblist() {
for i in {0..8}
do
- cmd="devmem 0xf083"$i"154"
- printf "udc%d : 0xF803%d154-" "$i" "$i"
+ cmd=$(devmem 0xf083"${i}"154)
+ printf "udc%d : 0xF803%d154-" "${i}" "${i}"
$cmd
done
}
case $1 in
rst)
- reset $2
+ reset "$2"
;;
fw)
fw_rev
;;
uart)
- uartmux $2
+ uartmux "$2"
;;
usb)
usblist
;;
led)
- ledtoggle $2 $3
+ ledtoggle "$2" "$3"
;;
*)
usage
diff --git a/meta-fii/meta-kudo/recipes-kudo/network/usb-network/usb_network.sh b/meta-fii/meta-kudo/recipes-kudo/network/usb-network/usb_network.sh
index 8d7804d..e0fdd2c 100644
--- a/meta-fii/meta-kudo/recipes-kudo/network/usb-network/usb_network.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/network/usb-network/usb_network.sh
@@ -1,10 +1,10 @@
#!/bin/bash
-cd /sys/kernel/config/usb_gadget
+cd /sys/kernel/config/usb_gadget || exit 1
if [ ! -f "g1" ]; then
mkdir g1
- cd g1
+ cd g1 || exit 1
echo 0x1d6b > idVendor # Linux foundation
echo 0x0104 > idProduct # Multifunction composite gadget