diff options
Diffstat (limited to 'meta-quanta/meta-gbs/recipes-gbs')
6 files changed, 62 insertions, 72 deletions
diff --git a/meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-update.sh b/meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-update.sh index bf71e9452c..32a595f5b1 100644 --- a/meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-update.sh +++ b/meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-update.sh @@ -28,14 +28,9 @@ KERNEL_SYSFS_FIU="/sys/bus/platform/drivers/NPCM-FIU" # the node of FIU is spi for kernel 5.10, but # for less than or equal kernel 5.4, the node # is fiu -for fname in $(find ${KERNEL_SYSFS_FIU} -type l) -do - if [ "${fname##*\.}" == "fiu" ] - then - KERNEL_FIU_ID="c0000000.fiu" - break - fi -done +if ls "$KERNEL_SYSFS_FIU"/*.fiu 1> /dev/null 2>&1; then + KERNEL_FIU_ID="c0000000.fiu" +fi IMAGE_FILE="/tmp/image-bios" @@ -45,7 +40,7 @@ findmtd() { m=$(grep -xl "$1" /sys/class/mtd/*/name) m=${m%/name} m=${m##*/} - echo $m + echo "$m" } cleanup() { @@ -82,8 +77,7 @@ main() { exit 1 fi - flashcp -v $IMAGE_FILE /dev/"${bios_mtd}" - if [ $? -eq 0 ]; then + if flashcp -v $IMAGE_FILE /dev/"${bios_mtd}" ; then echo "bios update successfully..." else echo "bios update failed..." @@ -91,6 +85,6 @@ main() { fi } # Exit without running main() if sourced -return 0 2>/dev/null - -main "$@" +if ! (return 0 2>/dev/null); then + main "$@" +fi diff --git a/meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-verify.sh b/meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-verify.sh index 3da25e483d..ac4ee1d577 100644 --- a/meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-verify.sh +++ b/meta-quanta/meta-gbs/recipes-gbs/gbs-bios-update/files/bios-verify.sh @@ -14,11 +14,11 @@ echo "Verify bios image..." if [ -e $IMAGE_FILE ] && [ -e $SIG_FILE ]; then - sha256_image=`sha256sum "$IMAGE_FILE" | awk '{print $1}'` - sha256_file=`awk '{print $1}' $SIG_FILE` + sha256_image=$(sha256sum "$IMAGE_FILE" | awk '{print $1}') + sha256_file=$(awk '{print $1}' $SIG_FILE) fi -if [[ $sha256_image != $sha256_file ]]; +if [ "$sha256_image" != "$sha256_file" ]; then echo "bios image verify fail." rm -f $IMAGE_FILE diff --git a/meta-quanta/meta-gbs/recipes-gbs/gbs-bmc-update/files/bmc-verify.sh b/meta-quanta/meta-gbs/recipes-gbs/gbs-bmc-update/files/bmc-verify.sh index bbaf15d7dc..d45105dbec 100644 --- a/meta-quanta/meta-gbs/recipes-gbs/gbs-bmc-update/files/bmc-verify.sh +++ b/meta-quanta/meta-gbs/recipes-gbs/gbs-bmc-update/files/bmc-verify.sh @@ -9,7 +9,7 @@ bmclog="/tmp/update-bmc.log" if [ -f $publickey ];then r="$(openssl dgst -verify $publickey -sha256 -signature $sigfile $bmcimage)" echo "$r" > $bmclog - if [[ "Verified OK" == "$r" ]]; then + if [ "Verified OK" = "$r" ]; then mv $bmcimage $imagebmc rm -f $sigfile exit 0 diff --git a/meta-quanta/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh b/meta-quanta/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh index cb652a2a84..b1bc46e6fd 100644 --- a/meta-quanta/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh +++ b/meta-quanta/meta-gbs/recipes-gbs/gbs-detect-gpio-present/files/detect-gpio-present.sh @@ -27,24 +27,24 @@ LOG_DEASSERT_FLAG="false" LOG_GENID_FLAG="0x0020" present_state=("true" "true" "true" "true" "true" "true" "true" "true" "true" "true" "true" "true") -for i in ${!PRESENT_OBJPATH[@]} +for i in "${!PRESENT_OBJPATH[@]}" do - mapper wait ${PRESENT_OBJPATH[$i]} + mapper wait "${PRESENT_OBJPATH[$i]}" done while true; do - for i in ${!PRESENT_OBJPATH[@]} + for i in "${!PRESENT_OBJPATH[@]}" do - boot_status="$(busctl get-property $SERVICE_NAME ${PRESENT_OBJPATH[$i]} $INTERFACE_NAME Present | awk '{print $2}')" + boot_status="$(busctl get-property $SERVICE_NAME "${PRESENT_OBJPATH[$i]}" $INTERFACE_NAME Present | awk '{print $2}')" - if [ $boot_status == "false" ] && [ ${present_state[$i]} == "true" ];then - echo "Update cable $(($i+1)) state." - present_state[$i]="false" - busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" ${PRESENT_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_ASSERT_FLAG $LOG_GENID_FLAG - elif [ $boot_status == "true" ] && [ ${present_state[$i]} == "false" ];then - echo "Update cable $(($i+1)) state." - present_state[$i]="true" - busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" ${PRESENT_OBJPATH[$i]} $LOG_EVENT_DATA $LOG_DEASSERT_FLAG $LOG_GENID_FLAG + if [ "$boot_status" == "false" ] && [ "${present_state[$i]}" == "true" ];then + echo "Update cable $((i+1)) state." + present_state[i]="false" + busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" "${PRESENT_OBJPATH[$i]}" "$LOG_EVENT_DATA" $LOG_ASSERT_FLAG $LOG_GENID_FLAG + elif [ "$boot_status" == "true" ] && [ "${present_state[$i]}" == "false" ];then + echo "Update cable $((i+1)) state." + present_state[i]="true" + busctl call $IPMI_LOG_SERVICE $IPMI_LOG_OBJPATH $IPMI_LOG_INTERFACE $IPMI_LOG_FUNCT $IPMI_LOG_PARA_FORMAT "$LOG_ERR" "${PRESENT_OBJPATH[$i]}" "$LOG_EVENT_DATA" $LOG_DEASSERT_FLAG $LOG_GENID_FLAG fi done sleep 1 diff --git a/meta-quanta/meta-gbs/recipes-gbs/gbs-sysinit/files/gbs-sysinit.sh b/meta-quanta/meta-gbs/recipes-gbs/gbs-sysinit/files/gbs-sysinit.sh index 8b660c2dca..67636c1924 100644 --- a/meta-quanta/meta-gbs/recipes-gbs/gbs-sysinit/files/gbs-sysinit.sh +++ b/meta-quanta/meta-gbs/recipes-gbs/gbs-sysinit/files/gbs-sysinit.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. - +# shellcheck source=meta-quanta/meta-gbs/recipes-gbs/gbs-sysinit/files/gbs-gpio-common.sh source /usr/libexec/gbs-gpio-common.sh WD1RCR_ADDR=0xf080103c @@ -44,36 +44,36 @@ set_gpio_persistence() { } get_board_rev_id() { - echo $(get_gpio_value 'BMC_BRD_REV_ID7')\ - $(get_gpio_value 'BMC_BRD_REV_ID6')\ - $(get_gpio_value 'BMC_BRD_REV_ID5')\ - $(get_gpio_value 'BMC_BRD_REV_ID4')\ - $(get_gpio_value 'BMC_BRD_REV_ID3')\ - $(get_gpio_value 'BMC_BRD_REV_ID2')\ - $(get_gpio_value 'BMC_BRD_REV_ID1')\ - $(get_gpio_value 'BMC_BRD_REV_ID0')\ + echo "$(get_gpio_value 'BMC_BRD_REV_ID7')"\ + "$(get_gpio_value 'BMC_BRD_REV_ID6')"\ + "$(get_gpio_value 'BMC_BRD_REV_ID5')"\ + "$(get_gpio_value 'BMC_BRD_REV_ID4')"\ + "$(get_gpio_value 'BMC_BRD_REV_ID3')"\ + "$(get_gpio_value 'BMC_BRD_REV_ID2')"\ + "$(get_gpio_value 'BMC_BRD_REV_ID1')"\ + "$(get_gpio_value 'BMC_BRD_REV_ID0')"\ | sed 's/ //g' > ~/board_rev_id.txt } get_board_sku_id() { - echo $(get_gpio_value 'BMC_BRD_SKU_ID3')\ - $(get_gpio_value 'BMC_BRD_SKU_ID2')\ - $(get_gpio_value 'BMC_BRD_SKU_ID1')\ - $(get_gpio_value 'BMC_BRD_SKU_ID0')\ + echo "$(get_gpio_value 'BMC_BRD_SKU_ID3')"\ + "$(get_gpio_value 'BMC_BRD_SKU_ID2')"\ + "$(get_gpio_value 'BMC_BRD_SKU_ID1')"\ + "$(get_gpio_value 'BMC_BRD_SKU_ID0')"\ | sed 's/ //g' > ~/board_sku_id.txt } get_hsbp_board_rev_id() { - echo $(get_gpio_value 'HSBP_BRD_REV_ID3')\ - $(get_gpio_value 'HSBP_BRD_REV_ID2')\ - $(get_gpio_value 'HSBP_BRD_REV_ID1')\ - $(get_gpio_value 'HSBP_BRD_REV_ID0')\ + echo "$(get_gpio_value 'HSBP_BRD_REV_ID3')"\ + "$(get_gpio_value 'HSBP_BRD_REV_ID2')"\ + "$(get_gpio_value 'HSBP_BRD_REV_ID1')"\ + "$(get_gpio_value 'HSBP_BRD_REV_ID0')"\ | sed 's/ //g' > ~/hsbp_board_rev_id.txt } get_fan_board_rev_id() { - echo $(get_gpio_value 'FAN_BRD_REV_ID1')\ - $(get_gpio_value 'FAN_BRD_REV_ID0')\ + echo "$(get_gpio_value 'FAN_BRD_REV_ID1')"\ + "$(get_gpio_value 'FAN_BRD_REV_ID0')"\ | sed 's/ //g' > ~/fan_board_rev_id.txt } @@ -100,10 +100,8 @@ check_board_sku() { sku1_val=$(get_gpio_value 'BMC_BRD_SKU_ID1') if (( sku1_val == 1 )); then echo "GBS SKU!" - BOARD_SKU="GBS" else echo "Other SKU!" - BOARD_SKU="TBD" fi } @@ -134,11 +132,9 @@ KERNEL_SYSFS_FIU="/sys/bus/platform/drivers/NPCM-FIU" # the node of FIU is spi for kernel 5.10, but # for less than or equal kernel 5.4, the node # is fiu -shopt -s nullglob -for fiu in "$KERNEL_SYSFS_FIU"/*.fiu; do +if ls "$KERNEL_SYSFS_FIU"/*.fiu 1> /dev/null 2>&1; then KERNEL_FIU_ID="c0000000.fiu" - break -done +fi bind_host_mtd() { set_gpio_direction 'SPI_SW_SELECT' high @@ -162,7 +158,7 @@ findmtd() { m=$(grep -xl "$1" /sys/class/mtd/*/name) m=${m%/name} m=${m##*/} - echo $m + echo "$m" } verify_host_bios() { @@ -176,7 +172,7 @@ verify_host_bios() { [[ -z "${pnor_mtd}" ]] && { echo "Failed to find host MTD partition!"; return 1; } # Test timing by computing SHA256SUM. - sha256sum /dev/${pnor_mtd}ro + sha256sum "/dev/${pnor_mtd}ro" echo "BIOS verification complete!" unbind_host_mtd @@ -186,12 +182,12 @@ parse_pe_fru() { pe_fruid=3 for i in {1..2}; do - mapper wait ${PE_PRESENT_OBJPATH[$(($i-1))]} - pe_prsnt_n="$(busctl get-property $SERVICE_NAME ${PE_PRESENT_OBJPATH[$(($i-1))]} \ + mapper wait "${PE_PRESENT_OBJPATH[$((i-1))]}" + pe_prsnt_n="$(busctl get-property $SERVICE_NAME "${PE_PRESENT_OBJPATH[$((i-1))]}" \ $INTERFACE_NAME Present)" if [[ ${pe_prsnt_n} == "b false" ]]; then - pe_fruid=$(($pe_fruid+1)) + pe_fruid=$((pe_fruid+1)) continue fi @@ -199,6 +195,7 @@ parse_pe_fru() { # i2c-0 -> i2c mux (addr: 0x71) -> PE0/PE1 # PE0: channel 0 # PE1: channel 1 + # shellcheck disable=SC2010 pe_fru_bus="$(ls -al /sys/bus/i2c/drivers/pca954x/0-0071/ | grep channel \ | awk -F "/" '{print $(NF)}' | awk -F "-" '{print $2}' | sed -n "${i}p")" @@ -206,17 +203,16 @@ parse_pe_fru() { # EEPROM part number) and perform a phosphor-read-eeprom for ((j=0; j < ${#pe_eeprom_addr[@]}; j++)); do - i2cget -f -y $pe_fru_bus "0x${pe_eeprom_addr[$j]}" 0x01 > /dev/null 2>&1 - if [ $? -eq 0 ]; then + if i2cget -f -y "$pe_fru_bus" "0x${pe_eeprom_addr[$j]}" 0x01 > /dev/null 2>&1 ; then if [ ! -f "/sys/bus/i2c/devices/$pe_fru_bus-00${pe_eeprom_addr[$j]}/eeprom" ]; then echo 24c02 "0x${pe_eeprom_addr[$j]}" > "/sys/bus/i2c/devices/i2c-$pe_fru_bus/new_device" fi pe_fru_bus="/sys/bus/i2c/devices/$pe_fru_bus-00${pe_eeprom_addr[$j]}/eeprom" - phosphor-read-eeprom --eeprom $pe_fru_bus --fruid $pe_fruid + phosphor-read-eeprom --eeprom "$pe_fru_bus" --fruid $pe_fruid break fi done - pe_fruid=$(($pe_fruid+1)) + pe_fruid=$((pe_fruid+1)) done } @@ -224,7 +220,7 @@ check_power_status() { res0="$(busctl get-property -j xyz.openbmc_project.State.Chassis \ /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis \ CurrentPowerState | jq -r '.["data"]')" - echo $res0 + echo "$res0" } clk_buf_bus_switch="11-0076" @@ -277,6 +273,6 @@ main() { } # Exit without running main() if sourced -return 0 2>/dev/null - -main "$@" +if ! (return 0 2>/dev/null) ; then + main "$@" +fi diff --git a/meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh b/meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh index e22dd20438..14136b7669 100644 --- a/meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh +++ b/meta-quanta/meta-gbs/recipes-gbs/hotswap-power-cycle/files/tray_powercycle.sh @@ -27,12 +27,12 @@ stop_phosphor_hwmon() { main() { # Stop phosphor-hwmon so that ADM1272 powercycle doesn't happen # in the middle of an i2c transaction and stuck the bus low - stop_phosphor_hwmon + stop_phosphor_hwmon "$@" gpioset gpiochip6 26=1 } # Exit without running main() if sourced -return 0 2>/dev/null - -main "$@" +if ! (return 0 2>/dev/null) ; then + main "$@" +fi |