Skip to content

[DellEMC] S6100 - Adding SSD component and platform_fw_au_reboot_handle for auto-update #9208

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

Merged
merged 1 commit into from
Dec 7, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ s6100/scripts/soft-reboot_plugin usr/share/sonic/device/x86_64-dell_s6100_c2538-
s6100/scripts/reboot_plugin usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
s6100/scripts/ssd-fw-upgrade usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
s6100/scripts/override.conf /etc/systemd/system/systemd-reboot.service.d
s6100/scripts/platform_fw_au_reboot_handle usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
common/dell_lpc_mon.sh usr/local/bin
s6100/scripts/s6100_ssd_mon.sh usr/local/bin
s6100/scripts/s6100_ssd_upgrade_status.sh usr/local/bin
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

DEVPATH="/usr/share/sonic/device/x86_64-dell_s6100_c2538-r0"

BIOS_FW_UPGRADE="$DEVPATH/bios-fw-upgrade"
FPGA_FW_UPGRADE="$DEVPATH/smf-fw-upgrade"
CPLD_FW_UPGRADE="$DEVPATH/cpld-fw-upgrade"
SSD_FW_UPGRADE="$DEVPATH/ssd-fw-upgrade"

execute_upgrade() {
case $1 in
BIOS)
if [ -x ${BIOS_FW_UPGRADE} ];then
${BIOS_FW_UPGRADE} $BOOT
fi
;;
FPGA)
if [ -x ${SMF_FW_UPGRADE} ];then
${SMF_FW_UPGRADE} $BOOT
fi
;;
CPLD)
if [ -x ${CPLD_FW_UPGRADE} ];then
${CPLD_FW_UPGRADE} $BOOT
fi
;;
SSD)
if [ -x ${SSD_FW_UPGRADE} ];then
${SSD_FW_UPGRADE} $BOOT
fi
;;
*)
esac
}


parse() {
if [ -f ${TASK_FILE} ];then
while IFS= read -r line; do
execute_upgrade $line
done < $TASK_FILE
fi
}

case "$1" in
fast-reboot)
TASK_FILE="/tmp/firmwareupdate/fast_fw_au_task"
;;
warm-reboot)
TASK_FILE="/tmp/firmwareupdate/warm_fw_au_task"
;;
reboot)
TASK_FILE="/tmp/firmwareupdate/cold_fw_au_task"
;;
*)
echo "Usage: $0 {fast-reboot|warm-reboot|reboot}" >&2
exit 2
esac
BOOT=$1
parse

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
MAX_S6100_FANTRAY = 4
MAX_S6100_PSU = 2
MAX_S6100_THERMAL = 10
MAX_S6100_COMPONENT = 3
MAX_S6100_COMPONENT = 4


class Chassis(ChassisBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@
########################################################################

try:
import json
import os
import re
import subprocess
import tarfile
from sonic_platform_base.component_base import ComponentBase
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

BIOS_QUERY_VERSION_COMMAND = "dmidecode -s system-version"
SSD_VERSION_COMMAND = "ssdutil -v"
SSD_UPGRADE_SCHEDULE = "/usr/local/bin/ssd_upgrade_schedule"
PCI_VERSION_COMMAND = "lspci -s 0:0.0"


class Component(ComponentBase):
Expand All @@ -29,9 +35,10 @@ class Component(ComponentBase):
CHASSIS_COMPONENTS = [
["BIOS", ("Performs initialization of hardware components during "
"booting")],
["CPLD", "Used for managing IO modules, SFP+ modules and system LEDs"],
["FPGA", ("Platform management controller for on-board temperature "
"monitoring, in-chassis power, Fan and LED control")]
"monitoring, in-chassis power, Fan and LED control")],
["CPLD", "Used for managing IO modules, SFP+ modules and system LEDs"],
["SSD", "Solid State Drive that stores data persistently"]
]
MODULE_COMPONENT = [
"IOM{}-CPLD",
Expand Down Expand Up @@ -125,6 +132,38 @@ def _get_fpga_version(self):
else:
return 'NA'

def _get_ssd_version(self):
rv = 'NA'
ssd_ver = self._get_command_result(SSD_VERSION_COMMAND)
if not ssd_ver:
return rv
else:
version = re.search(r'Firmware\s*:(.*)',ssd_ver)
if version:
rv = version.group(1).strip()
return rv

def _get_available_firmware_version(self, image_path):
if not os.path.isfile(image_path):
return False, "ERROR: File not found"

try:
updater = tarfile.open(image_path, "r")
except tarfile.ReadError:
return False, "ERROR: Unable to extract firmware updater"

try:
ver_info_fd = updater.extractfile("fw-component-version")
except KeyError:
updater.close()
return False, "ERROR: Version info not available"

ver_info = json.load(ver_info_fd)
ver_info_fd.close()
updater.close()

return True, ver_info

def get_name(self):
"""
Retrieves the name of the component
Expand Down Expand Up @@ -216,10 +255,53 @@ def get_firmware_version(self):
else:
return bios_ver

elif self.index == 1: # SwitchCard CPLD
return self._get_cpld_version()
elif self.index == 2: # FPGA
elif self.index == 1: # FPGA
return self._get_fpga_version()
elif self.index == 2: # SwitchCard CPLD
return self._get_cpld_version()
elif self.index == 3: #SSD
return self._get_ssd_version()

def get_available_firmware_version(self, image_path):
"""
Retrieves the available firmware version of the component

Note: the firmware version will be read from image

Args:
image_path: A string, path to firmware image

Returns:
A string containing the available firmware version of the component
"""
avail_ver = None
if self.index == 2: # SwitchCard CPLD
valid, version = self._get_available_firmware_version(image_path)
pci_ver = self._get_command_result(PCI_VERSION_COMMAND)
if valid:
if pci_ver:
board_ver = re.search(r"\(rev ([0-9]{2})\)$", pci_ver)
if board_ver:
board_ver = board_ver.group(1).strip()
board_type = 'B0' if board_ver == '02' else 'C0'
cpld_ver = self._get_cpld_version()
avail_ver = version.get(board_type) if board_type == 'B0' else cpld_ver
else:
print(version)

elif self.index == 3: # SSD
valid, version = self._get_available_firmware_version(image_path)
ssd_ver = self._get_command_result(SSD_VERSION_COMMAND)
if valid:
if ssd_ver:
ssd_model = re.search(r'Device Model\s*:.*(3IE[3]{0,1})', ssd_ver)
if ssd_model:
ssd_model = ssd_model.group(1).strip()
avail_ver = version.get(ssd_model)
else:
print(version)

return avail_ver if avail_ver else "NA"

def install_firmware(self, image_path):
"""
Expand Down