From 889d2f6e2d0ffa97e0abb43582c91a47e0edadb6 Mon Sep 17 00:00:00 2001 From: st Date: Fri, 15 Nov 2019 18:35:18 +0530 Subject: [PATCH 1/7] [DellEMC] S6100 Last Reboot Reason Thermal Support --- files/image_config/platform/rc.local | 7 ++ .../debian/platform-modules-s6100.install | 3 + .../s6100/scripts/fast-reboot_plugin | 6 ++ .../s6100/scripts/platform_reboot_override | 7 ++ .../s6100/scripts/s6100_platform.sh | 18 +---- .../s6100/scripts/track_reboot_reason.sh | 75 +++++++++++++++++++ .../s6100/scripts/warm-reboot_plugin | 1 + .../s6100/sonic_platform/chassis.py | 21 +++++- 8 files changed, 119 insertions(+), 19 deletions(-) create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh create mode 120000 platform/broadcom/sonic-platform-modules-dell/s6100/scripts/warm-reboot_plugin diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index b74e9f40c4b0..067b2ceb74a3 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -240,6 +240,13 @@ if [ -f $FIRST_BOOT_FILE ]; then # Notify firstboot to Platform, to use it for reboot-cause touch /tmp/notify_firstboot_to_platform + # create reboot-cause/platform/$platform/ directory + # /host/reboot-cause/platform/reboot-reason + # will be used to track last reboot reason + if [ ! -d /host/reboot-cause/platform ]; then + mkdir -p /host/reboot-cause/platform + fi + if [ -d /host/image-$SONIC_VERSION/platform/$platform ]; then dpkg -i /host/image-$SONIC_VERSION/platform/$platform/*.deb fi diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install index b0c27702cb4a..7a8183f0a0b6 100644 --- a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install +++ b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install @@ -3,6 +3,9 @@ s6100/scripts/s6100_platform.sh usr/local/bin common/dell_i2c_utils.sh usr/local/bin common/io_rd_wr.py usr/local/bin s6100/scripts/platform_reboot_override usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 +s6100/scripts/fast-reboot_plugin usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 +s6100/scripts/track_reboot_reason.sh usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 +s6100/scripts/warm-reboot_plugin usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 s6100/scripts/override.conf /etc/systemd/system/systemd-reboot.service.d common/dell_lpc_mon.sh usr/local/bin s6100/scripts/platform_sensors.py usr/local/bin diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin new file mode 100755 index 000000000000..d385be3bc685 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin @@ -0,0 +1,6 @@ +#!/bin/bash + +if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then + cd /sys/devices/platform/SMF.512/hwmon/* + echo 0xcc > mb_poweron_reason +fi diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_reboot_override b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_reboot_override index 3e165630658b..70431a941705 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_reboot_override +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_reboot_override @@ -1,11 +1,17 @@ #!/usr/bin/python import sys import os +import subprocess import struct PORT_RES = '/dev/port' +def track_reboot(): + # Run plugin script which will track the cli triggered reboot, fastboot, warmboot + res = subprocess.check_output(['/usr/share/sonic/device/x86_64-dell_s6100_c2538-r0/fast-reboot_plugin']) + return + def portio_reg_write(resource, offset, val): fd = os.open(resource, os.O_RDWR) if(fd < 0): @@ -21,5 +27,6 @@ def portio_reg_write(resource, offset, val): os.close(fd) if __name__ == "__main__": + track_reboot() portio_reg_write(PORT_RES, 0xcf9, 0xe) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh index 52eb757ad696..03014d7e5c56 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh @@ -218,21 +218,9 @@ reset_muxes() { } track_reboot_reason() { - if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then - rv=$(cd /sys/devices/platform/SMF.512/hwmon/*; cat mb_poweron_reason) - reason=$(echo $rv | cut -d 'x' -f2) - if [ $reason == "ff" ]; then - cd /sys/devices/platform/SMF.512/hwmon/* - if [[ -e /tmp/notify_firstboot_to_platform ]]; then - echo 0x01 > mb_poweron_reason - else - echo 0xbb > mb_poweron_reason - fi - elif [ $reason == "bb" ] || [ $reason == "1" ]; then - cd /sys/devices/platform/SMF.512/hwmon/* - echo 0xaa > mb_poweron_reason - fi - fi + /usr/share/sonic/device/x86_64-dell_s6100_c2538-r0/track_reboot_reason.sh + status=$(echo $?) + return status } install_python_api_package() { diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh new file mode 100755 index 000000000000..7fdfd3b097e4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +reboot_dir_found=false +reboot_file_found=false + +if [[ -d /host/reboot-cause/platform ]]; then + reboot_dir_found=true + if [[ -f /host/reboot-cause/platform/reboot_reason ]]; then + reboot_file_found=true + fi +fi + +is_thermal_reset() { + prev_thermal=$(cat /host/reboot-cause/platform/reboot_reason) + curr_poweron_reason=$(cat /sys/devices/platform/SMF.512/hwmon/*/smf_poweron_reason) + if [[ $curr_poweron_reason = "11" ]]; then + echo 0 + return 0 + fi + if [[ $prev_thermal = $curr_poweron_reason ]]; then + echo 0 + return 0 + else + echo "$curr_poweron_reason" > /host/reboot-cause/platform/reboot_reason + echo 1 + return 1 + fi + + echo 0 + return 0 +} + +is_watchdog_reset(){ + curr_reset_reason=$(cat /sys/devices/platform/SMF.512/hwmon/*/smf_reset_reason) + if [[ $curr_reset_reason = "33" ]]; then + echo 1 + return 1 + fi + + echo 0 + return 0 +} + +_track_reboot_reason(){ + if [[ $reboot_file_found = false ]]; then + echo "None" > /host/reboot-cause/platform/reboot_reason + fi + + if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then + is_thermal_reboot=$(is_thermal_reset) + + is_wd_reboot=$(is_watchdog_reset) + + rv=$(cat /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason) + reason=$(echo $rv | cut -d 'x' -f2) + if [[ $reason = "ff" ]]; then + echo "None" > /host/reboot-cause/platform/reboot_reason + if [[ -e /tmp/notify_firstboot_to_platform ]]; then + echo 0x01 > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + else + echo 0xbb > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + fi + elif [[ $is_thermal_reboot = 1 ]]; then + echo 0xee > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + elif [[ $is_wd_reboot = 1 ]] && [[ $reason != "cc" ]]; then + echo 0xdd > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + elif [[ $reason = "cc" ]]; then + echo 0xaa > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + else + echo 0x99 > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + fi + fi +} + +_track_reboot_reason diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/warm-reboot_plugin b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/warm-reboot_plugin new file mode 120000 index 000000000000..180742bbc4d5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/warm-reboot_plugin @@ -0,0 +1 @@ +fast-reboot_plugin \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py index e39e8480e2c7..b3058479d95e 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py @@ -43,6 +43,8 @@ class Chassis(ChassisBase): reset_reason_dict[33] = ChassisBase.REBOOT_CAUSE_WATCHDOG reset_reason_dict[44] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE reset_reason_dict[55] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE + reset_reason_dict[66] = ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER + reset_reason_dict[77] = ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER power_reason_dict = {} power_reason_dict[11] = ChassisBase.REBOOT_CAUSE_POWER_LOSS @@ -204,10 +206,21 @@ def get_reboot_cause(self): if (power_reason in self.power_reason_dict): return (self.power_reason_dict[power_reason], None) else: - if ((smf_mb_reg_reason == 0xbb) or (smf_mb_reg_reason == 0xff)): + if (smf_mb_reg_reason == 0xaa): + return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) + elif ((smf_mb_reg_reason == 0xbb) or (smf_mb_reg_reason == 0xff)): return (ChassisBase.REBOOT_CAUSE_POWER_LOSS, None) - - if (reset_reason in self.reset_reason_dict): - return (self.reset_reason_dict[reset_reason], None) + elif (smf_mb_reg_reason == 0xdd): + return (ChassisBase.REBOOT_CAUSE_WATCHDOG, None) + elif (smf_mb_reg_reason == 0xee): + return (self.power_reason_dict[power_reason], None) + elif (reset_reason == 66): + return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, + "Emulated Cold Reset") + elif (reset_reason == 77): + return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, + "Emulated Warm Reset") + else: + return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, "Invalid Reason") From 05394e659cd843d26cecace555389bb4a842705f Mon Sep 17 00:00:00 2001 From: st Date: Fri, 15 Nov 2019 18:49:41 +0530 Subject: [PATCH 2/7] [DellEMC]S6100 Last Reboot Reason Thermal --- .../s6100/scripts/track_reboot_reason.sh | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh index 7fdfd3b097e4..9f6c1988a948 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh @@ -6,7 +6,7 @@ reboot_file_found=false if [[ -d /host/reboot-cause/platform ]]; then reboot_dir_found=true if [[ -f /host/reboot-cause/platform/reboot_reason ]]; then - reboot_file_found=true + reboot_file_found=true fi fi @@ -18,14 +18,14 @@ is_thermal_reset() { return 0 fi if [[ $prev_thermal = $curr_poweron_reason ]]; then - echo 0 - return 0 + echo 0 + return 0 else - echo "$curr_poweron_reason" > /host/reboot-cause/platform/reboot_reason - echo 1 - return 1 + echo "$curr_poweron_reason" > /host/reboot-cause/platform/reboot_reason + echo 1 + return 1 fi - + echo 0 return 0 } @@ -33,8 +33,8 @@ is_thermal_reset() { is_watchdog_reset(){ curr_reset_reason=$(cat /sys/devices/platform/SMF.512/hwmon/*/smf_reset_reason) if [[ $curr_reset_reason = "33" ]]; then - echo 1 - return 1 + echo 1 + return 1 fi echo 0 @@ -43,18 +43,18 @@ is_watchdog_reset(){ _track_reboot_reason(){ if [[ $reboot_file_found = false ]]; then - echo "None" > /host/reboot-cause/platform/reboot_reason + echo "None" > /host/reboot-cause/platform/reboot_reason fi if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then is_thermal_reboot=$(is_thermal_reset) - is_wd_reboot=$(is_watchdog_reset) + is_wd_reboot=$(is_watchdog_reset) rv=$(cat /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason) reason=$(echo $rv | cut -d 'x' -f2) if [[ $reason = "ff" ]]; then - echo "None" > /host/reboot-cause/platform/reboot_reason + echo "None" > /host/reboot-cause/platform/reboot_reason if [[ -e /tmp/notify_firstboot_to_platform ]]; then echo 0x01 > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason else @@ -62,8 +62,8 @@ _track_reboot_reason(){ fi elif [[ $is_thermal_reboot = 1 ]]; then echo 0xee > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason - elif [[ $is_wd_reboot = 1 ]] && [[ $reason != "cc" ]]; then - echo 0xdd > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + elif [[ $is_wd_reboot = 1 ]] && [[ $reason != "cc" ]]; then + echo 0xdd > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason elif [[ $reason = "cc" ]]; then echo 0xaa > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason else From 6425bb3d4f383931323c39975d33e0cbb71eadc9 Mon Sep 17 00:00:00 2001 From: st Date: Wed, 4 Dec 2019 16:49:30 +0530 Subject: [PATCH 3/7] code refactoring and adding unknown software reboot support --- .../s6100/scripts/platform_reboot_override | 4 +- .../s6100/scripts/s6100_platform.sh | 4 +- .../s6100/scripts/track_reboot_reason.sh | 65 ++++++++++++------- .../s6100/sonic_platform/chassis.py | 5 +- 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_reboot_override b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_reboot_override index 70431a941705..dcec8067054a 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_reboot_override +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/platform_reboot_override @@ -7,7 +7,7 @@ import struct PORT_RES = '/dev/port' -def track_reboot(): +def log_software_reboot(): # Run plugin script which will track the cli triggered reboot, fastboot, warmboot res = subprocess.check_output(['/usr/share/sonic/device/x86_64-dell_s6100_c2538-r0/fast-reboot_plugin']) return @@ -27,6 +27,6 @@ def portio_reg_write(resource, offset, val): os.close(fd) if __name__ == "__main__": - track_reboot() + log_software_reboot() portio_reg_write(PORT_RES, 0xcf9, 0xe) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh index 03014d7e5c56..17d8392e0092 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh @@ -217,7 +217,7 @@ reset_muxes() { io_rd_wr.py --set --val 0xff --offset 0x20b } -track_reboot_reason() { +init_reset_reason() { /usr/share/sonic/device/x86_64-dell_s6100_c2538-r0/track_reboot_reason.sh status=$(echo $?) return status @@ -245,7 +245,7 @@ if [[ "$1" == "init" ]]; then modprobe dell_ich modprobe dell_s6100_iom_cpld modprobe dell_s6100_lpc - track_reboot_reason + init_reset_reason # Disable Watchdog Timer if [[ -e /usr/local/bin/platform_watchdog_disable.sh ]]; then diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh index 9f6c1988a948..2a647ff00993 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh @@ -3,25 +3,31 @@ reboot_dir_found=false reboot_file_found=false +REBOOT_CAUSE_FILE=/host/reboot-cause/reboot-cause.txt +REBOOT_REASON=/host/reboot-cause/platform/reboot_reason +SMF_POWERON_REASON=/sys/devices/platform/SMF.512/hwmon/*/smf_poweron_reason +SMF_RESET_REASON=/sys/devices/platform/SMF.512/hwmon/*/smf_reset_reason +MAILBOX_POWERON_REASON=/sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + if [[ -d /host/reboot-cause/platform ]]; then reboot_dir_found=true - if [[ -f /host/reboot-cause/platform/reboot_reason ]]; then + if [[ -f $REBOOT_REASON ]]; then reboot_file_found=true fi fi -is_thermal_reset() { - prev_thermal=$(cat /host/reboot-cause/platform/reboot_reason) - curr_poweron_reason=$(cat /sys/devices/platform/SMF.512/hwmon/*/smf_poweron_reason) +_is_thermal_reset() { + prev_thermal=$(cat $REBOOT_REASON) + curr_poweron_reason=$(cat $SMF_POWERON_REASON) if [[ $curr_poweron_reason = "11" ]]; then echo 0 return 0 fi if [[ $prev_thermal = $curr_poweron_reason ]]; then - echo 0 - return 0 + echo 2 + return 2 else - echo "$curr_poweron_reason" > /host/reboot-cause/platform/reboot_reason + echo "$curr_poweron_reason" > $REBOOT_REASON echo 1 return 1 fi @@ -30,8 +36,8 @@ is_thermal_reset() { return 0 } -is_watchdog_reset(){ - curr_reset_reason=$(cat /sys/devices/platform/SMF.512/hwmon/*/smf_reset_reason) +_is_watchdog_reset(){ + curr_reset_reason=$(cat $SMF_RESET_REASON) if [[ $curr_reset_reason = "33" ]]; then echo 1 return 1 @@ -41,35 +47,50 @@ is_watchdog_reset(){ return 0 } -_track_reboot_reason(){ +_is_unknown_reset(){ + if [[ -f $REBOOT_CAUSE_FILE ]]; then + if [[ $1 = 0 ]]; then + echo "Unknown software reboot" > $REBOOT_CAUSE_FILE + return + fi + curr_poweron_reason=$(cat $SMF_POWERON_REASON) + curr_reset_reason=$(cat $SMF_RESET_REASON) + mb_poweron_reason=$(cat $MAILBOX_POWERON_REASON) + echo "Unknown POR: $curr_poweron_reason RST: $curr_reset_reason MBR: $mb_poweron_reason" > $REBOOT_CAUSE_FILE + fi + +} + +update_mailbox_register(){ if [[ $reboot_file_found = false ]]; then - echo "None" > /host/reboot-cause/platform/reboot_reason + echo "None" > $REBOOT_REASON fi if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then - is_thermal_reboot=$(is_thermal_reset) + is_thermal_reboot=$(_is_thermal_reset) - is_wd_reboot=$(is_watchdog_reset) + is_wd_reboot=$(_is_watchdog_reset) - rv=$(cat /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason) + rv=$(cat $MAILBOX_POWERON_REASON) reason=$(echo $rv | cut -d 'x' -f2) if [[ $reason = "ff" ]]; then - echo "None" > /host/reboot-cause/platform/reboot_reason + echo "None" > $REBOOT_REASON if [[ -e /tmp/notify_firstboot_to_platform ]]; then - echo 0x01 > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + echo 0x01 > $MAILBOX_POWERON_REASON else - echo 0xbb > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + echo 0xbb > $MAILBOX_POWERON_REASON fi elif [[ $is_thermal_reboot = 1 ]]; then - echo 0xee > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + echo 0xee > $MAILBOX_POWERON_REASON elif [[ $is_wd_reboot = 1 ]] && [[ $reason != "cc" ]]; then - echo 0xdd > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + echo 0xdd > $MAILBOX_POWERON_REASON elif [[ $reason = "cc" ]]; then - echo 0xaa > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + echo 0xaa > $MAILBOX_POWERON_REASON else - echo 0x99 > /sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason + _is_unknown_reset $is_thermal_reboot + echo 0x99 > $MAILBOX_POWERON_REASON fi fi } -_track_reboot_reason +update_mailbox_register diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py index b3058479d95e..0e21f941b06c 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py @@ -18,6 +18,7 @@ from sonic_platform.module import Module from sonic_platform.thermal import Thermal from sonic_platform.component import Component + from sonic_platform.watchdog import Watchdog from eeprom import Eeprom except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -77,6 +78,8 @@ def __init__(self): component = Component(i) self._component_list.append(component) + self._watchdog = Watchdog() + def _get_reboot_reason_smf_register(self): # Returns 0xAA on software reload # Returns 0xFF on power-cycle @@ -202,7 +205,7 @@ def get_reboot_cause(self): # In S6100, if Reset_Reason is not 11 and smf_mb_reg_reason # is ff or bb, then it is PowerLoss - if (reset_reason == 11): + if (reset_reason == 11 and smf_mb_reg_reason != 0x99): if (power_reason in self.power_reason_dict): return (self.power_reason_dict[power_reason], None) else: From 858c4c3cfadecb986d8478416d0a8e5a2be915d9 Mon Sep 17 00:00:00 2001 From: st Date: Thu, 9 Jan 2020 20:55:52 +0530 Subject: [PATCH 4/7] Added newer BIOS based changes, dependency changes --- .../common/nvram_rd_wr.py | 97 +++++++++++++++ .../debian/platform-modules-s6100.install | 2 + .../s6100/scripts/s6100_platform.sh | 10 +- .../s6100/scripts/track_reboot_reason.sh | 114 ++++++++++++++---- .../s6100/sonic_platform/chassis.py | 55 ++++----- .../s6100/sonic_platform/eeprom.py | 7 +- .../s6100/systemd/s6100-reboot-cause.service | 12 ++ 7 files changed, 233 insertions(+), 64 deletions(-) create mode 100755 platform/broadcom/sonic-platform-modules-dell/common/nvram_rd_wr.py create mode 100644 platform/broadcom/sonic-platform-modules-dell/s6100/systemd/s6100-reboot-cause.service diff --git a/platform/broadcom/sonic-platform-modules-dell/common/nvram_rd_wr.py b/platform/broadcom/sonic-platform-modules-dell/common/nvram_rd_wr.py new file mode 100755 index 000000000000..30108892741b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/common/nvram_rd_wr.py @@ -0,0 +1,97 @@ +#!/usr/bin/python +#Script to read/write the nvram + +import sys +import os +import getopt +import struct + +nvram_resource='/dev/nvram' + +def usage(): + ''' This is the Usage Method ''' + + print 'Utility for NVRAM read/write' + print '\t\t nvram_rd_wr.py --get --offset ' + print '\t\t nvram_rd_wr.py --set --val --offset ' + sys.exit(1) + +def nvram_reg_read(nvram_resource,offset): + fd=os.open(nvram_resource, os.O_RDONLY) + if(fd<0): + print 'file open failed %s"%nvram_resource' + return + if(os.lseek(fd, offset, os.SEEK_SET) != offset): + print 'lseek failed on %s'%nvram_resource + return + buf=os.read(fd,1) + reg_val1=ord(buf) + print 'value %x'%reg_val1 + os.close(fd) + +def nvram_reg_write(nvram_resource,offset,val): + fd=os.open(nvram_resource,os.O_RDWR) + if(fd<0): + print 'file open failed %s"%nvram_resource' + return + if(os.lseek(fd, offset, os.SEEK_SET) != offset): + print 'lseek failed on %s'%nvram_resource + return + ret=os.write(fd,struct.pack('B',val)) + if(ret != 1): + print 'write failed %d'%ret + return + os.close(fd) + +def main(argv): + + ''' The main function will read the user input from the + command line argument and process the request ''' + + opts = '' + val = '' + choice = '' + resouce = '' + offset = '' + + try: + opts, args = getopt.getopt(argv, "hgs:" , \ + ["val=","offset=","help", "get", "set"]) + + except getopt.GetoptError: + usage() + + if not os.path.exists(nvram_resource): + print 'NVRAM is not initialized' + sys.exit(1) + + for opt,arg in opts: + + if opt in ('-h','--help'): + choice = 'help' + + elif opt in ('-g', '--get'): + choice = 'get' + + elif opt in ('-s', '--set'): + choice = 'set' + + elif opt == '--offset': + offset = int(arg,16) - 0xE + + elif opt == '--val': + val = int(arg,16) + + if choice == 'get' and offset != '': + nvram_reg_read(nvram_resource,offset) + + elif choice == 'set' and offset != '' and val != '': + nvram_reg_write(nvram_resource,offset,val) + + else: + usage() + +#Calling the main method +if __name__ == "__main__": + main(sys.argv[1:]) + diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install index 7a8183f0a0b6..cc3d3384cd7e 100644 --- a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install +++ b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install @@ -2,6 +2,7 @@ s6100/scripts/iom_power_*.sh usr/local/bin s6100/scripts/s6100_platform.sh usr/local/bin common/dell_i2c_utils.sh usr/local/bin common/io_rd_wr.py usr/local/bin +common/nvram_rd_wr.py usr/local/bin s6100/scripts/platform_reboot_override usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 s6100/scripts/fast-reboot_plugin usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 s6100/scripts/track_reboot_reason.sh usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 @@ -15,4 +16,5 @@ s6100/scripts/platform_watchdog_disable.sh usr/local/bin s6100/scripts/sensors usr/bin s6100/systemd/platform-modules-s6100.service etc/systemd/system s6100/systemd/s6100-lpc-monitor.service etc/systemd/system +s6100/systemd/s6100-reboot-cause.service etc/systemd/system tools/flashrom/flashrom usr/local/bin/ diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh index 17d8392e0092..21dff92f7b55 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_platform.sh @@ -217,12 +217,6 @@ reset_muxes() { io_rd_wr.py --set --val 0xff --offset 0x20b } -init_reset_reason() { - /usr/share/sonic/device/x86_64-dell_s6100_c2538-r0/track_reboot_reason.sh - status=$(echo $?) - return status -} - install_python_api_package() { device="/usr/share/sonic/device" platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) @@ -245,7 +239,8 @@ if [[ "$1" == "init" ]]; then modprobe dell_ich modprobe dell_s6100_iom_cpld modprobe dell_s6100_lpc - init_reset_reason + modprobe nvram + systemctl start s6100-reboot-cause.service # Disable Watchdog Timer if [[ -e /usr/local/bin/platform_watchdog_disable.sh ]]; then @@ -279,6 +274,7 @@ elif [[ "$1" == "deinit" ]]; then modprobe -r i2c-mux-pca954x modprobe -r i2c-dev modprobe -r dell_ich + modprobe -r nvram remove_python_api_package else echo "s6100_platform : Invalid option !" diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh index 2a647ff00993..9845ccf6cb0e 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh @@ -2,49 +2,120 @@ reboot_dir_found=false reboot_file_found=false +smf_dir_missing=0 +nvram_missing=0 REBOOT_CAUSE_FILE=/host/reboot-cause/reboot-cause.txt -REBOOT_REASON=/host/reboot-cause/platform/reboot_reason +REBOOT_REASON_FILE=/host/reboot-cause/platform/reboot_reason +BIOS_VERSION_FILE=/host/reboot-cause/platform/bios_minor_version SMF_POWERON_REASON=/sys/devices/platform/SMF.512/hwmon/*/smf_poweron_reason SMF_RESET_REASON=/sys/devices/platform/SMF.512/hwmon/*/smf_reset_reason MAILBOX_POWERON_REASON=/sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason +NVRAM_DEVICE_FILE=/dev/nvram +RESET_REASON_FILE=/host/reboot-cause/platform/reset_reason +SMF_DIR=/sys/devices/platform/SMF.512/hwmon/ + +while [[ ! -d $SMF_DIR ]] +do + sleep 0.5 + let smf_dir_missing=$smf_dir_missing+1 + if [[ "$smf_dir_missing" = "5" ]]; then + echo "SMF is not initialized" + smf_dir_missing=0 + fi +done + +SMF_RESET=$(cat $SMF_RESET_REASON) if [[ -d /host/reboot-cause/platform ]]; then reboot_dir_found=true - if [[ -f $REBOOT_REASON ]]; then + if [[ -f $REBOOT_REASON_FILE ]]; then reboot_file_found=true fi fi +SMF_BIOS_REG=$(io_rd_wr.py --get --offset 0x203 | cut -d " " -f 3) +SMF_BIOS_REG=$((16#$SMF_BIOS_REG)) +bios_secondary_boot=$(($SMF_BIOS_REG & 1)) + +_get_smf_reset_register(){ + BIOS_VERSION=$(/usr/sbin/dmidecode -s system-version) + BIOS_VERSION_MINOR=$(echo $BIOS_VERSION | cut -d'-' -f 2) + + if [[ $BIOS_VERSION_MINOR -gt 7 ]]; then + echo $BIOS_VERSION > $BIOS_VERSION_FILE + elif [[ "$bios_secondary_boot" = "0" ]]; then + # For Primary BIOS with older version + if [[ -e $BIOS_VERSION_FILE ]]; then + rm $BIOS_VERSION_FILE + fi + fi + + if [[ -e $BIOS_VERSION_FILE ]]; then + while [[ ! -e $NVRAM_DEVICE_FILE ]] + do + sleep 1 + let nvram_missing=$nvram_missing+1 + if [[ "$nvram_missing" = "5" ]]; then + echo "NVRAM is not initialized" + nvram_missing=0 + fi + done + first_reset=$(nvram_rd_wr.py --get --offset 0x5c | cut -d " " -f 2) + second_reset=$(nvram_rd_wr.py --get --offset 0x5d | cut -d " " -f 2) + third_reset=$(nvram_rd_wr.py --get --offset 0x5e | cut -d " " -f 2) + fourth_reset=$(nvram_rd_wr.py --get --offset 0x5f | cut -d " " -f 2) + + if [[ "$first_reset" != "ee" ]]; then + SMF_RESET=$first_reset + fi + + # Saving NVRAM values for future debugging + if [[ $reboot_dir_found = true ]]; then + echo "First reset - $first_reset" > $RESET_REASON_FILE + echo "Second reset - $second_reset" >> $RESET_REASON_FILE + echo "Third reset - $third_reset" >> $RESET_REASON_FILE + echo "Fourth reset - $fourth_reset" >> $RESET_REASON_FILE + fi + + # Clearing NVRAM values to holding next reset values + nvram_rd_wr.py --set --val 0xee --offset 0x58 + nvram_rd_wr.py --set --val 0xee --offset 0x5c + nvram_rd_wr.py --set --val 0xee --offset 0x5d + nvram_rd_wr.py --set --val 0xee --offset 0x5e + nvram_rd_wr.py --set --val 0xee --offset 0x5f + fi +} + _is_thermal_reset() { - prev_thermal=$(cat $REBOOT_REASON) + prev_thermal=$(cat $REBOOT_REASON_FILE) curr_poweron_reason=$(cat $SMF_POWERON_REASON) if [[ $curr_poweron_reason = "11" ]]; then echo 0 - return 0 + return fi if [[ $prev_thermal = $curr_poweron_reason ]]; then echo 2 - return 2 + return else - echo "$curr_poweron_reason" > $REBOOT_REASON + echo "$curr_poweron_reason" > $REBOOT_REASON_FILE echo 1 - return 1 + return fi echo 0 - return 0 + return } _is_watchdog_reset(){ - curr_reset_reason=$(cat $SMF_RESET_REASON) + curr_reset_reason=$SMF_RESET if [[ $curr_reset_reason = "33" ]]; then echo 1 - return 1 + return fi echo 0 - return 0 + return } _is_unknown_reset(){ @@ -54,7 +125,7 @@ _is_unknown_reset(){ return fi curr_poweron_reason=$(cat $SMF_POWERON_REASON) - curr_reset_reason=$(cat $SMF_RESET_REASON) + curr_reset_reason=$SMF_RESET mb_poweron_reason=$(cat $MAILBOX_POWERON_REASON) echo "Unknown POR: $curr_poweron_reason RST: $curr_reset_reason MBR: $mb_poweron_reason" > $REBOOT_CAUSE_FILE fi @@ -62,24 +133,25 @@ _is_unknown_reset(){ } update_mailbox_register(){ + if [[ "$bios_secondary_boot" = "1" ]]; then + echo "Secondary BIOS booted" + fi + if [[ $reboot_file_found = false ]]; then - echo "None" > $REBOOT_REASON + echo "None" > $REBOOT_REASON_FILE fi + _get_smf_reset_register if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then is_thermal_reboot=$(_is_thermal_reset) is_wd_reboot=$(_is_watchdog_reset) - rv=$(cat $MAILBOX_POWERON_REASON) - reason=$(echo $rv | cut -d 'x' -f2) + mbr=$(cat $MAILBOX_POWERON_REASON) + reason=$(echo $mbr | cut -d 'x' -f2) if [[ $reason = "ff" ]]; then - echo "None" > $REBOOT_REASON - if [[ -e /tmp/notify_firstboot_to_platform ]]; then - echo 0x01 > $MAILBOX_POWERON_REASON - else - echo 0xbb > $MAILBOX_POWERON_REASON - fi + echo "None" > $REBOOT_REASON_FILE + echo 0xbb > $MAILBOX_POWERON_REASON elif [[ $is_thermal_reboot = 1 ]]; then echo 0xee > $MAILBOX_POWERON_REASON elif [[ $is_wd_reboot = 1 ]] && [[ $reason != "cc" ]]; then diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py index 0e21f941b06c..2ae528ddb85f 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py @@ -20,6 +20,7 @@ from sonic_platform.component import Component from sonic_platform.watchdog import Watchdog from eeprom import Eeprom + import time except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -81,9 +82,12 @@ def __init__(self): self._watchdog = Watchdog() def _get_reboot_reason_smf_register(self): - # Returns 0xAA on software reload - # Returns 0xFF on power-cycle - # Returns 0x01 on first-boot + # In S6100, mb_poweron_reason register will + # Returns 0xaa or 0xcc on software reload + # Returns 0xff or 0xbb on power-cycle + # Returns 0xdd on Watchdog + # Returns 0xee on Thermal Shutdown + # Returns 0x99 on Unknown reset smf_mb_reg_reason = self._get_pmc_register('mb_poweron_reason') return int(smf_mb_reg_reason, 16) @@ -192,38 +196,21 @@ def get_reboot_cause(self): power_reason = int(self._get_pmc_register('smf_poweron_reason')) smf_mb_reg_reason = self._get_reboot_reason_smf_register() - if ((smf_mb_reg_reason == 0x01) and (power_reason == 0x11)): + if ((smf_mb_reg_reason == 0xbb) or (smf_mb_reg_reason == 0xff)): + return (ChassisBase.REBOOT_CAUSE_POWER_LOSS, None) + elif ((smf_mb_reg_reason == 0xaa) or (smf_mb_reg_reason == 0xcc)): return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) - - # Reset_Reason = 11 ==> PowerLoss - # So return the reboot reason from Last Power_Reason Dictionary - # If Reset_Reason is not 11 return from Reset_Reason dictionary - # Also check if power_reason, reset_reason are valid values by - # checking key presence in dictionary else return - # REBOOT_CAUSE_HARDWARE_OTHER as the Power_Reason and Reset_Reason - # registers returned invalid data - - # In S6100, if Reset_Reason is not 11 and smf_mb_reg_reason - # is ff or bb, then it is PowerLoss - if (reset_reason == 11 and smf_mb_reg_reason != 0x99): - if (power_reason in self.power_reason_dict): - return (self.power_reason_dict[power_reason], None) + elif (smf_mb_reg_reason == 0xdd): + return (ChassisBase.REBOOT_CAUSE_WATCHDOG, None) + elif (smf_mb_reg_reason == 0xee): + return (self.power_reason_dict[power_reason], None) + elif (reset_reason == 66): + return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, + "Emulated Cold Reset") + elif (reset_reason == 77): + return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, + "Emulated Warm Reset") else: - if (smf_mb_reg_reason == 0xaa): - return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) - elif ((smf_mb_reg_reason == 0xbb) or (smf_mb_reg_reason == 0xff)): - return (ChassisBase.REBOOT_CAUSE_POWER_LOSS, None) - elif (smf_mb_reg_reason == 0xdd): - return (ChassisBase.REBOOT_CAUSE_WATCHDOG, None) - elif (smf_mb_reg_reason == 0xee): - return (self.power_reason_dict[power_reason], None) - elif (reset_reason == 66): - return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, - "Emulated Cold Reset") - elif (reset_reason == 77): - return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, - "Emulated Warm Reset") - else: - return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) + return (ChassisBase.REBOOT_CAUSE_NON_HARDWARE, None) return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, "Invalid Reason") diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py index 4e683e1e511b..07a172906e01 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py @@ -25,8 +25,11 @@ def __init__(self): try: self.eeprom_data = self.read_eeprom() except: - self.eeprom_data = "N/A" - raise RuntimeError("Eeprom is not Programmed") + try: + self.eeprom_data = self.read_eeprom() + except: + self.eeprom_data = "N/A" + raise RuntimeError("Eeprom is not Programmed") else: eeprom = self.eeprom_data diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/systemd/s6100-reboot-cause.service b/platform/broadcom/sonic-platform-modules-dell/s6100/systemd/s6100-reboot-cause.service new file mode 100644 index 000000000000..bcf903d56d80 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/systemd/s6100-reboot-cause.service @@ -0,0 +1,12 @@ +[Unit] +Description=Read Dell S6100 reboot cause +Before=process-reboot-cause.service +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/usr/share/sonic/device/x86_64-dell_s6100_c2538-r0/track_reboot_reason.sh +RemainAfterExit=no + +[Install] +WantedBy=multi-user.target From 7eeb6106cdfad11f2d2cbc00e2633457e36d0ca5 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar T <53558409+santhosh-kt@users.noreply.github.com> Date: Wed, 29 Jan 2020 14:38:12 +0530 Subject: [PATCH 5/7] Correcting the directory path in the comment --- files/image_config/platform/rc.local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 43b797fa6fd7..34dafac95b75 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -240,7 +240,7 @@ if [ -f $FIRST_BOOT_FILE ]; then # Notify firstboot to Platform, to use it for reboot-cause touch /tmp/notify_firstboot_to_platform - # create reboot-cause/platform/$platform/ directory + # create /host/reboot-cause/platform/ directory # /host/reboot-cause/platform/reboot-reason # will be used to track last reboot reason if [ ! -d /host/reboot-cause/platform ]; then From be2de77f2aa610990853e29ec2f6ec629a49cd9b Mon Sep 17 00:00:00 2001 From: Santhosh Kumar T <53558409+santhosh-kt@users.noreply.github.com> Date: Thu, 30 Jan 2020 11:44:58 +0530 Subject: [PATCH 6/7] Updated comments for reboot-cause platform Updated comments for reboot-cause platform directory --- files/image_config/platform/rc.local | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 34dafac95b75..4509df27773a 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -240,9 +240,8 @@ if [ -f $FIRST_BOOT_FILE ]; then # Notify firstboot to Platform, to use it for reboot-cause touch /tmp/notify_firstboot_to_platform - # create /host/reboot-cause/platform/ directory - # /host/reboot-cause/platform/reboot-reason - # will be used to track last reboot reason + # Create /host/reboot-cause/platform/ directory + # can be used to track last reboot reason by some platforms if [ ! -d /host/reboot-cause/platform ]; then mkdir -p /host/reboot-cause/platform fi From f3ad108dbdd2a843ef7ba4960991e59fd584272c Mon Sep 17 00:00:00 2001 From: st Date: Mon, 10 Feb 2020 11:40:15 +0530 Subject: [PATCH 7/7] Non-alignment spaces resolved --- files/image_config/platform/rc.local | 2 +- .../s6100/scripts/track_reboot_reason.sh | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 4509df27773a..db95292527d9 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -243,7 +243,7 @@ if [ -f $FIRST_BOOT_FILE ]; then # Create /host/reboot-cause/platform/ directory # can be used to track last reboot reason by some platforms if [ ! -d /host/reboot-cause/platform ]; then - mkdir -p /host/reboot-cause/platform + mkdir -p /host/reboot-cause/platform fi if [ -d /host/image-$SONIC_VERSION/platform/$platform ]; then diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh index 9845ccf6cb0e..0686d577c9e4 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh @@ -91,8 +91,8 @@ _is_thermal_reset() { prev_thermal=$(cat $REBOOT_REASON_FILE) curr_poweron_reason=$(cat $SMF_POWERON_REASON) if [[ $curr_poweron_reason = "11" ]]; then - echo 0 - return + echo 0 + return fi if [[ $prev_thermal = $curr_poweron_reason ]]; then echo 2 @@ -120,14 +120,14 @@ _is_watchdog_reset(){ _is_unknown_reset(){ if [[ -f $REBOOT_CAUSE_FILE ]]; then - if [[ $1 = 0 ]]; then - echo "Unknown software reboot" > $REBOOT_CAUSE_FILE - return - fi + if [[ $1 = 0 ]]; then + echo "Unknown software reboot" > $REBOOT_CAUSE_FILE + return + fi curr_poweron_reason=$(cat $SMF_POWERON_REASON) - curr_reset_reason=$SMF_RESET - mb_poweron_reason=$(cat $MAILBOX_POWERON_REASON) - echo "Unknown POR: $curr_poweron_reason RST: $curr_reset_reason MBR: $mb_poweron_reason" > $REBOOT_CAUSE_FILE + curr_reset_reason=$SMF_RESET + mb_poweron_reason=$(cat $MAILBOX_POWERON_REASON) + echo "Unknown POR: $curr_poweron_reason RST: $curr_reset_reason MBR: $mb_poweron_reason" > $REBOOT_CAUSE_FILE fi } @@ -159,7 +159,7 @@ update_mailbox_register(){ elif [[ $reason = "cc" ]]; then echo 0xaa > $MAILBOX_POWERON_REASON else - _is_unknown_reset $is_thermal_reboot + _is_unknown_reset $is_thermal_reboot echo 0x99 > $MAILBOX_POWERON_REASON fi fi