Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #230

Closed
wants to merge 4 commits into from
Closed

test #230

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
machine:
type: string
docker:
- image: crops/poky:ubuntu-22.04
- image: crops/poky:centos-7
environment:
MACHINE: << parameters.machine >>
CACHE_DIR: /tmp/job/sstate-cache
Expand Down
35 changes: 35 additions & 0 deletions common/recipes-utils/openbmc-utils/files/reset_script_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

DEFAULT_WARNING_MSG="This operation is potentially disruptive."

function warn_and_confirm {
# Params
# 1: "force" Set true if -f or --force was passed into the main script
# 2: Optional warning message to override the default message

local force="${1:-"false"}"
local message="${2:-$DEFAULT_WARNING_MSG}"

if [[ "$force" == "true" ]]; then
return 0
fi

echo "Warning: $message"
read -r -p "Do you wish to continue? [y/N]: " user_input
if [ "$user_input" != "y" ] && [ "$user_input" != "Y" ] ; then
exit 0
fi
}

function check_force_arg {
# Params
# 1: Pass in "$@" from the main script
for arg in $1
do
if [[ "$arg" == "-f" || "$arg" == "--force" ]]; then
echo "true"
else
echo "false"
fi
done
}
2 changes: 2 additions & 0 deletions common/recipes-utils/openbmc-utils/openbmc-utils_0.1.bb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ LOCAL_URI = " \
file://cpu_monitor.py \
file://setup_i2c.service \
file://setup_gpio.service \
file://reset_script_utils.sh \
${@bb.utils.contains('PACKAGECONFIG', 'disable-watchdog', \
'file://disable_watchdog.sh ' + \
'file://disable_watchdog.service', '', d)} \
Expand All @@ -83,6 +84,7 @@ OPENBMC_UTILS_FILES = " \
emmc_auto_mount.sh \
emmc_enhance_part.sh \
flashrom-utils.sh \
reset_script_utils.sh \
"

OPENBMC_PYTHON_LIBS = " \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
PWD1014A_SYSFS_DIR=$(i2c_device_sysfs_abspath 2-003a)
PWR_SYSTEM_SYSFS="${SYSCPLD_SYSFS_DIR}/pwr_cyc_all_n"
PWR_USRV_RST_SYSFS="${SYSCPLD_SYSFS_DIR}/usrv_rst_n"
PWR_TH_RST_SYSFS="${SYSCPLD_SYSFS_DIR}/th_sys_rst_n"
ALT_SYSRESET_SYSFS="${PWD1014A_SYSFS_DIR}/mod_hard_powercycle"

usage() {
Expand All @@ -50,7 +49,7 @@
}

is_main_power_on() {
status=$(cat $PWR_MAIN_SYSFS | head -1 )
status=$(cat "$PWR_MAIN_SYSFS" | head -1 )

Check failure on line 52 in meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/wedge_power.sh

View workflow job for this annotation

GitHub Actions / Aggregate-Lint-Output

[] reported by reviewdog 🐶 note: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. [SC2002] Raw Output: meta-facebook/meta-wedge100/recipes-utils/openbmc-utils/files/wedge_power.sh:52:16: note: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. [SC2002]
if [ "$status" == "0x1" ]; then
return 0 # powered on
else
Expand Down Expand Up @@ -82,12 +81,12 @@

do_on_com_e() {
logger -p user.crit "Powering on microserver..."
echo 1 > $PWR_USRV_SYSFS
echo 1 > "$PWR_USRV_SYSFS"
}

do_on_main_pwr() {
logger -p user.crit "Turning on main power..."
echo 1 > $PWR_MAIN_SYSFS
echo 1 > "$PWR_MAIN_SYSFS"
}

do_on() {
Expand All @@ -101,7 +100,7 @@
;;
*)
usage
exit -1
exit 1
;;

esac
Expand Down Expand Up @@ -130,12 +129,12 @@

do_off_com_e() {
logger -p user.crit "Powering off microserver..."
echo 0 > $PWR_USRV_SYSFS
echo 0 > "$PWR_USRV_SYSFS"
}

do_off_main_pwr() {
logger -p user.crit "Turning off main power..."
echo 0 > $PWR_MAIN_SYSFS
echo 0 > "$PWR_MAIN_SYSFS"
}

do_off() {
Expand All @@ -158,7 +157,7 @@
;;
*)
usage
exit -1
exit 1
;;
esac
done
Expand All @@ -167,33 +166,33 @@
logger -p user.crit "Power reset the whole system..."
echo -n "Power reset the whole system ..."
sleep 1
echo 0 > $PWR_SYSTEM_SYSFS
echo 0 > "$PWR_SYSTEM_SYSFS"
# Echo 0 above should work already. However, after CPLD upgrade,
# We need to re-generate the pulse to make this work
usleep $pulse_us
echo 1 > $PWR_SYSTEM_SYSFS
echo 1 > "$PWR_SYSTEM_SYSFS"
usleep $pulse_us
echo 0 > $PWR_SYSTEM_SYSFS
echo 0 > "$PWR_SYSTEM_SYSFS"
usleep $pulse_us
echo 1 > $PWR_SYSTEM_SYSFS
echo 1 > "$PWR_SYSTEM_SYSFS"
logger -p user.crit "Chassis power failed through CPLD. Will try pwr1014a in 5 sec..."
sleep 5
echo 0 > $ALT_SYSRESET_SYSFS
echo 0 > "$ALT_SYSRESET_SYSFS"
sleep 1
else
if ! wedge_is_us_on; then
echo "Power resetting microserver that is powered off has no effect."
echo "Use '$prog on' to power the microserver on"
return -1
return 1
fi
# reset TH first
reset_brcm.sh

logger -p user.crit "Power reset microserver..."
echo -n "Power reset microserver ..."
echo 0 > $PWR_USRV_RST_SYSFS
echo 0 > "$PWR_USRV_RST_SYSFS"
sleep 1
echo 1 > $PWR_USRV_RST_SYSFS
echo 1 > "$PWR_USRV_RST_SYSFS"
logger "Successfully power reset micro-server"
fi
echo " Done"
Expand All @@ -202,27 +201,27 @@

if [ $# -lt 1 ]; then
usage
exit -1
exit 1
fi

command="$1"
shift

case "$command" in
status)
do_status $@
do_status "$@"
;;
on)
do_on $@
do_on "$@"
;;
off)
do_off $@
do_off "$@"
;;
reset)
do_reset $@
do_reset "$@"
;;
*)
usage
exit -1
exit 1
;;
esac
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
# Boston, MA 02110-1301 USA
#

# shellcheck disable=SC1091
. /usr/local/bin/openbmc-utils.sh
. /usr/local/bin/reset_script_utils.sh

force=$(check_force_arg "$@")
warn_and_confirm "$force"

# There are two reset pins to ASIC. System reset and PCI reset.
#
Expand All @@ -32,8 +37,8 @@
# to control the PCI reset pin separately. However, we don't use it for now
# as we depend on the CPLD for the correct reset sequence.

echo 0 > $PWR_TH_RST_SYSFS
echo 0 > "$PWR_TH_RST_SYSFS"
sleep 1
echo 1 > $PWR_TH_RST_SYSFS
echo 1 > "$PWR_TH_RST_SYSFS"

logger "Reset Tomahawk"
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#shellcheck disable=SC1091
. /usr/local/bin/openbmc-utils.sh
. /usr/local/bin/reset_script_utils.sh

force=$(check_force_arg "$@")
warn_and_confirm "$force"

if [ "$(wedge_board_type)" != "1" ]; then
echo "$(basename "$0") only support on Wedge400C"
Expand Down