Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions device/mellanox/x86_64-mlnx_lssn2700-r0/platform_reboot
1 change: 1 addition & 0 deletions device/mellanox/x86_64-mlnx_msn2010-r0/platform_reboot
1 change: 1 addition & 0 deletions device/mellanox/x86_64-mlnx_msn2100-r0/platform_reboot
1 change: 1 addition & 0 deletions device/mellanox/x86_64-mlnx_msn2410-r0/platform_reboot
47 changes: 47 additions & 0 deletions device/mellanox/x86_64-mlnx_msn2700-r0/platform_reboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

FW_UPGRADE_SCRIPT="/usr/bin/mlnx-fw-upgrade.sh"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set -e
to make it strict on any error?


NEXT_SONIC_IMAGE="$(sonic_installer list | grep "Next: " | cut -d ' ' -f 2)"
Copy link
Collaborator

@qiluo-msft qiluo-msft Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sonic_installer [](start = 20, length = 15)

Check run as root? #Closed

Copy link
Collaborator Author

@nazariig nazariig Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiluo-msft This script is a part of reboot where we already have this check. Do we really need to duplicate it? #WontFix

CURRENT_SONIC_IMAGE="$(sonic_installer list | grep "Current: " | cut -d ' ' -f 2)"

FORCE_REBOOT="no"

ParseArguments() {
while [ $# -ge 1 ]; do
case "$1" in
-f|--force)
FORCE_REBOOT="yes"
;;
esac
shift
done
}

ParseArguments $@

if [[ "${CURRENT_SONIC_IMAGE}" != "${NEXT_SONIC_IMAGE}" ]]; then
Copy link
Collaborator

@qiluo-msft qiluo-msft Oct 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo "Prepare ASIC to reboot: install new FW if required"

NEXT_IMAGE_FS_PATH="/host/image-${NEXT_SONIC_IMAGE#SONiC-OS-}/fs.squashfs"
FS_MOUNTPOINT="/tmp/image-${NEXT_SONIC_IMAGE#SONiC-OS-}-fs"

mkdir -p "${FS_MOUNTPOINT}"
mount -t squashfs "${NEXT_IMAGE_FS_PATH}" "${FS_MOUNTPOINT}"

${FW_UPGRADE_SCRIPT} "${FS_MOUNTPOINT}/etc/mlnx/fw-SPC.mfa"
EXIT_CODE=$?

umount "${FS_MOUNTPOINT}"

if [[ ${EXIT_CODE} != 0 ]]; then
echo "Failed to burn FW: errno=${EXIT_CODE}"

if [[ ${FORCE_REBOOT} != "yes" ]]; then
echo "Reboot is interrupted: use -f|--force to override"
exit 1
fi
fi
fi

/sbin/reboot $@
Copy link
Collaborator

@qiluo-msft qiluo-msft Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exec ? #Closed

1 change: 1 addition & 0 deletions device/mellanox/x86_64-mlnx_msn2740-r0/platform_reboot
24 changes: 12 additions & 12 deletions platform/mellanox/mlnx-fw-upgrade.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ query_retry_count_max="10"
fw_file=/etc/mlnx/fw-SPC.mfa

run_or_fail() {
$1
if [[ $? != 0 ]]; then
echo $1 failed
exit 1
fi
$1
if [[ $? != 0 ]]; then
echo $1 failed
exit 1
fi
}

# wait until devices will be available
Expand All @@ -18,12 +18,12 @@ query_cmd="mlxfwmanager --query"
${query_cmd} > /dev/null

while [[ (${query_retry_count} -lt ${query_retry_count_max}) && ($? -ne "0") ]]; do
sleep 1
query_retry_count=$[${query_retry_count}+1]
${query_cmd} > /dev/null
sleep 1
query_retry_count=$[${query_retry_count}+1]
${query_cmd} > /dev/null
done

function upgrade() {
upgrade() {
if [ ! -z "$1" ]; then
fw_file="$1"
if [ ! -f "$fw_file" ]; then
Expand All @@ -46,17 +46,17 @@ function upgrade() {
fw_info=$(grep FW /tmp/mlnxfwmanager-query.txt)
fw_current=$(echo $fw_info | cut -f2 -d' ')
fi

if [[ -z ${fw_current} ]]; then
echo "Could not retreive current FW version."
exit 1
fi

if [[ -z ${fw_required} ]]; then
echo "Could not retreive required FW version."
exit 1
fi

if [[ ${fw_current} == ${fw_required} ]]; then
echo "Mellanox firmware is up to date."
else
Expand Down