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 2017/02/23 22:33:12 UTC
[18/50] incubator-mynewt-core git commit: sys/reboot;
log reset request coming from network differently from assert().
sys/reboot; log reset request coming from network differently from
assert().
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/51af56ca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/51af56ca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/51af56ca
Branch: refs/heads/sensors_branch
Commit: 51af56ca6d43c97c95642eb30ae00c59f786c046
Parents: 57a5bb6
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Feb 13 12:08:36 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Feb 13 12:08:36 2017 -0800
----------------------------------------------------------------------
hw/hal/include/hal/hal_system.h | 11 ++++++-----
mgmt/newtmgr/nmgr_os/src/newtmgr_os.c | 2 +-
sys/reboot/include/reboot/log_reboot.h | 3 ++-
sys/reboot/src/log_reboot.c | 24 ++++++++++++++++++------
4 files changed, 27 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/51af56ca/hw/hal/include/hal/hal_system.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_system.h b/hw/hal/include/hal/hal_system.h
index 3b3c90d..4470b3d 100644
--- a/hw/hal/include/hal/hal_system.h
+++ b/hw/hal/include/hal/hal_system.h
@@ -48,11 +48,12 @@ int hal_debugger_connected(void);
* Reboot reason
*/
enum hal_reset_reason {
- HAL_RESET_POR = 1, /* power on reset */
- HAL_RESET_PIN = 2, /* caused by reset pin */
- HAL_RESET_WATCHDOG = 3, /* watchdog */
- HAL_RESET_SOFT = 4, /* system_reset() or equiv */
- HAL_RESET_BROWNOUT = 5 /* low supply voltage */
+ HAL_RESET_POR = 1, /* power on reset */
+ HAL_RESET_PIN = 2, /* caused by reset pin */
+ HAL_RESET_WATCHDOG = 3, /* watchdog */
+ HAL_RESET_SOFT = 4, /* system_reset() or equiv */
+ HAL_RESET_BROWNOUT = 5, /* low supply voltage */
+ HAL_RESET_REQUESTED = 6, /* restart due to user request */
};
enum hal_reset_reason hal_reset_cause(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/51af56ca/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 1e01b24..c3e38d6 100644
--- a/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
+++ b/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
@@ -330,7 +330,7 @@ nmgr_reset(struct mgmt_cbuf *cb)
os_callout_init(&nmgr_reset_callout, mgmt_evq_get(), nmgr_reset_tmo, NULL);
#if MYNEWT_VAL(LOG_SOFT_RESET)
- log_reboot(HAL_RESET_SOFT);
+ log_reboot(HAL_RESET_REQUESTED);
#endif
os_callout_reset(&nmgr_reset_callout, OS_TICKS_PER_SEC / 4);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/51af56ca/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 396299c..e3ff093 100644
--- a/sys/reboot/include/reboot/log_reboot.h
+++ b/sys/reboot/include/reboot/log_reboot.h
@@ -30,7 +30,8 @@ extern "C" {
(reason == HAL_RESET_WATCHDOG ? "WDOG" : \
(reason == HAL_RESET_SOFT ? "SOFT" : \
(reason == HAL_RESET_BROWNOUT ? "BROWNOUT" : \
- "UNKNOWN")))))
+ (reason == HAL_RESET_REQUESTED ? "REQUESTED" : \
+ "UNKNOWN"))))))
int reboot_init_handler(int log_store_type, uint8_t entries);
int log_reboot(enum hal_reset_reason);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/51af56ca/sys/reboot/src/log_reboot.c
----------------------------------------------------------------------
diff --git a/sys/reboot/src/log_reboot.c b/sys/reboot/src/log_reboot.c
index 952def6..9bfe04c 100644
--- a/sys/reboot/src/log_reboot.c
+++ b/sys/reboot/src/log_reboot.c
@@ -45,13 +45,15 @@ static char reboot_cnt_str[12];
static char soft_reboot_str[12];
static char *reboot_cnt_get(int argc, char **argv, char *buf, int max_len);
static int reboot_cnt_set(int argc, char **argv, char *val);
+static int reboot_cnt_export(void (*export_func)(char *name, char *val),
+ enum conf_export_tgt tgt);
struct conf_handler reboot_conf_handler = {
.ch_name = "reboot",
.ch_get = reboot_cnt_get,
.ch_set = reboot_cnt_set,
.ch_commit = NULL,
- .ch_export = NULL
+ .ch_export = reboot_cnt_export
};
#if MYNEWT_VAL(REBOOT_LOG_FCB)
@@ -150,18 +152,18 @@ log_reboot(enum hal_reset_reason reason)
reboot_tmp_cnt = reboot_cnt;
- if (reason == HAL_RESET_SOFT) {
+ if (reason == HAL_RESET_REQUESTED) {
/*
- * Save reboot count as soft reboot cnt if the reason is
- * a soft reboot
+ * Save soft_reboot as 1 if user is requesting restart.
*/
- reboot_tmp_cnt = reboot_cnt + 1;
+ reboot_tmp_cnt = 1;
conf_save_one("reboot/soft_reboot",
conf_str_from_value(CONF_INT16, &reboot_tmp_cnt,
str, sizeof(str)));
+ reboot_tmp_cnt = reboot_cnt + 1;
} else {
conf_save_one("reboot/soft_reboot", "0");
- if (soft_reboot) {
+ if (soft_reboot && reason == HAL_RESET_SOFT) {
/* No need to log as it's not a hard reboot */
goto err;
} else {
@@ -230,6 +232,16 @@ err:
return OS_ENOENT;
}
+static int
+reboot_cnt_export(void (*func)(char *name, char *val), enum conf_export_tgt tgt)
+{
+ if (tgt == CONF_EXPORT_SHOW) {
+ func("reboot/reboot_cnt", reboot_cnt_str);
+ func("reboot/soft_reboot", soft_reboot_str);
+ }
+ return 0;
+}
+
void
log_reboot_pkg_init(void)
{