This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 3511ec823ce8115da53ecd44630424ab0f5ac7e1 Author: Gustavo Henrique Nihei <[email protected]> AuthorDate: Tue Feb 22 10:33:04 2022 -0300 esp32s3-devkit: Initialize Watchdog Timers on bringup Signed-off-by: Gustavo Henrique Nihei <[email protected]> --- .../esp32s3/common/include/esp32s3_board_wdt.h | 73 +++++++++++++++++++ boards/xtensa/esp32s3/common/src/Make.defs | 4 ++ .../src/esp32s3_board_wdt.c} | 82 +++++++++------------- .../esp32s3-devkit/configs/watchdog/defconfig | 51 ++++++++++++++ .../esp32s3/esp32s3-devkit/src/esp32s3_bringup.c | 14 ++++ 5 files changed, 174 insertions(+), 50 deletions(-) diff --git a/boards/xtensa/esp32s3/common/include/esp32s3_board_wdt.h b/boards/xtensa/esp32s3/common/include/esp32s3_board_wdt.h new file mode 100644 index 0000000..f697729 --- /dev/null +++ b/boards/xtensa/esp32s3/common/include/esp32s3_board_wdt.h @@ -0,0 +1,73 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/common/include/esp32s3_board_wdt.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32S3_COMMON_INCLUDE_ESP32S3_BOARD_WDT_H +#define __BOARDS_XTENSA_ESP32S3_COMMON_INCLUDE_ESP32S3_BOARD_WDT_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_WATCHDOG + +/**************************************************************************** + * Name: board_wdt_init + * + * Description: + * Configure the watchdog timer driver. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int board_wdt_init(void); + +#endif /* CONFIG_WATCHDOG */ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_XTENSA_ESP32S3_COMMON_INCLUDE_ESP32S3_BOARD_WDT_H */ diff --git a/boards/xtensa/esp32s3/common/src/Make.defs b/boards/xtensa/esp32s3/common/src/Make.defs index e504c22..7069365 100644 --- a/boards/xtensa/esp32s3/common/src/Make.defs +++ b/boards/xtensa/esp32s3/common/src/Make.defs @@ -22,6 +22,10 @@ ifeq ($(CONFIG_ESP32S3_TIMER),y) CSRCS += esp32s3_board_tim.c endif +ifeq ($(CONFIG_WATCHDOG),y) + CSRCS += esp32s3_board_wdt.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src) diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/common/src/esp32s3_board_wdt.c similarity index 54% copy from boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c copy to boards/xtensa/esp32s3/common/src/esp32s3_board_wdt.c index a01e583..c3f6942 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/common/src/esp32s3_board_wdt.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c + * boards/xtensa/esp32s3/common/src/esp32s3_board_wdt.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -24,84 +24,66 @@ #include <nuttx/config.h> -#include <stdio.h> -#include <fcntl.h> -#include <unistd.h> -#include <syslog.h> -#include <sys/stat.h> -#include <sys/ioctl.h> #include <sys/types.h> -#include <syslog.h> #include <debug.h> -#include <stdio.h> -#include <errno.h> -#include <nuttx/fs/fs.h> - -#ifdef CONFIG_ESP32S3_TIMER -# include "esp32s3_board_tim.h" -#endif +#include "esp32s3_board_wdt.h" +#include "esp32s3_wdt_lowerhalf.h" +#include "esp32s3_wdt.h" #include "esp32s3-devkit.h" /**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: esp32s3_bringup + * Name: board_wdt_init * * Description: - * Perform architecture-specific initialization - * - * CONFIG_BOARD_LATE_INITIALIZE=y : - * Called from board_late_initialize(). + * Configure the watchdog timer driver. * - * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : - * Called from the NSH library + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. * ****************************************************************************/ -int esp32s3_bringup(void) +int board_wdt_init(void) { - int ret; + int ret = OK; -#ifdef CONFIG_FS_PROCFS - /* Mount the procfs file system */ - - ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); +#ifdef CONFIG_ESP32S3_MWDT0 + ret = esp32s3_wdt_initialize("/dev/watchdog0", ESP32S3_WDT_MWDT0); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + syslog(LOG_ERR, "Failed to initialize MWDT0: %d\n", ret); + return ret; } -#endif - -#ifdef CONFIG_FS_TMPFS - /* Mount the tmpfs file system */ +#endif /* CONFIG_ESP32S3_MWDT0 */ - ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); +#ifdef CONFIG_ESP32S3_MWDT1 + ret = esp32s3_wdt_initialize("/dev/watchdog1", ESP32S3_WDT_MWDT1); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n", - CONFIG_LIBC_TMPDIR, ret); + syslog(LOG_ERR, "Failed to initialize MWDT1: %d\n", ret); + return ret; } -#endif - -#ifdef CONFIG_ESP32S3_TIMER - /* Configure general purpose timers */ +#endif /* CONFIG_ESP32S3_MWDT1 */ - ret = board_tim_init(); +#ifdef CONFIG_ESP32S3_RWDT + ret = esp32s3_wdt_initialize("/dev/watchdog2", ESP32S3_WDT_RWDT); if (ret < 0) { - syslog(LOG_ERR, "Failed to initialize timers: %d\n", ret); + syslog(LOG_ERR, "Failed to initialize RWDT: %d\n", ret); + return ret; } -#endif +#endif /* CONFIG_ESP32S3_RWDT */ - /* If we got here then perhaps not all initialization was successful, but - * at least enough succeeded to bring-up NSH with perhaps reduced - * capabilities. - */ - - UNUSED(ret); - return OK; + return ret; } + diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/watchdog/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/watchdog/defconfig new file mode 100644 index 0000000..19d61e1 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/watchdog/defconfig @@ -0,0 +1,51 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-devkit" +CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_MWDT0=y +CONFIG_ESP32S3_MWDT1=y +CONFIG_ESP32S3_UART0=y +CONFIG_EXAMPLES_WATCHDOG=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_MM_REGIONS=3 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_WATCHDOG=y diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c index a01e583..a5d54cd 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c @@ -42,6 +42,10 @@ # include "esp32s3_board_tim.h" #endif +#ifdef CONFIG_WATCHDOG +# include "esp32s3_board_wdt.h" +#endif + #include "esp32s3-devkit.h" /**************************************************************************** @@ -97,6 +101,16 @@ int esp32s3_bringup(void) } #endif +#ifdef CONFIG_WATCHDOG + /* Configure watchdog timer */ + + ret = board_wdt_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize watchdog timer: %d\n", ret); + } +#endif + /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities.
