pinhole: check for bmc reset reason
If firmware can not determine the reason for the BMC reset via the sysfs
bootstatus value then look for the pinhole rest GPIO to see if that is
the reason for the reboot.
See the following for more details:
https://github.com/openbmc/docs/blob/master/designs/power-recovery.md
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: If8e6e8cdc54dcb5f596d530c03c4676117fc8a47
diff --git a/bmc_state_manager.cpp b/bmc_state_manager.cpp
index c3c1c7d..b248b01 100644
--- a/bmc_state_manager.cpp
+++ b/bmc_state_manager.cpp
@@ -1,7 +1,9 @@
#include "bmc_state_manager.hpp"
+#include "utils.hpp"
#include "xyz/openbmc_project/Common/error.hpp"
+#include <gpiod.h>
#include <sys/sysinfo.h>
#include <phosphor-logging/elog-errors.hpp>
@@ -276,15 +278,28 @@
{
case WDIOF_EXTERN1:
this->lastRebootCause(RebootCause::Watchdog);
- break;
+ return;
case WDIOF_CARDRESET:
this->lastRebootCause(RebootCause::POR);
- break;
+ return;
default:
this->lastRebootCause(RebootCause::Unknown);
+ // Continue below to see if more details can be found
+ // on reason for reboot
break;
}
+ // If the above code could not detect a reason, look for a the
+ // reset-cause-pinhole gpio to see if it is the reason for the reboot
+ auto gpioval =
+ phosphor::state::manager::utils::getGpioValue("reset-cause-pinhole");
+
+ if (1 == gpioval)
+ {
+ info("The BMC reset was caused by a pinhole reset");
+ this->lastRebootCause(RebootCause::PinholeReset);
+ }
+
return;
}
diff --git a/meson.build b/meson.build
index 8bafd18..1ac11e8 100644
--- a/meson.build
+++ b/meson.build
@@ -112,9 +112,10 @@
executable('phosphor-bmc-state-manager',
'bmc_state_manager.cpp',
'bmc_state_manager_main.cpp',
+ 'utils.cpp',
dependencies: [
sdbusplus, sdeventplus, phosphorlogging,
- phosphordbusinterfaces, cppfs
+ phosphordbusinterfaces, cppfs, libgpiod
],
implicit_include_directories: true,
install: true