Loading boot/nuttx/include/mcuboot_config/mcuboot_config.h +9 −0 Changes for boot/nuttx/include/mcuboot_config/mcuboot_config.h: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -181,6 +181,15 @@ */ #ifdef CONFIG_MCUBOOT_WATCHDOG #ifndef CONFIG_MCUBOOT_WATCHDOG_DEVPATH # define CONFIG_MCUBOOT_WATCHDOG_DEVPATH "/dev/watchdog0" #endif #ifndef CONFIG_MCUBOOT_WATCHDOG_TIMEOUT # define CONFIG_MCUBOOT_WATCHDOG_TIMEOUT 10000 /* Watchdog timeout in ms */ #endif # define MCUBOOT_WATCHDOG_FEED() do \ { \ mcuboot_watchdog_feed(); \ Loading boot/nuttx/include/watchdog/watchdog.h +21 −0 Changes for boot/nuttx/include/watchdog/watchdog.h: 21 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,4 +41,25 @@ void mcuboot_watchdog_feed(void); /**************************************************************************** * Public Function Prototypes ****************************************************************************/ /**************************************************************************** * Name: mcuboot_watchdog_init * * Description: * Initialize the watchdog timer by setting the trigger timeout and * starting it. * * Input Parameters: * None. * * Returned Value: * OK on success, ERROR if not. * ****************************************************************************/ int mcuboot_watchdog_init(void); #endif /* __BOOT_NUTTX_INCLUDE_WATCHDOG_WATCHDOG_H */ boot/nuttx/main.c +9 −0 Changes for boot/nuttx/main.c: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -114,6 +114,15 @@ int main(int argc, FAR char *argv[]) syslog(LOG_INFO, "*** Booting MCUboot build %s ***\n", CONFIG_MCUBOOT_VERSION); #ifdef CONFIG_MCUBOOT_WATCHDOG int ret = mcuboot_watchdog_init(); if (ret < 0) { syslog(LOG_ERR, "Unable to initialize the watchdog timer\n"); FIH_PANIC; } #endif FIH_CALL(boot_go, fih_rc, &rsp); if (fih_not_eq(fih_rc, FIH_SUCCESS)) Loading boot/nuttx/src/watchdog/watchdog.c +54 −0 Changes for boot/nuttx/src/watchdog/watchdog.c: 54 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -74,3 +74,57 @@ void mcuboot_watchdog_feed(void) close(fd); } /**************************************************************************** * Name: mcuboot_watchdog_init * * Description: * Initialize the watchdog timer by setting the trigger timeout and * starting it. * * Input Parameters: * None. * * Returned Value: * OK on success, ERROR if not. * ****************************************************************************/ int mcuboot_watchdog_init(void) { int fd; int ret; fd = open(CONFIG_MCUBOOT_WATCHDOG_DEVPATH, O_RDONLY); if (fd < 0) { BOOT_LOG_ERR("Failed to open %s", CONFIG_MCUBOOT_WATCHDOG_DEVPATH); goto errout; } ret = ioctl(fd, WDIOC_SETTIMEOUT, (unsigned long)CONFIG_MCUBOOT_WATCHDOG_TIMEOUT); if (ret < 0) { int errcode = errno; BOOT_LOG_ERR("Failed to set timeout in watchdog device: %d", errcode); goto errout_with_dev; } ret = ioctl(fd, WDIOC_START, 0); if (ret < 0) { int errcode = errno; BOOT_LOG_ERR("Failed to start watchdog device: %d", errcode); goto errout_with_dev; } close(fd); return OK; errout_with_dev: close(fd); errout: return ERROR; } Loading
boot/nuttx/include/mcuboot_config/mcuboot_config.h +9 −0 Changes for boot/nuttx/include/mcuboot_config/mcuboot_config.h: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -181,6 +181,15 @@ */ #ifdef CONFIG_MCUBOOT_WATCHDOG #ifndef CONFIG_MCUBOOT_WATCHDOG_DEVPATH # define CONFIG_MCUBOOT_WATCHDOG_DEVPATH "/dev/watchdog0" #endif #ifndef CONFIG_MCUBOOT_WATCHDOG_TIMEOUT # define CONFIG_MCUBOOT_WATCHDOG_TIMEOUT 10000 /* Watchdog timeout in ms */ #endif # define MCUBOOT_WATCHDOG_FEED() do \ { \ mcuboot_watchdog_feed(); \ Loading
boot/nuttx/include/watchdog/watchdog.h +21 −0 Changes for boot/nuttx/include/watchdog/watchdog.h: 21 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,4 +41,25 @@ void mcuboot_watchdog_feed(void); /**************************************************************************** * Public Function Prototypes ****************************************************************************/ /**************************************************************************** * Name: mcuboot_watchdog_init * * Description: * Initialize the watchdog timer by setting the trigger timeout and * starting it. * * Input Parameters: * None. * * Returned Value: * OK on success, ERROR if not. * ****************************************************************************/ int mcuboot_watchdog_init(void); #endif /* __BOOT_NUTTX_INCLUDE_WATCHDOG_WATCHDOG_H */
boot/nuttx/main.c +9 −0 Changes for boot/nuttx/main.c: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -114,6 +114,15 @@ int main(int argc, FAR char *argv[]) syslog(LOG_INFO, "*** Booting MCUboot build %s ***\n", CONFIG_MCUBOOT_VERSION); #ifdef CONFIG_MCUBOOT_WATCHDOG int ret = mcuboot_watchdog_init(); if (ret < 0) { syslog(LOG_ERR, "Unable to initialize the watchdog timer\n"); FIH_PANIC; } #endif FIH_CALL(boot_go, fih_rc, &rsp); if (fih_not_eq(fih_rc, FIH_SUCCESS)) Loading
boot/nuttx/src/watchdog/watchdog.c +54 −0 Changes for boot/nuttx/src/watchdog/watchdog.c: 54 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -74,3 +74,57 @@ void mcuboot_watchdog_feed(void) close(fd); } /**************************************************************************** * Name: mcuboot_watchdog_init * * Description: * Initialize the watchdog timer by setting the trigger timeout and * starting it. * * Input Parameters: * None. * * Returned Value: * OK on success, ERROR if not. * ****************************************************************************/ int mcuboot_watchdog_init(void) { int fd; int ret; fd = open(CONFIG_MCUBOOT_WATCHDOG_DEVPATH, O_RDONLY); if (fd < 0) { BOOT_LOG_ERR("Failed to open %s", CONFIG_MCUBOOT_WATCHDOG_DEVPATH); goto errout; } ret = ioctl(fd, WDIOC_SETTIMEOUT, (unsigned long)CONFIG_MCUBOOT_WATCHDOG_TIMEOUT); if (ret < 0) { int errcode = errno; BOOT_LOG_ERR("Failed to set timeout in watchdog device: %d", errcode); goto errout_with_dev; } ret = ioctl(fd, WDIOC_START, 0); if (ret < 0) { int errcode = errno; BOOT_LOG_ERR("Failed to start watchdog device: %d", errcode); goto errout_with_dev; } close(fd); return OK; errout_with_dev: close(fd); errout: return ERROR; }