Automatic fw upgrade for mlnx platform (#31)
* Automatic fw upgrade for mlnx platform Implement script for firmware upgrade to required version Add firmware binary and script to ops-syncd-mlnx container Add pciutils and usbutils to sonic-generic.bin * Update firmware installation message It is possible to do both upgrade and downgrade Change "Upgrading" to "Installing compatible version" Signed-off-by: marian-pritsak <marianp@mellanox.com>
This commit is contained in:
parent
e5d8289f0b
commit
51fa77fa8d
4
Makefile
4
Makefile
@ -73,6 +73,8 @@ $(addprefix dockers/docker-syncd-mlnx/deps/,syncd_1.0.0_amd64.deb libsairedis_1.
|
||||
mkdir -p `dirname $@` && cp $< $(dir $@)
|
||||
dockers/docker-syncd-mlnx/deps/%.deb: src/%.deb
|
||||
mkdir -p `dirname $@` && cp $< $(dir $@)
|
||||
dockers/docker-syncd-mlnx/deps/fw-SPC.mfa: src/mlnx-sdk/fw-SPC.mfa
|
||||
mkdir -p `dirname $@` && cp $< $(dir $@)
|
||||
|
||||
## Rules: docker-syncd-cavm
|
||||
$(addprefix dockers/docker-syncd-cavm/deps/,$(CAVM-SDK-DEBS)) : dockers/docker-syncd-cavm/deps/%.deb : src/cavm-sdk/%.deb
|
||||
@ -106,7 +108,7 @@ target/docker-syncd.gz: target/docker-base.gz $(addprefix dockers/docker-syncd/d
|
||||
docker load < $<
|
||||
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
|
||||
|
||||
target/docker-syncd-mlnx.gz: target/docker-base.gz $(addprefix dockers/docker-syncd-mlnx/deps/,$(MLNX-SDK-DEBS) applibs_1.mlnx.4.2.2100_amd64.deb libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb $(LIBNL-DEBS))
|
||||
target/docker-syncd-mlnx.gz: target/docker-base.gz $(addprefix dockers/docker-syncd-mlnx/deps/,$(MLNX-SDK-DEBS) applibs_1.mlnx.4.2.2100_amd64.deb libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb $(LIBNL-DEBS)) dockers/docker-syncd-mlnx/deps/fw-SPC.mfa
|
||||
docker load < $<
|
||||
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
|
||||
|
||||
|
@ -183,7 +183,9 @@ sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install \
|
||||
bsdmainutils \
|
||||
ca-certificates \
|
||||
i2c-tools \
|
||||
efibootmgr
|
||||
efibootmgr \
|
||||
usbutils \
|
||||
pciutils
|
||||
|
||||
## Remove sshd host keys, and will regenerate on first sshd start
|
||||
sudo rm -f $FILESYSTEM_ROOT/etc/ssh/ssh_host_*_key*
|
||||
|
@ -27,6 +27,8 @@ RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return
|
||||
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /deps/syncd_*.deb
|
||||
|
||||
COPY ["start.sh", "/usr/bin/"]
|
||||
COPY ["mlnx-fw-upgrade.sh", "/usr/bin/"]
|
||||
COPY ["/deps/fw-SPC.mfa", "/etc/mlnx/"]
|
||||
|
||||
## Clean up
|
||||
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
|
||||
|
53
dockers/docker-syncd-mlnx/mlnx-fw-upgrade.sh
Executable file
53
dockers/docker-syncd-mlnx/mlnx-fw-upgrade.sh
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
query_retry_count_max="10"
|
||||
required_fw_version="13.1130.0010"
|
||||
fw_file=/etc/mlnx/fw-SPC.mfa
|
||||
|
||||
run_or_fail() {
|
||||
$1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo $1 failed
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# wait until devices will be available
|
||||
query_retry_count="0"
|
||||
mlxfwmanager --query > /dev/null
|
||||
|
||||
while [[ (${query_retry_count} -lt ${query_retry_count_max}) && ($? -ne "0") ]]; do
|
||||
sleep 1
|
||||
query_retry_count=$[${query_retry_count}+1]
|
||||
mlxfwmanager --query > /dev/null
|
||||
done
|
||||
|
||||
run_or_fail "mlxfwmanager --query" > /tmp/mlnxfwmanager-query.txt
|
||||
|
||||
# get current firmware version
|
||||
found_fw=false
|
||||
for word in `cat /tmp/mlnxfwmanager-query.txt`
|
||||
do
|
||||
if [[ ${found_fw} == true ]]; then
|
||||
fw_version=${word}
|
||||
break
|
||||
fi
|
||||
if [[ ${word} == FW ]]; then
|
||||
found_fw=true
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z ${fw_version} ]]; then
|
||||
echo "Could not retreive current FW version."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${required_fw_version} == ${fw_version} ]]; then
|
||||
echo "Mellanox firmware is up to date."
|
||||
else
|
||||
echo "Mellanox firmware required version is ${required_fw_version}. Installing compatible version..."
|
||||
run_or_fail "mlxfwmanager -i ${fw_file} -u -f -y"
|
||||
|
||||
# exit from here so that syncd service will restart
|
||||
exit 0
|
||||
fi
|
@ -8,6 +8,10 @@ function clean_up {
|
||||
|
||||
trap clean_up SIGTERM SIGKILL
|
||||
|
||||
# fw-upgrade will exit if firmware was actually upgraded or if some error
|
||||
# occures
|
||||
. mlnx-fw-upgrade.sh
|
||||
|
||||
service rsyslog start
|
||||
service syncd start
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user