Merged nuttx/nuttx into master
This commit is contained in:
commit
5060ba4a85
@ -11,4 +11,44 @@ config PHOTON_DFU_BOOTLOADER
|
||||
---help---
|
||||
Build image that can be uploaded using stock DFU bootloader.
|
||||
|
||||
config PHOTON_WDG
|
||||
bool
|
||||
|
||||
config PHOTON_IWDG
|
||||
bool "Photon iwdg kicker support"
|
||||
depends on STM32_IWDG
|
||||
depends on WATCHDOG
|
||||
select PHOTON_WDG
|
||||
|
||||
config PHOTON_IWDG_TIMEOUT
|
||||
int "Photon iwdg Timeout (ms)"
|
||||
default 32000
|
||||
depends on PHOTON_IWDG
|
||||
---help---
|
||||
Watchdog timeout value in milliseconds.
|
||||
|
||||
if PHOTON_WDG
|
||||
config PHOTON_WDG_THREAD
|
||||
bool "Watchdog Deamon Thread"
|
||||
|
||||
if PHOTON_WDG_THREAD
|
||||
config PHOTON_WDG_THREAD_NAME
|
||||
string "Watchdog Thread Name"
|
||||
default "wdog"
|
||||
|
||||
config PHOTON_WDG_THREAD_INTERVAL
|
||||
int "Watchdog Thread Interval (ms)"
|
||||
default 2500
|
||||
|
||||
config PHOTON_WDG_THREAD_PRIORITY
|
||||
int "Watchdog Thread Priority"
|
||||
default 200
|
||||
|
||||
config PHOTON_WDG_THREAD_STACKSIZE
|
||||
int "Watchdog Thread Stacksize"
|
||||
default 1024
|
||||
|
||||
endif # PHOTON_WDG_THREAD
|
||||
endif # PHOTON_WDG
|
||||
|
||||
endif
|
||||
|
@ -429,7 +429,7 @@ CONFIG_STM32_USART1=y
|
||||
# CONFIG_STM32_UART4 is not set
|
||||
# CONFIG_STM32_UART5 is not set
|
||||
# CONFIG_STM32_USART6 is not set
|
||||
# CONFIG_STM32_IWDG is not set
|
||||
CONFIG_STM32_IWDG=y
|
||||
# CONFIG_STM32_WWDG is not set
|
||||
# CONFIG_STM32_NOEXT_VECTORS is not set
|
||||
|
||||
@ -574,8 +574,21 @@ CONFIG_ARCH_BOARD="photon"
|
||||
# Board-Specific Options
|
||||
#
|
||||
CONFIG_PHOTON_DFU_BOOTLOADER=y
|
||||
CONFIG_PHOTON_WDG=y
|
||||
CONFIG_PHOTON_IWDG=y
|
||||
CONFIG_PHOTON_IWDG_TIMEOUT=32000
|
||||
CONFIG_PHOTON_WDG_THREAD=y
|
||||
CONFIG_PHOTON_WDG_THREAD_NAME="wdog"
|
||||
CONFIG_PHOTON_WDG_THREAD_INTERVAL=2500
|
||||
CONFIG_PHOTON_WDG_THREAD_PRIORITY=200
|
||||
CONFIG_PHOTON_WDG_THREAD_STACKSIZE=1024
|
||||
# CONFIG_BOARD_CRASHDUMP is not set
|
||||
# CONFIG_LIB_BOARDCTL is not set
|
||||
CONFIG_LIB_BOARDCTL=y
|
||||
# CONFIG_BOARDCTL_RESET is not set
|
||||
# CONFIG_BOARDCTL_UNIQUEID is not set
|
||||
# CONFIG_BOARDCTL_TSCTEST is not set
|
||||
# CONFIG_BOARDCTL_GRAPHICS is not set
|
||||
# CONFIG_BOARDCTL_IOCTL is not set
|
||||
|
||||
#
|
||||
# RTOS Features
|
||||
@ -718,7 +731,8 @@ CONFIG_ARCH_HAVE_SPI_BITORDER=y
|
||||
# CONFIG_TIMER is not set
|
||||
# CONFIG_ONESHOT is not set
|
||||
# CONFIG_RTC is not set
|
||||
# CONFIG_WATCHDOG is not set
|
||||
CONFIG_WATCHDOG=y
|
||||
CONFIG_WATCHDOG_DEVPATH="/dev/watchdog0"
|
||||
# CONFIG_ANALOG is not set
|
||||
# CONFIG_AUDIO_DEVICES is not set
|
||||
# CONFIG_VIDEO_DEVICES is not set
|
||||
@ -1090,6 +1104,7 @@ CONFIG_EXAMPLES_NSH=y
|
||||
# CONFIG_EXAMPLES_TELNETD is not set
|
||||
# CONFIG_EXAMPLES_TIFF is not set
|
||||
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
|
||||
# CONFIG_EXAMPLES_USBSERIAL is not set
|
||||
# CONFIG_EXAMPLES_USBTERM is not set
|
||||
# CONFIG_EXAMPLES_WATCHDOG is not set
|
||||
# CONFIG_EXAMPLES_WEBSERVER is not set
|
||||
@ -1229,7 +1244,7 @@ CONFIG_NSH_FILEIOSIZE=512
|
||||
#
|
||||
CONFIG_NSH_CONSOLE=y
|
||||
# CONFIG_NSH_ALTCONDEV is not set
|
||||
# CONFIG_NSH_ARCHINIT is not set
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
# CONFIG_NSH_LOGIN is not set
|
||||
# CONFIG_NSH_CONSOLE_LOGIN is not set
|
||||
|
||||
|
@ -41,6 +41,10 @@ ifeq ($(CONFIG_PHOTON_DFU_BOOTLOADER),y)
|
||||
CSRCS += dfu_signature.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PHOTON_WDG),y)
|
||||
CSRCS += photon_wdt.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_LIBRARY),y)
|
||||
CSRCS += stm32_appinit.c
|
||||
endif
|
||||
|
@ -62,5 +62,23 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: photon_watchdog_initialize()
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture-specific initialization of the Watchdog hardware.
|
||||
*
|
||||
* Input parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_PHOTON_WDG
|
||||
int photon_watchdog_initialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __CONFIGS_PHOTON_SRC_PHOTON_H */
|
||||
|
179
configs/photon/src/photon_wdt.c
Normal file
179
configs/photon/src/photon_wdt.c
Normal file
@ -0,0 +1,179 @@
|
||||
/************************************************************************************
|
||||
* configs/photon/src/photon_wdt.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Simon Piriou <spiriou31@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <sched.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <nuttx/timers/watchdog.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
/* Configuration *******************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/* Watchdog daemon thread */
|
||||
|
||||
#if defined(CONFIG_PHOTON_WDG_THREAD)
|
||||
|
||||
static int wdog_daemon(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
/* Open watchdog device */
|
||||
|
||||
fd = open(CONFIG_WATCHDOG_DEVPATH, O_RDONLY);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
wderr("ERROR: open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Start watchdog timer */
|
||||
|
||||
ret = ioctl(fd, WDIOC_START, 0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
wderr("ERROR: ioctl(WDIOC_START) failed: %d\n", errno);
|
||||
goto exit_close_dev;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
usleep((CONFIG_PHOTON_WDG_THREAD_INTERVAL)*1000);
|
||||
|
||||
/* Send keep alive ioctl */
|
||||
|
||||
ret = ioctl(fd, WDIOC_KEEPALIVE, 0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
wderr("ERROR: ioctl(WDIOC_KEEPALIVE) failed: %d\n", errno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
exit_close_dev:
|
||||
|
||||
/* Close watchdog device and exit. */
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PHOTON_WDG_THREAD */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: photon_watchdog_initialize()
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture-specific initialization of the Watchdog hardware.
|
||||
* This interface must be provided by all configurations using
|
||||
* apps/examples/watchdog
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int photon_watchdog_initialize(void)
|
||||
{
|
||||
int fd;
|
||||
int ret = 0;
|
||||
|
||||
/* Open the watchdog device */
|
||||
|
||||
fd = open(CONFIG_WATCHDOG_DEVPATH, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
wderr("ERROR: open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Set the watchdog timeout */
|
||||
|
||||
#ifdef CONFIG_PHOTON_IWDG
|
||||
wdinfo("Timeout = %d.\n", CONFIG_PHOTON_IWDG_TIMEOUT);
|
||||
ret = ioctl(fd, WDIOC_SETTIMEOUT, (unsigned long)CONFIG_PHOTON_IWDG_TIMEOUT);
|
||||
#else
|
||||
# error "No watchdog configured"
|
||||
#endif
|
||||
|
||||
/* Close watchdog as it is not needed here anymore */
|
||||
|
||||
close(fd);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
wderr("ERROR: watchdog configuration failed: %d\n", errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_PHOTON_WDG_THREAD)
|
||||
|
||||
/* Spawn wdog deamon thread */
|
||||
|
||||
int taskid = kernel_thread(CONFIG_PHOTON_WDG_THREAD_NAME,
|
||||
CONFIG_PHOTON_WDG_THREAD_PRIORITY,
|
||||
CONFIG_PHOTON_WDG_THREAD_STACKSIZE,
|
||||
(main_t)wdog_daemon, (FAR char * const *)NULL);
|
||||
|
||||
if (taskid <= 0)
|
||||
{
|
||||
wderr("ERROR: cannot spawn wdog_daemon thread\n");
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PHOTON_WDG_THREAD */
|
||||
|
||||
return OK;
|
||||
}
|
@ -40,8 +40,13 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "photon.h"
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "stm32_wdg.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -82,5 +87,22 @@
|
||||
|
||||
int board_app_initialize(uintptr_t arg)
|
||||
{
|
||||
return OK;
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_STM32_IWDG
|
||||
stm32_iwdginitialize("/dev/watchdog0", STM32_LSI_FREQUENCY);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PHOTON_WDG
|
||||
|
||||
/* Start WDG kicker thread */
|
||||
|
||||
ret = photon_watchdog_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
serr("Failed to start watchdog thread: %d\n", errno);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user