[REBOOT REASON] Differentiate reset reasons between REQ vs DFU vs crashes
diff --git a/cmd/img_mgmt/include/img_mgmt/img_mgmt.h b/cmd/img_mgmt/include/img_mgmt/img_mgmt.h
index 333caca..4385477 100644
--- a/cmd/img_mgmt/include/img_mgmt/img_mgmt.h
+++ b/cmd/img_mgmt/include/img_mgmt/img_mgmt.h
@@ -161,6 +161,13 @@
int img_mgmt_slot_in_use(int slot);
/**
+ * @brief Check if the DFU status is pending
+ *
+ * @return 1 if there's pending DFU otherwise 0.
+ */
+int img_mgmt_state_any_pending(void);
+
+/**
* @brief Collects information about the specified image slot
*
* @param query_slot Slot to read state flags from
diff --git a/cmd/img_mgmt/src/img_mgmt_state.c b/cmd/img_mgmt/src/img_mgmt_state.c
index 05798a8..9db0a6a 100644
--- a/cmd/img_mgmt/src/img_mgmt_state.c
+++ b/cmd/img_mgmt/src/img_mgmt_state.c
@@ -89,7 +89,7 @@
* Indicates whether any image slot is pending (i.e., whether a test swap will
* happen on the next reboot.
*/
-static int
+int
img_mgmt_state_any_pending(void)
{
return img_mgmt_state_flags(0) & IMG_MGMT_STATE_F_PENDING ||
diff --git a/cmd/os_mgmt/port/mynewt/src/mynewt_os_mgmt.c b/cmd/os_mgmt/port/mynewt/src/mynewt_os_mgmt.c
index 46fd612..b93804b 100644
--- a/cmd/os_mgmt/port/mynewt/src/mynewt_os_mgmt.c
+++ b/cmd/os_mgmt/port/mynewt/src/mynewt_os_mgmt.c
@@ -26,6 +26,7 @@
#include "os_mgmt/os_mgmt_impl.h"
#include "os_mgmt/os_mgmt.h"
#include "mgmt/mgmt.h"
+#include "img_mgmt/img_mgmt.h"
static struct os_callout mynewt_os_mgmt_reset_callout;
@@ -111,6 +112,10 @@
.line = 0,
.pc = 0,
};
+
+ if (img_mgmt_state_any_pending()) {
+ info.reason = HAL_RESET_DFU;
+ }
#endif
os_callout_init(&mynewt_os_mgmt_reset_callout, os_eventq_dflt_get(),
mynewt_os_mgmt_reset_tmo, NULL);