SAM4S Xplained Pro: Watchdog timer support for Bob Doison

This commit is contained in:
Gregory Nutt 2014-04-21 19:19:56 -06:00
parent a8cb0ad8f4
commit 61e80ae998
7 changed files with 496 additions and 103 deletions

View File

@ -7237,3 +7237,6 @@
Bob Doison (2014-4-21).
* arch/arm/src/sam34/sam_wdt.c/.h: Add watchdog driver. From Bob
Doison (2014-4-21).
* nuttx/configs/sam4s-xplained-pro: Add board-specific watchdog
timer support. From Bob Doison (2014-4-21).

View File

@ -1,9 +1,12 @@
- implement flash driver
- see arch/arm/src/stm32/stm32_flash.c and related
- both banks could be mapped with care taken not to erase the active code.
- perhaps the MPU could block code corruption?
- once implemented, the free() cmd replacement can show flash information.
- implement flash driver
- see arch/arm/src/stm32/stm32_flash.c and related
- both banks could be mapped with care taken not to erase the active code.
- perhaps the MPU could block code corruption?
- once implemented, the free() cmd replacement can show flash information.
- Seen crashes when running serial ports below 921600
- USB serial not quite stable when pushing lots of data
- UARTs don't use DMA. We may need this for high baudrates.
- Inbound hardware flow control requires dma.

View File

@ -54,8 +54,8 @@
************************************************************************************/
/* Clocking *************************************************************************/
/* After power-on reset, the sam3u device is running on a 4MHz internal RC. These
* definitions will configure clocking with MCK = 48MHz, PLLA = 96, and CPU=120MHz.
/* After power-on reset, the sam4s device is running on a 4MHz internal RC. These
* definitions will configure clocking with MCK = 120MHz, PLLA = 240, and CPU=120MHz.
*/
/* Main oscillator register settings */
@ -69,6 +69,8 @@
* PLLdiv: 1 (bypassed)
* Fpll: (12MHz * 20) / 1 = 240MHz
*/
#define BOARD_32KOSC_FREQUENCY (32768)
#define BOARD_SLCK_FREQUENCY (BOARD_32KOSC_FREQUENCY)
#define BOARD_MAINOSC_FREQUENCY (12000000)
#define BOARD_CKGR_PLLAR_MUL (19 << PMC_CKGR_PLLAR_MUL_SHIFT)

View File

@ -26,6 +26,7 @@ CONFIG_HOST_LINUX=y
CONFIG_INTELHEX_BINARY=y
# CONFIG_MOTOROLA_SREC is not set
CONFIG_RAW_BINARY=y
# CONFIG_UBOOT_UIMAGE is not set
#
# Customize Header Files
@ -49,12 +50,13 @@ CONFIG_ARCH_HAVE_STACKCHECK=y
#
# CONFIG_DEBUG_MM is not set
# CONFIG_DEBUG_SCHED is not set
CONFIG_DEBUG_FS=y
# CONFIG_DEBUG_USB is not set
# CONFIG_DEBUG_FS is not set
# CONFIG_DEBUG_LIB is not set
# CONFIG_DEBUG_BINFMT is not set
# CONFIG_DEBUG_GRAPHICS is not set
# CONFIG_DEBUG_IRQ is not set
# CONFIG_DEBUG_STACK is not set
CONFIG_DEBUG_STACK=y
#
# Driver Debug Options
@ -65,6 +67,7 @@ CONFIG_DEBUG_FS=y
# CONFIG_DEBUG_GPIO is not set
# CONFIG_DEBUG_DMA is not set
# CONFIG_DEBUG_RTC is not set
# CONFIG_DEBUG_WATCHDOG is not set
# CONFIG_DEBUG_AUDIO is not set
CONFIG_DEBUG_SYMBOLS=y
CONFIG_ARCH_HAVE_CUSTOMOPT=y
@ -136,7 +139,6 @@ CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT=y
# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set
# CONFIG_ARMV7M_OABI_TOOLCHAIN is not set
CONFIG_GPIO_IRQ=y
CONFIG_ARCH_HAVE_EXTNAND=y
CONFIG_ARCH_HAVE_EXTNOR=y
CONFIG_ARCH_HAVE_EXTSRAM0=y
@ -195,6 +197,17 @@ CONFIG_ARCH_CHIP_SAM4S=y
#
# AT91SAM3/4 Peripheral Support
#
# CONFIG_SAM34_ACC is not set
# CONFIG_SAM34_ADC12B is not set
# CONFIG_SAM34_CRCCU is not set
# CONFIG_SAM34_DACC is not set
# CONFIG_SAM34_DMAC1 is not set
CONFIG_SAM34_HSMCI=y
CONFIG_SAM34_PDCA=y
# CONFIG_SAM34_PWM is not set
CONFIG_SAM34_RTC=y
# CONFIG_SAM34_RTT is not set
CONFIG_SAM34_SMC=y
# CONFIG_SAM34_SPI0 is not set
# CONFIG_SAM34_SSC is not set
# CONFIG_SAM34_TC0 is not set
@ -203,29 +216,19 @@ CONFIG_ARCH_CHIP_SAM4S=y
# CONFIG_SAM34_TC3 is not set
# CONFIG_SAM34_TC4 is not set
# CONFIG_SAM34_TC5 is not set
# CONFIG_SAM34_PWM is not set
# CONFIG_SAM34_TWIM0 is not set
# CONFIG_SAM34_TWIS0 is not set
# CONFIG_SAM34_TWIM1 is not set
# CONFIG_SAM34_TWIS1 is not set
# CONFIG_SAM34_UART0 is not set
CONFIG_SAM34_UART0=y
CONFIG_SAM34_UART1=y
CONFIG_SAM34_UDP=y
# CONFIG_SAM34_USART0 is not set
# CONFIG_SAM34_USART1 is not set
# CONFIG_SAM34_ADC12B is not set
# CONFIG_SAM34_DACC is not set
# CONFIG_SAM34_ACC is not set
CONFIG_SAM34_SMC=y
CONFIG_SAM34_PDCA=y
# CONFIG_SAM34_CRCCU is not set
# CONFIG_SAM34_UDP is not set
CONFIG_SAM34_RTC=y
# CONFIG_SAM34_RTT is not set
CONFIG_SAM34_USART1=y
CONFIG_SAM34_WDT=y
CONFIG_SAM34_HSMCI=y
#
# External Memory Configuration
# AT91SAM3/4 External Memory Configuration
#
CONFIG_SAM34_EXTNAND=y
CONFIG_SAM34_EXTNANDSIZE=268435456
@ -236,14 +239,34 @@ CONFIG_SAM34_EXTNANDSIZE=268435456
#
# AT91SAM3/4 GPIO Interrupt Configuration
#
CONFIG_GPIOA_IRQ=y
# CONFIG_GPIOB_IRQ is not set
CONFIG_GPIOC_IRQ=y
CONFIG_SAM34_GPIO_IRQ=y
CONFIG_SAM34_GPIOA_IRQ=y
CONFIG_SAM34_GPIOB_IRQ=y
CONFIG_SAM34_GPIOC_IRQ=y
#
# AT91SAM3/4 HSMCI device driver options
#
CONFIG_SAM34_HSMCI_RDPROOF=y
CONFIG_SAM34_HSMCI_WRPROOF=y
#
# AT91SAM3/4 USB Full Speed Device Controller driver (DCD) options
#
# CONFIG_SAM34_UDP_REGDEBUG is not set
#
# AT91SAM3/4 Watchdog Configuration
#
# CONFIG_WDT_ENABLED_ON_RESET is not set
CONFIG_WDT_ENABLED_ON_RESET=y
# CONFIG_WDT_DISABLE_ON_RESET is not set
CONFIG_WDT_TIMEOUT=4000
CONFIG_WDT_MINTIME=2000
CONFIG_WDT_THREAD=y
CONFIG_WDT_THREAD_NAME="wdog"
CONFIG_WDT_THREAD_INTERVAL=2000
CONFIG_WDT_THREAD_PRIORITY=99
CONFIG_WDT_THREAD_STACKSIZE=512
#
# Architecture Options
@ -259,12 +282,13 @@ CONFIG_ARCH_HAVE_VFORK=y
# CONFIG_ARCH_NAND_HWECC is not set
CONFIG_ARCH_IRQPRIO=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_USBDUMP=y
# CONFIG_ENDIAN_BIG is not set
# CONFIG_ARCH_IDLE_CUSTOM is not set
CONFIG_ARCH_HAVE_RAMFUNCS=y
# CONFIG_ARCH_RAMFUNCS is not set
CONFIG_ARCH_HAVE_RAMVECTORS=y
CONFIG_ARCH_RAMVECTORS=y
# CONFIG_ARCH_RAMVECTORS is not set
#
# Board Settings
@ -322,29 +346,6 @@ CONFIG_NSH_MMCSDSLOTNO=0
#
# RTOS Features
#
# CONFIG_BOARD_INITIALIZE is not set
CONFIG_MSEC_PER_TICK=10
# CONFIG_SYSTEM_TIME64 is not set
CONFIG_RR_INTERVAL=50
# CONFIG_SCHED_CPULOAD is not set
# CONFIG_SCHED_INSTRUMENTATION is not set
CONFIG_TASK_NAME_SIZE=16
# CONFIG_SCHED_HAVE_PARENT is not set
CONFIG_JULIAN_TIME=y
CONFIG_START_YEAR=2014
CONFIG_START_MONTH=3
CONFIG_START_DAY=20
CONFIG_DEV_CONSOLE=y
# CONFIG_MUTEX_TYPES is not set
# CONFIG_PRIORITY_INHERITANCE is not set
# CONFIG_FDCLONE_DISABLE is not set
# CONFIG_FDCLONE_STDIO is not set
CONFIG_SDCLONE_DISABLE=y
CONFIG_SCHED_WAITPID=y
# CONFIG_SCHED_STARTHOOK is not set
# CONFIG_SCHED_ATEXIT is not set
# CONFIG_SCHED_ONEXIT is not set
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_DISABLE_OS_API=y
# CONFIG_DISABLE_CLOCK is not set
# CONFIG_DISABLE_POSIX_TIMERS is not set
@ -353,6 +354,63 @@ CONFIG_DISABLE_OS_API=y
# CONFIG_DISABLE_MQUEUE is not set
CONFIG_DISABLE_ENVIRON=y
#
# Clocks and Timers
#
CONFIG_MSEC_PER_TICK=10
# CONFIG_SYSTEM_TIME64 is not set
# CONFIG_CLOCK_MONOTONIC is not set
CONFIG_JULIAN_TIME=y
CONFIG_START_YEAR=2014
CONFIG_START_MONTH=3
CONFIG_START_DAY=20
CONFIG_MAX_WDOGPARMS=2
CONFIG_PREALLOC_WDOGS=32
CONFIG_PREALLOC_TIMERS=4
#
# Tasks and Scheduling
#
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_RR_INTERVAL=50
CONFIG_TASK_NAME_SIZE=16
CONFIG_MAX_TASK_ARGS=4
CONFIG_MAX_TASKS=16
# CONFIG_SCHED_HAVE_PARENT is not set
CONFIG_SCHED_WAITPID=y
#
# Pthread Options
#
# CONFIG_MUTEX_TYPES is not set
CONFIG_NPTHREAD_KEYS=4
#
# Performance Monitoring
#
# CONFIG_SCHED_CPULOAD is not set
# CONFIG_SCHED_INSTRUMENTATION is not set
#
# Files and I/O
#
CONFIG_DEV_CONSOLE=y
# CONFIG_FDCLONE_DISABLE is not set
# CONFIG_FDCLONE_STDIO is not set
CONFIG_SDCLONE_DISABLE=y
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NAME_MAX=32
# CONFIG_PRIORITY_INHERITANCE is not set
#
# RTOS hooks
#
# CONFIG_BOARD_INITIALIZE is not set
# CONFIG_SCHED_STARTHOOK is not set
# CONFIG_SCHED_ATEXIT is not set
# CONFIG_SCHED_ONEXIT is not set
#
# Signal Numbers
#
@ -363,19 +421,10 @@ CONFIG_SIG_SIGCONDTIMEDOUT=16
CONFIG_SIG_SIGWORK=17
#
# Sizes of configurable things (0 disables)
# POSIX Message Queue Options
#
CONFIG_MAX_TASKS=16
CONFIG_MAX_TASK_ARGS=4
CONFIG_NPTHREAD_KEYS=4
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NAME_MAX=32
CONFIG_PREALLOC_MQ_MSGS=8
CONFIG_MQ_MAXMSGSIZE=32
CONFIG_MAX_WDOGPARMS=2
CONFIG_PREALLOC_WDOGS=4
CONFIG_PREALLOC_TIMERS=4
#
# Stack and heap information
@ -403,7 +452,8 @@ CONFIG_DEV_ZERO=y
CONFIG_RTC=y
CONFIG_RTC_DATETIME=y
CONFIG_RTC_ALARM=y
# 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
@ -429,9 +479,10 @@ CONFIG_SDIO_BLOCKSETUP=y
# CONFIG_SERCOMM_CONSOLE is not set
CONFIG_SERIAL=y
# CONFIG_DEV_LOWCONSOLE is not set
CONFIG_SERIAL_REMOVABLE=y
# CONFIG_16550_UART is not set
# CONFIG_ARCH_HAVE_UART is not set
# CONFIG_ARCH_HAVE_UART0 is not set
CONFIG_ARCH_HAVE_UART0=y
CONFIG_ARCH_HAVE_UART1=y
# CONFIG_ARCH_HAVE_UART2 is not set
# CONFIG_ARCH_HAVE_UART3 is not set
@ -443,7 +494,7 @@ CONFIG_ARCH_HAVE_UART1=y
# CONFIG_ARCH_HAVE_SCI0 is not set
# CONFIG_ARCH_HAVE_SCI1 is not set
# CONFIG_ARCH_HAVE_USART0 is not set
# CONFIG_ARCH_HAVE_USART1 is not set
CONFIG_ARCH_HAVE_USART1=y
# CONFIG_ARCH_HAVE_USART2 is not set
# CONFIG_ARCH_HAVE_USART3 is not set
# CONFIG_ARCH_HAVE_USART4 is not set
@ -455,12 +506,27 @@ CONFIG_ARCH_HAVE_UART1=y
#
# USART Configuration
#
CONFIG_USART1_ISUART=y
CONFIG_MCU_SERIAL=y
CONFIG_STANDARD_SERIAL=y
# CONFIG_SERIAL_TIOCSERGSTRUCT is not set
CONFIG_UART1_SERIAL_CONSOLE=y
CONFIG_UART0_SERIAL_CONSOLE=y
# CONFIG_UART1_SERIAL_CONSOLE is not set
# CONFIG_USART1_SERIAL_CONSOLE is not set
# CONFIG_NO_SERIAL_CONSOLE is not set
#
# UART0 Configuration
#
CONFIG_UART0_RXBUFSIZE=256
CONFIG_UART0_TXBUFSIZE=256
CONFIG_UART0_BAUD=912600
CONFIG_UART0_BITS=8
CONFIG_UART0_PARITY=0
CONFIG_UART0_2STOP=0
# CONFIG_UART0_IFLOWCONTROL is not set
# CONFIG_UART0_OFLOWCONTROL is not set
#
# UART1 Configuration
#
@ -470,11 +536,65 @@ CONFIG_UART1_BAUD=921600
CONFIG_UART1_BITS=8
CONFIG_UART1_PARITY=0
CONFIG_UART1_2STOP=0
CONFIG_UART1_IFLOWCONTROL=y
CONFIG_UART1_OFLOWCONTROL=y
CONFIG_SERIAL_IFLOWCONTROL=y
CONFIG_SERIAL_OFLOWCONTROL=y
# CONFIG_USBDEV is not set
# CONFIG_UART1_IFLOWCONTROL is not set
# CONFIG_UART1_OFLOWCONTROL is not set
#
# USART1 Configuration
#
CONFIG_USART1_RXBUFSIZE=256
CONFIG_USART1_TXBUFSIZE=256
CONFIG_USART1_BAUD=921600
CONFIG_USART1_BITS=8
CONFIG_USART1_PARITY=0
CONFIG_USART1_2STOP=0
# CONFIG_USART1_IFLOWCONTROL is not set
# CONFIG_USART1_OFLOWCONTROL is not set
# CONFIG_SERIAL_IFLOWCONTROL is not set
# CONFIG_SERIAL_OFLOWCONTROL is not set
CONFIG_USBDEV=y
#
# USB Device Controller Driver Options
#
# CONFIG_USBDEV_ISOCHRONOUS is not set
# CONFIG_USBDEV_DUALSPEED is not set
# CONFIG_USBDEV_SELFPOWERED is not set
CONFIG_USBDEV_BUSPOWERED=y
CONFIG_USBDEV_MAXPOWER=100
# CONFIG_USBDEV_DMA is not set
CONFIG_ARCH_USBDEV_STALLQUEUE=y
CONFIG_USBDEV_TRACE=y
CONFIG_USBDEV_TRACE_NRECORDS=256
CONFIG_USBDEV_TRACE_STRINGS=y
#
# USB Device Class Driver Options
#
# CONFIG_USBDEV_COMPOSITE is not set
# CONFIG_PL2303 is not set
CONFIG_CDCACM=y
# CONFIG_CDCACM_CONSOLE is not set
CONFIG_CDCACM_EP0MAXPACKET=64
CONFIG_CDCACM_EPINTIN=1
CONFIG_CDCACM_EPINTIN_FSSIZE=64
CONFIG_CDCACM_EPINTIN_HSSIZE=64
CONFIG_CDCACM_EPBULKOUT=3
CONFIG_CDCACM_EPBULKOUT_FSSIZE=64
CONFIG_CDCACM_EPBULKOUT_HSSIZE=512
CONFIG_CDCACM_EPBULKIN=2
CONFIG_CDCACM_EPBULKIN_FSSIZE=64
CONFIG_CDCACM_EPBULKIN_HSSIZE=512
CONFIG_CDCACM_NWRREQS=4
CONFIG_CDCACM_NRDREQS=4
CONFIG_CDCACM_BULKIN_REQLEN=250
CONFIG_CDCACM_RXBUFSIZE=1024
CONFIG_CDCACM_TXBUFSIZE=1024
CONFIG_CDCACM_VENDORID=0x0525
CONFIG_CDCACM_PRODUCTID=0xa4a7
CONFIG_CDCACM_VENDORSTR="NuttX"
CONFIG_CDCACM_PRODUCTSTR="CDC/ACM Serial"
# CONFIG_USBMSC is not set
# CONFIG_USBHOST is not set
# CONFIG_WIRELESS is not set
@ -642,7 +762,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_HIDKBD is not set
# CONFIG_EXAMPLES_KEYPADTEST is not set
# CONFIG_EXAMPLES_IGMP is not set
# CONFIG_EXAMPLES_LCDRW is not set
# CONFIG_EXAMPLES_MM is not set
# CONFIG_EXAMPLES_MODBUS is not set
# CONFIG_EXAMPLES_MOUNT is not set
@ -776,7 +895,7 @@ CONFIG_NSH_CODECS_BUFSIZE=128
CONFIG_NSH_CMDOPT_HEXDUMP=y
CONFIG_NSH_PROC_MOUNTPOUNT="/proc"
CONFIG_NSH_FILEIOSIZE=2048
# CONFIG_NSH_STRERROR is not set
CONFIG_NSH_STRERROR=y
CONFIG_NSH_LINELEN=80
# CONFIG_NSH_DISABLE_SEMICOLON is not set
CONFIG_NSH_CMDPARMS=y
@ -789,11 +908,13 @@ CONFIG_NSH_NESTDEPTH=3
# CONFIG_NSH_DISABLE_LOOPS is not set
# CONFIG_NSH_DISABLEBG is not set
CONFIG_NSH_CONSOLE=y
# CONFIG_NSH_USBCONSOLE is not set
#
# USB Trace Support
#
# CONFIG_NSH_CONDEV is not set
# CONFIG_NSH_USBDEV_TRACE is not set
CONFIG_NSH_CONDEV="/dev/console"
CONFIG_NSH_ARCHINIT=y
#
@ -809,27 +930,15 @@ CONFIG_NSH_ARCHINIT=y
# System Libraries and NSH Add-Ons
#
#
# USB CDC/ACM Device Commands
#
#
# USB Composite Device Commands
#
#
# Custom Free Memory Command
#
# CONFIG_SYSTEM_FREE is not set
#
# I2C tool
# EMACS-like Command Line Editor
#
#
# INI File Parser
#
# CONFIG_SYSTEM_INIFILE is not set
# CONFIG_SYSTEM_CLE is not set
#
# FLASH Program Installation
@ -840,6 +949,15 @@ CONFIG_NSH_ARCHINIT=y
# FLASH Erase-all Command
#
#
# I2C tool
#
#
# INI File Parser
#
# CONFIG_SYSTEM_INIFILE is not set
#
# NxPlayer media player library / command Line
#
@ -877,15 +995,6 @@ CONFIG_SYSTEM_SDCARD=y
CONFIG_SYSTEM_SYSINFO=y
CONFIG_SYSTEM_SYSINFO_STACKSIZE=1024
#
# USB Monitor
#
#
# EMACS-like Command Line Editor
#
# CONFIG_SYSTEM_CLE is not set
#
# VI Work-Alike Editor
#
@ -894,11 +1003,43 @@ CONFIG_SYSTEM_SYSINFO_STACKSIZE=1024
#
# Stack Monitor
#
CONFIG_SYSTEM_STACKMONITOR=y
CONFIG_SYSTEM_STACKMONITOR_STACKSIZE=1024
CONFIG_SYSTEM_STACKMONITOR_PRIORITY=50
CONFIG_SYSTEM_STACKMONITOR_INTERVAL=2
#
# USB CDC/ACM Device Commands
#
CONFIG_SYSTEM_CDCACM=y
CONFIG_SYSTEM_CDCACM_DEVMINOR=0
CONFIG_SYSTEM_CDCACM_TRACEINIT=y
CONFIG_SYSTEM_CDCACM_TRACECLASS=y
CONFIG_SYSTEM_CDCACM_TRACETRANSFERS=y
CONFIG_SYSTEM_CDCACM_TRACECONTROLLER=y
CONFIG_SYSTEM_CDCACM_TRACEINTERRUPTS=y
#
# USB Composite Device Commands
#
#
# USB Mass Storage Device Commands
#
#
# USB Monitor
#
CONFIG_SYSTEM_USBMONITOR=y
CONFIG_SYSTEM_USBMONITOR_STACKSIZE=1024
CONFIG_SYSTEM_USBMONITOR_PRIORITY=50
CONFIG_SYSTEM_USBMONITOR_INTERVAL=2
CONFIG_SYSTEM_USBMONITOR_TRACEINIT=y
CONFIG_SYSTEM_USBMONITOR_TRACECLASS=y
CONFIG_SYSTEM_USBMONITOR_TRACETRANSFERS=y
CONFIG_SYSTEM_USBMONITOR_TRACECONTROLLER=y
CONFIG_SYSTEM_USBMONITOR_TRACEINTERRUPTS=y
#
# Zmodem Commands
#

View File

@ -68,6 +68,11 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += sam_buttons.c
endif
ifeq ($(CONFIG_SAM34_WDT),y)
CSRCS += sam_wdt.c
endif
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)

View File

@ -98,11 +98,10 @@ int nsh_archinitialize(void)
int ret;
#endif
message("initializing...\n");
#ifdef HAVE_HSMCI
/* Initialize the HSMCI driver */
message("initializing HSMCI\n");
ret = sam_hsmci_initialize();
if (ret < 0)
{
@ -114,6 +113,7 @@ int nsh_archinitialize(void)
#ifdef HAVE_PROC
/* mount the proc filesystem */
message("Mounting procfs to /proc\n");
ret = mount(NULL, "/proc", "procfs", 0, NULL);
if (ret < 0)
{
@ -125,6 +125,7 @@ int nsh_archinitialize(void)
#ifdef HAVE_USBMONITOR
/* Start the USB Monitor */
message("Starting USB Monitor\n");
ret = usbmonitor_start(0, NULL);
if (ret != OK)
{
@ -134,6 +135,7 @@ int nsh_archinitialize(void)
#endif
#warning "add automount config...."
message("Mounting /dev/mmcsd0 to /fat\n");
ret = mount("/dev/mmcsd0", "/fat", "vfat", 0, NULL);
if (ret < 0)
{

View File

@ -0,0 +1,237 @@
/************************************************************************************
* configs/sam4s-xplained-pro/src/up_watchdog.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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/watchdog.h>
#include <arch/board/board.h>
#include <nuttx/kthread.h>
#include "sam_wdt.h"
#include <nuttx/clock.h>
#ifdef CONFIG_WATCHDOG
/************************************************************************************
* Definitions
************************************************************************************/
/* Configuration *******************************************************************/
/* Wathdog hardware should be enabled */
#if !defined(CONFIG_SAM34_WDT)
# warning "CONFIG_SAM34_WDT must be defined"
#endif
/* Select the path to the registered watchdog timer device */
#ifndef CONFIG_WATCHDOG_DEVPATH
# ifdef CONFIG_EXAMPLES_WATCHDOG_DEVPATH
# define CONFIG_WATCHDOG_DEVPATH CONFIG_EXAMPLES_WATCHDOG_DEVPATH
# else
# define CONFIG_WATCHDOG_DEVPATH "/dev/watchdog0"
# endif
#endif
/* Debug ***************************************************************************/
/* Non-standard debug that may be enabled just for testing the watchdog timer */
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_WATCHDOG
#endif
#ifdef CONFIG_DEBUG_WATCHDOG
# define wdgdbg dbg
# define wdglldbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define wdgvdbg vdbg
# define wdgllvdbg llvdbg
# else
# define wdgvdbg(x...)
# define wdgllvdbg(x...)
# endif
#else
# define wdgdbg(x...)
# define wdglldbg(x...)
# define wdgvdbg(x...)
# define wdgllvdbg(x...)
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/*
Watchdog kicker task
*/
#if defined(CONFIG_WDT_THREAD)
static int wdog_daemon(int argc, char *argv[])
{
int fd;
int ret;
/* Open the watchdog device for reading */
wdgvdbg("Opening.\n");
fd = open(CONFIG_WATCHDOG_DEVPATH, O_RDONLY);
if (fd < 0)
{
wdgdbg("open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno);
goto errout;
}
/* Start the watchdog timer. */
wdgvdbg("Starting.\n");
ret = ioctl(fd, WDIOC_START, 0);
if (ret < 0)
{
wdgdbg("ioctl(WDIOC_START) failed: %d\n", errno);
goto errout_with_dev;
}
while(1)
{
usleep((CONFIG_WDT_THREAD_INTERVAL)*1000);
wdgvdbg("ping\n");
ret = ioctl(fd, WDIOC_KEEPALIVE, 0);
if (ret < 0)
{
wdgdbg("ioctl(WDIOC_KEEPALIVE) failed: %d\n", errno);
goto errout_with_dev;
}
}
errout_with_dev:
close(fd);
errout:
return ERROR;
}
#endif
/****************************************************************************
* Name: up_wdginitialize()
*
* Description:
* Perform architecture-specific initialization of the Watchdog hardware.
* This interface must be provided by all configurations using
* apps/examples/watchdog
*
****************************************************************************/
int up_wdginitialize(void)
{
#if (defined(CONFIG_SAM34_WDT) && !defined(CONFIG_WDT_DISABLE_ON_RESET))
int fd;
int ret;
/* Initialize tha register the watchdog timer device */
wdgvdbg("Initializing Watchdog driver...\n");
sam_wdtinitialize(CONFIG_WATCHDOG_DEVPATH);
/* Open the watchdog device */
wdgvdbg("Opening.\n");
fd = open(CONFIG_WATCHDOG_DEVPATH, O_RDONLY);
if (fd < 0)
{
wdgdbg("open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno);
goto errout;
}
/* Set the watchdog timeout */
wdgvdbg("Timeout = %d.\n", CONFIG_WDT_TIMEOUT);
ret = ioctl(fd, WDIOC_SETTIMEOUT, (unsigned long)CONFIG_WDT_TIMEOUT);
if (ret < 0)
{
wdgdbg("ioctl(WDIOC_SETTIMEOUT) failed: %d\n", errno);
goto errout_with_dev;
}
/* Set the watchdog minimum time */
wdgvdbg("MinTime = %d.\n", CONFIG_WDT_MINTIME);
ret = ioctl(fd, WDIOC_MINTIME, (unsigned long)CONFIG_WDT_MINTIME);
if (ret < 0)
{
wdgdbg("ioctl(WDIOC_MINTIME) failed: %d\n", errno);
goto errout_with_dev;
}
/* Start Kicker task */
#if defined(CONFIG_WDT_THREAD)
sched_lock();
int taskid = KERNEL_THREAD(CONFIG_WDT_THREAD_NAME,
CONFIG_WDT_THREAD_PRIORITY,
CONFIG_WDT_THREAD_STACKSIZE,
(main_t)wdog_daemon, (FAR char * const *)NULL);
ASSERT(taskid > 0);
sched_unlock();
#endif
return OK;
errout_with_dev:
close(fd);
errout:
return ERROR;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_WATCHDOG */