-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Mellanox]platform api support firmware install #3931
Merged
+351
−16
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2c8e646
[sonic_platform]support install firmware
80ecdaa
[component.py]Address comments
f73b20b
[component.py]address comments
b411566
[platform_api]add chassis.get_name, add exit code checking
37b11ca
[component.py]add return code check for subprocess handling
30a4ae7
[component]update name: onie-fw-updated.sh
9477140
[chassis]update the way to get the chassis name to using onie_platfor…
08d885a
[fwupdate]fix issue that setting next_entry=ONIE breaks the sonic_ins…
c3fa992
[onie-fw-update]remove find_onie_menuentry.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
[sonic_platform]support install firmware
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
#!/bin/sh | ||
|
||
# Copyright (C) 2019 Mellanox Technologies Ltd. | ||
# Copyright (C) 2019 Michael Shych <michaelsh@mellanox.com> | ||
# | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
this_script=${ONIE_FWPKG_PROGRAM_NAME:-$(basename $(realpath $0))} | ||
|
||
onie_mount=/mnt/onie-boot | ||
os_boot=/host | ||
onie_partition= | ||
onie_entry=0 | ||
|
||
export ONIE_FWPKG_PROGRAM_NAME=$(basename $(realpath $0)) | ||
|
||
usage() | ||
{ | ||
cat <<EOF | ||
update | ||
The 'update' command will reboot system to ONIE update mode | ||
and ONIE will perform automatically update of previously | ||
added (i.e. pending) FW (ONIE itself, BIOS or CPLD) image. | ||
EOF | ||
} | ||
|
||
enable_onie_access() | ||
{ | ||
onie_partition=$(fdisk -l | grep "ONIE boot" | awk '{print $1}') | ||
if [ ! -d $onie_mount ]; then | ||
mkdir /mnt/onie-boot | ||
fi | ||
mount $onie_partition /mnt/onie-boot | ||
if [ ! -e /lib/onie ]; then | ||
ln -s /mnt/onie-boot/onie/tools/lib/onie /lib/onie | ||
fi | ||
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$onie_mount/onie/tools/bin/ | ||
export PATH | ||
} | ||
|
||
clean_onie_access() | ||
{ | ||
rm -f /lib/onie | ||
umount $onie_partition | ||
} | ||
|
||
# ONIE entry must exist in grub config | ||
find_onie_menuentry() | ||
{ | ||
onie_entry="$(cat $os_boot/grub/grub.cfg | grep -e 'menuentry' | cat -n | awk '$0~/ONIE/ {print $1-1}')" | ||
entries_num="$(echo "$onie_entry" | grep -E '^[0-9]+$' | wc -l)" | ||
if [ $entries_num -eq 1 ] && [ $onie_entry -ge 1 ]; then | ||
return 0 | ||
fi | ||
return 1 | ||
} | ||
|
||
change_grub_boot_order() | ||
{ | ||
find_onie_menuentry | ||
rc=$? | ||
if [ $rc -eq 0 ]; then | ||
grub-reboot --boot-directory=$os_boot $onie_entry | ||
else | ||
echo "ERROR: ONIE entry wasn't found in grub config" | ||
return 1 | ||
fi | ||
|
||
grub-editenv $onie_mount/grub/grubenv set onie_mode=update | ||
return 0 | ||
} | ||
|
||
show_pending() | ||
{ | ||
curr_dir=$(pwd) | ||
cd $onie_mount/onie/update/pending || return 0 | ||
num=$(find . -type f | wc -l) | ||
if [ $num -ge 1 ]; then | ||
echo "Number of FW update pending files are: "$num | ||
ls -l * | awk {'print $9" "$5" "$7"-"$6" "$8'} | ||
else | ||
echo "There is no pending files for FW update." | ||
fi | ||
cd $curr_dir | ||
|
||
return $num | ||
} | ||
|
||
system_reboot() | ||
{ | ||
echo "Reboot will be done after 5 sec." | ||
sleep 5 | ||
/sbin/reboot | ||
} | ||
|
||
# Process command arguments | ||
cmd=$1 | ||
# optional argument | ||
name="$2" | ||
|
||
if [ -z "$cmd" ] ; then | ||
# Default to 'show' if no command is specified. | ||
cmd="show" | ||
fi | ||
|
||
case "$cmd" in | ||
add | remove) | ||
[ -z "$name" ] && { | ||
echo "ERROR: This command requires a firmware update file name." | ||
echo "Run '$this_script help' for complete details." | ||
exit 1 | ||
} | ||
;; | ||
update) | ||
enable_onie_access | ||
show_pending | ||
rc=$? | ||
if [ $rc -ne 0 ]; then | ||
change_grub_boot_order | ||
rc=$? | ||
clean_onie_access | ||
if [ $rc -eq 0 ]; then | ||
system_reboot | ||
fi | ||
exit $rc | ||
else | ||
echo "ERROR: NO FW images for update." | ||
echo "Run: $this_script add <image> before update." | ||
clean_onie_access | ||
exit 1 | ||
fi | ||
;; | ||
purge | show | show-results | show-log | show-pending | help) | ||
;; | ||
*) | ||
echo "Unknown command: $cmd" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
enable_onie_access | ||
$onie_mount/onie/tools/bin/onie-fwpkg "$@" | ||
rc=$? | ||
if [ $cmd = "help" ]; then | ||
usage | ||
fi | ||
clean_onie_access | ||
|
||
exit $rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# bios update tool | ||
|
||
ONIE_FW_UPDATE= onie-fw-update | ||
$(ONIE_FW_UPDATE)_PATH = platform/mellanox/ | ||
SONIC_COPY_FILES += $(ONIE_FW_UPDATE) | ||
|
||
export ONIE_FW_UPDATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephenxs Since we are already use
onie_entry
, we do not need this anymoreThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.