From b04c39f656e0de25abc05b37cc47ac831f43b662 Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Sun, 23 Jul 2023 22:42:39 +0800 Subject: [PATCH] [Mellanox] Add support for BIOS update on Spectrum-4 (#15795) (#15941) --- .../sonic_platform/component.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/component.py b/platform/mellanox/mlnx-platform-api/sonic_platform/component.py index 4befc7998425..db184567ca29 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/component.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/component.py @@ -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"); @@ -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' @@ -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; + 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)) @@ -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 @@ -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 @@ -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' @@ -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'] @@ -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'