You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2019/10/17 00:37:16 UTC

[mynewt-mcumgr] branch master updated: [REBOOT REASON] Differentiate reset reasons between REQ vs DFU vs crashes

This is an automated email from the ASF dual-hosted git repository.

vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git


The following commit(s) were added to refs/heads/master by this push:
     new 345fb47  [REBOOT REASON] Differentiate reset reasons between REQ vs DFU vs crashes
     new 6475202  Merge pull request #37 from manish-sudo/dfu_reset_reason
345fb47 is described below

commit 345fb4773180dbde24f651514b3692aa4c62048c
Author: Manish <ma...@juul.com>
AuthorDate: Wed Oct 16 14:07:29 2019 -0700

    [REBOOT REASON] Differentiate reset reasons between REQ vs DFU vs crashes
---
 cmd/img_mgmt/include/img_mgmt/img_mgmt.h     | 7 +++++++
 cmd/img_mgmt/src/img_mgmt_state.c            | 2 +-
 cmd/os_mgmt/port/mynewt/src/mynewt_os_mgmt.c | 5 +++++
 3 files changed, 13 insertions(+), 1 deletion(-)

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_ver_str(const struct image_version *ver, char *dst);
 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 @@ img_mgmt_state_flags(int query_slot)
  * 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 @@ os_mgmt_impl_reset(unsigned int delay_ms)
         .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);