Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 1 addition & 11 deletions platform/mellanox/mlnx-fw-upgrade.j2
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ function PrintHelp() {
echo " -c, --clear-semaphore Clear hw resources before updating firmware"
{% if sonic_asic_platform == "nvidia-bluefield" %}
echo " -r, --reset Reset firmware configuration (NVIDIA BlueField platform only)"
echo " -n, --no-mst Do not start MST drivers (NVIDIA BlueField platform only)"
{% endif %}
echo " -h, --help Print help"
echo
Expand Down Expand Up @@ -118,9 +117,6 @@ function ParseArguments() {
-c|--clear-semaphore)
CLEAR_SEMAPHORE="${YES_PARAM}"
;;
-n|--no-mst)
NO_MST="${YES_PARAM}"
;;
{% if sonic_asic_platform == "nvidia-bluefield" %}
-r|--reset)
RESET_CONFIG="${YES_PARAM}"
Expand Down Expand Up @@ -235,12 +231,6 @@ function WaitForDevice() {
local -r DEVICE_TYPE=$(GetMstDeviceType)
local SPC_MST_DEV
local QUERY_RC=""

if [[ "${NO_MST}" != "${YES_PARAM}" ]]; then
LogInfo "Restarting MST device"
/usr/bin/mst restart --with_i2cdev
fi

while : ; do
SPC_MST_DEV=$(GetSPCMstDevice)
${QUERY_XML} -d ${SPC_MST_DEV} -o ${QUERY_FILE}
Expand Down Expand Up @@ -515,4 +505,4 @@ else
UpgradeFWFromImage
fi

ExitSuccess "firmware upgrade is completed"
ExitSuccess "firmware upgrade is completed"
40 changes: 24 additions & 16 deletions platform/mellanox/mlnx-platform-api/sonic_platform/component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -33,6 +33,7 @@
from sonic_py_common import device_info
from sonic_py_common.logger import Logger
from sonic_py_common.general import check_output_pipe
import contextlib
if sys.version_info[0] > 2:
import configparser
else:
Expand Down Expand Up @@ -762,19 +763,12 @@ def __init__(self, idx):
self.image_ext_name = self.COMPONENT_FIRMWARE_EXTENSION

def __get_mst_device(self):
if not os.path.exists(self.MST_DEVICE_PATH):
print("ERROR: mst driver is not loaded")
return None

pattern = os.path.join(self.MST_DEVICE_PATH, self.MST_DEVICE_PATTERN)

mst_dev_list = glob.glob(pattern)
if not mst_dev_list or len(mst_dev_list) != 1:
devices = str(os.listdir(self.MST_DEVICE_PATH))
print("ERROR: Failed to get mst device: pattern={}, devices={}".format(pattern, devices))
return None

return mst_dev_list[0]
output = None
try:
output = subprocess.check_output(['/usr/bin/asic_detect/asic_detect.sh', '-p']).decode('utf-8').strip()
except subprocess.CalledProcessError as e:
raise RuntimeError("Failed to get {} mst device: {}".format(self.name, str(e)))
return output

def _install_firmware(self, image_path):
if not self._check_file_validity(image_path):
Expand Down Expand Up @@ -940,14 +934,28 @@ class ComponenetFPGADPU(ComponentCPLD):

CPLD_FIRMWARE_UPDATE_COMMAND = ['cpldupdate', '--cpld_chain', '2', '--gpio', '--print-progress', '']

@contextlib.contextmanager
def _mst_context(self):
try:
subprocess.check_call(['/usr/bin/mst', 'start'], universal_newlines=True)
yield
except subprocess.CalledProcessError as e:
logger.log_error("Failed to manage {} mst: {}".format(self.name, str(e)))
raise
finally:
try:
subprocess.check_call(['/usr/bin/mst', 'stop'], universal_newlines=True)
except subprocess.CalledProcessError as e:
logger.log_error("Failed to stop {} mst: {}".format(self.name, str(e)))

def _install_firmware(self, image_path):
self.CPLD_FIRMWARE_UPDATE_COMMAND[5] = image_path

try:
print("INFO: Installing {} firmware update: path={}".format(self.name, image_path))
subprocess.check_call(self.CPLD_FIRMWARE_UPDATE_COMMAND, universal_newlines=True)
with self._mst_context():
subprocess.check_call(self.CPLD_FIRMWARE_UPDATE_COMMAND, universal_newlines=True)
except subprocess.CalledProcessError as e:
print("ERROR: Failed to update {} firmware: {}".format(self.name, str(e)))
return False

return True
14 changes: 9 additions & 5 deletions platform/mellanox/mlnx-platform-api/tests/test_component.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -293,15 +294,18 @@ def test_cpld_get_component_list_dpu(self):
for index, item in enumerate(component_list):
assert item.name == 'DPU{}_FPGA'.format(index + 1)

def test_cpld_get_mst_device(self):
@mock.patch('sonic_platform.component.subprocess.check_output')
def test_cpld_get_mst_device(self, mock_check_output):
ComponentCPLD.MST_DEVICE_PATH = '/tmp/mst'
os.system('rm -rf /tmp/mst')
c = ComponentCPLD(1)
assert c._ComponentCPLD__get_mst_device() is None
mock_check_output.return_value = b''
assert c._ComponentCPLD__get_mst_device() == ''
os.makedirs(ComponentCPLD.MST_DEVICE_PATH)
assert c._ComponentCPLD__get_mst_device() is None
assert c._ComponentCPLD__get_mst_device() == ''
with open('/tmp/mst/mt0_pci_cr0', 'w+') as f:
f.write('dummy')
mock_check_output.return_value = b'/tmp/mst/mt0_pci_cr0'
assert c._ComponentCPLD__get_mst_device() == '/tmp/mst/mt0_pci_cr0'

@mock.patch('sonic_platform.component.subprocess.check_call')
Expand Down
4 changes: 2 additions & 2 deletions platform/nvidia-bluefield/installer/install.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ if [[ $SKIP_FIRMWARE_UPGRADE != "true" ]]; then
bfb_pre_fw_install
fi

ex $sonic_fs_mountpoint/usr/bin/mlnx-fw-upgrade.sh -v --no-mst
ex $sonic_fs_mountpoint/usr/bin/mlnx-fw-upgrade.sh -v
if [[ $? != 0 ]]; then
log "ERROR: FW update failed"
fi

if [[ $FORCE_FW_CONFIG_RESET == "true" ]]; then
ex $sonic_fs_mountpoint/usr/bin/mlnx-fw-upgrade.sh -v -r --no-mst
ex $sonic_fs_mountpoint/usr/bin/mlnx-fw-upgrade.sh -v -r
fi

ex umount $sonic_fs_mountpoint
Expand Down
Loading