You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/12/02 19:43:20 UTC

[6/7] incubator-mynewt-core git commit: log_reboot; use hal_reset_cause when recording reboot reason at bootup.

log_reboot; use hal_reset_cause when recording reboot reason at
bootup.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/35e11e67
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/35e11e67
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/35e11e67

Branch: refs/heads/develop
Commit: 35e11e67281d4f2470f8377d8145538bdcc09579
Parents: fe3c27f
Author: System Administrator <ma...@runtime.io>
Authored: Fri Dec 2 11:41:39 2016 -0800
Committer: System Administrator <ma...@runtime.io>
Committed: Fri Dec 2 11:42:45 2016 -0800

----------------------------------------------------------------------
 apps/slinky/src/main.c                 |  2 +-
 apps/slinky_oic/src/main.c             |  2 +-
 apps/splitty/src/main.c                |  2 +-
 mgmt/newtmgr/nmgr_os/src/newtmgr_os.c  |  2 +-
 sys/reboot/include/reboot/log_reboot.h | 19 +++++++++----------
 sys/reboot/src/log_reboot.c            |  6 +++---
 6 files changed, 16 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/35e11e67/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index f4da51e..342a901 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -302,7 +302,7 @@ main(int argc, char **argv)
 
     conf_load();
 
-    log_reboot(HARD_REBOOT);
+    log_reboot(hal_reset_cause());
 
 #if MYNEWT_VAL(SPLIT_LOADER)
     {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/35e11e67/apps/slinky_oic/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky_oic/src/main.c b/apps/slinky_oic/src/main.c
index afadd33..06c7bef 100755
--- a/apps/slinky_oic/src/main.c
+++ b/apps/slinky_oic/src/main.c
@@ -294,7 +294,7 @@ main(int argc, char **argv)
 
     conf_load();
 
-    log_reboot(HARD_REBOOT);
+    log_reboot(hal_reset_cause());
 
 #if MYNEWT_VAL(SPLIT_LOADER)
     {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/35e11e67/apps/splitty/src/main.c
----------------------------------------------------------------------
diff --git a/apps/splitty/src/main.c b/apps/splitty/src/main.c
index fcb18c6..956ed1f 100755
--- a/apps/splitty/src/main.c
+++ b/apps/splitty/src/main.c
@@ -228,7 +228,7 @@ main(int argc, char **argv)
 
     conf_load();
 
-    log_reboot(HARD_REBOOT);
+    log_reboot(hal_reset_cause());
 
     init_tasks();
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/35e11e67/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c b/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
index 1dddcc3..c645ee0 100644
--- a/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
+++ b/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
@@ -323,7 +323,7 @@ nmgr_reset(struct mgmt_cbuf *cb)
 {
     os_callout_init(&nmgr_reset_callout, mgmt_evq_get(), nmgr_reset_tmo, NULL);
 
-    log_reboot(SOFT_REBOOT);
+    log_reboot(HAL_RESET_SOFT);
     os_callout_reset(&nmgr_reset_callout, OS_TICKS_PER_SEC / 4);
 
     mgmt_cbuf_setoerr(cb, OS_OK);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/35e11e67/sys/reboot/include/reboot/log_reboot.h
----------------------------------------------------------------------
diff --git a/sys/reboot/include/reboot/log_reboot.h b/sys/reboot/include/reboot/log_reboot.h
index eead387..396299c 100644
--- a/sys/reboot/include/reboot/log_reboot.h
+++ b/sys/reboot/include/reboot/log_reboot.h
@@ -23,18 +23,17 @@
 extern "C" {
 #endif
 
-#define  SOFT_REBOOT (0)
-#define  HARD_REBOOT (1)
-#define  GEN_CORE    (2)
-
-#define REBOOT_REASON_STR(reason) \
-    (SOFT_REBOOT  == reason ? "SOFT"     :\
-    (HARD_REBOOT  == reason ? "HARD"     :\
-    (GEN_CORE     == reason ? "GEN_CORE" :\
-     "UNKNOWN")))
+#include <hal/hal_system.h>
+#define REBOOT_REASON_STR(reason)                                       \
+    (reason == HAL_RESET_POR ? "HARD" :                                 \
+      (reason == HAL_RESET_PIN ? "RESET_PIN" :                          \
+        (reason == HAL_RESET_WATCHDOG ? "WDOG" :                        \
+          (reason == HAL_RESET_SOFT ? "SOFT" :                          \
+            (reason == HAL_RESET_BROWNOUT ? "BROWNOUT" :                \
+              "UNKNOWN")))))
 
 int reboot_init_handler(int log_store_type, uint8_t entries);
-int log_reboot(int reason);
+int log_reboot(enum hal_reset_reason);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/35e11e67/sys/reboot/src/log_reboot.c
----------------------------------------------------------------------
diff --git a/sys/reboot/src/log_reboot.c b/sys/reboot/src/log_reboot.c
index 0015157..7a02414 100644
--- a/sys/reboot/src/log_reboot.c
+++ b/sys/reboot/src/log_reboot.c
@@ -130,7 +130,7 @@ reboot_init_handler(int log_store_type, uint8_t entries)
  * @return 0 on success; non-zero on failure
  */
 int
-log_reboot(int reason)
+log_reboot(enum hal_reset_reason reason)
 {
     int rc;
     char str[12] = {0};
@@ -149,7 +149,7 @@ log_reboot(int reason)
 
     reboot_tmp_cnt = reboot_cnt;
 
-    if (reason == SOFT_REBOOT) {
+    if (reason == HAL_RESET_SOFT) {
         /*
          * Save reboot count as soft reboot cnt if the reason is
          * a soft reboot
@@ -158,7 +158,7 @@ log_reboot(int reason)
         conf_save_one("reboot/soft_reboot",
                       conf_str_from_value(CONF_INT16, &reboot_tmp_cnt,
                                           str, sizeof(str)));
-    } else if (reason == HARD_REBOOT) {
+    } else {
         conf_save_one("reboot/soft_reboot", "0");
         if (soft_reboot) {
             /* No need to log as it's not a hard reboot */