You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2020/04/20 09:01:08 UTC

[mynewt-core] branch master updated: watchdog: Fix places that ignore WATCHDOG_INTERVAL=0

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 23aa366  watchdog: Fix places that ignore WATCHDOG_INTERVAL=0
23aa366 is described below

commit 23aa3668a6f34b147ac0a77840d4fbbcb218a34f
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Apr 17 13:50:19 2020 +0200

    watchdog: Fix places that ignore WATCHDOG_INTERVAL=0
    
    When WATCHDOG_INTERVAL is set to zero
    - flash loader would try to initialize watchdog with 0 value
      that would most likely not work
    - hal_flash for STM MCUs would try to tickle uninitialized
      watchdog and that would result in hard fault
---
 apps/flash_loader/src/fl.c              | 4 ++++
 hw/mcu/stm/stm32_common/src/hal_flash.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/apps/flash_loader/src/fl.c b/apps/flash_loader/src/fl.c
index 9c57588..5cdb7cb 100644
--- a/apps/flash_loader/src/fl.c
+++ b/apps/flash_loader/src/fl.c
@@ -172,8 +172,10 @@ main(int argc, char **argv)
 
     hal_bsp_init();
     flash_map_init();
+#if MYNEWT_VAL(WATCHDOG_INTERVAL) > 0
     hal_watchdog_init(MYNEWT_VAL(WATCHDOG_INTERVAL));
     hal_watchdog_enable();
+#endif
 
     fl_data = malloc(MYNEWT_VAL(FLASH_LOADER_DL_SZ));
     assert(fl_data);
@@ -221,7 +223,9 @@ main(int argc, char **argv)
             rc = FL_RC_UNKNOWN_CMD_ERR;
             break;
         }
+#if MYNEWT_VAL(WATCHDOG_INTERVAL) > 0
         hal_watchdog_tickle();
+#endif
         if (fl_cmd_rc <= FL_RC_OK) {
             fl_cmd_rc = rc;
         }
diff --git a/hw/mcu/stm/stm32_common/src/hal_flash.c b/hw/mcu/stm/stm32_common/src/hal_flash.c
index 53fab36..255273b 100644
--- a/hw/mcu/stm/stm32_common/src/hal_flash.c
+++ b/hw/mcu/stm/stm32_common/src/hal_flash.c
@@ -133,7 +133,7 @@ stm32_flash_write_linear(const struct hal_flash *dev, uint32_t address,
          * Long writes take excessive time, and stall the idle thread,
          * so tickling the watchdog here to avoid reset...
          */
-        if (!(i % 32)) {
+        if (MYNEWT_VAL(WATCHDOG_INTERVAL) > 0 && !(i % 32)) {
             hal_watchdog_tickle();
         }
     }