Skip to content
Closed
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
23 changes: 13 additions & 10 deletions platform/mellanox/mlnx-platform-api/sonic_platform/component.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES.
# Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -130,7 +130,7 @@ class ONIEUpdater(object):
ONIE_FW_UPDATE_CMD_INSTALL = ['/usr/bin/mlnx-onie-fw-update.sh', 'update', '--no-reboot']
ONIE_FW_UPDATE_CMD_SHOW_PENDING = ['/usr/bin/mlnx-onie-fw-update.sh', 'show-pending']

ONIE_VERSION_PARSE_PATTERN = '([0-9]{4})\.([0-9]{2})-([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)'
ONIE_VERSION_PARSE_PATTERN = '([0-9]{4})\.([0-9]{2})-([0-9]+)\.([0-9]+)\.([0-9]+)-?(dev)?-([0-9]+)'
ONIE_VERSION_BASE_PARSE_PATTERN = '([0-9]+)\.([0-9]+)\.([0-9]+)'
ONIE_VERSION_REQUIRED = '5.2.0016'

Expand All @@ -145,14 +145,16 @@ class ONIEUpdater(object):
# For SN2201, upgrading fireware from ONIE is supported from day one so we do not need to check it.
PLATFORM_ALWAYS_SUPPORT_UPGRADE = ['x86_64-nvidia_sn2201-r0']

BIOS_UPDATE_FILE_EXT = '.rom'

BIOS_UPDATE_FILE_EXT_ROM = '.rom'
BIOS_UPDATE_FILE_EXT_CAB = '.cab'

def __init__(self):
self.platform = device_info.get_platform()

def __add_prefix(self, image_path):
if self.BIOS_UPDATE_FILE_EXT not in image_path:
if image_path.endswith(self.BIOS_UPDATE_FILE_EXT_CAB):
return image_path;

Choose a reason for hiding this comment

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

@DavidZagury looks like it will break automatic FW upgrade. Suggest to double check

elif self.BIOS_UPDATE_FILE_EXT_ROM not in image_path:
rename_path = "/tmp/00-{}".format(os.path.basename(image_path))
else:
rename_path = "/tmp/99-{}".format(os.path.basename(image_path))
Expand Down Expand Up @@ -279,7 +281,8 @@ def parse_onie_version(self, version, is_base=False):
onie_major = m.group(3)
onie_minor = m.group(4)
onie_release = m.group(5)
onie_baudrate = m.group(6)
onie_signtype = m.group(6)
onie_baudrate = m.group(7)

return onie_year, onie_month, onie_major, onie_minor, onie_release, onie_baudrate

Expand Down Expand Up @@ -422,7 +425,7 @@ def _check_file_validity(self, image_path):

name_list = os.path.splitext(image_path)
if self.image_ext_name is not None:
if name_list[1] != self.image_ext_name:
if name_list[1] not in self.image_ext_name:
print("ERROR: Extend name of file {} is wrong. Image for {} should have extend name {}".format(image_path, self.name, self.image_ext_name))
return False

Expand Down Expand Up @@ -478,7 +481,7 @@ def update_firmware(self, image_path):
class ComponentSSD(Component):
COMPONENT_NAME = 'SSD'
COMPONENT_DESCRIPTION = 'SSD - Solid-State Drive'
COMPONENT_FIRMWARE_EXTENSION = '.pkg'
COMPONENT_FIRMWARE_EXTENSION = ['.pkg']

FIRMWARE_VERSION_ATTR = 'Firmware Version'
AVAILABLE_FIRMWARE_VERSION_ATTR = 'Available Firmware Version'
Expand Down Expand Up @@ -641,7 +644,7 @@ def update_firmware(self, image_path):
class ComponentBIOS(Component):
COMPONENT_NAME = 'BIOS'
COMPONENT_DESCRIPTION = 'BIOS - Basic Input/Output System'
COMPONENT_FIRMWARE_EXTENSION = '.rom'
COMPONENT_FIRMWARE_EXTENSION = ['.rom', '.cab']

BIOS_VERSION_COMMAND = ['dmidecode', '--oem-string', '1']

Expand Down Expand Up @@ -725,7 +728,7 @@ def get_firmware_version(self):
class ComponentCPLD(Component):
COMPONENT_NAME = 'CPLD{}'
COMPONENT_DESCRIPTION = 'CPLD - Complex Programmable Logic Device'
COMPONENT_FIRMWARE_EXTENSION = '.vme'
COMPONENT_FIRMWARE_EXTENSION = ['.vme']

MST_DEVICE_PATH = '/dev/mst'
MST_DEVICE_PATTERN = 'mt[0-9]*_pci_cr0'
Expand Down