summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-04-22 07:52:08 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-04-22 07:52:08 -0600
commit5ac1c9adabdb5bd299c3bedaf7e09f1971797d04 (patch)
treeb138385468cded7e833068bda695ecfe5f9fbd6e
parentb73c2bdabb5dc418b587d7c70a502831ece7d38e (diff)
downloadnuttx-5ac1c9adabdb5bd299c3bedaf7e09f1971797d04.tar.gz
nuttx-5ac1c9adabdb5bd299c3bedaf7e09f1971797d04.tar.bz2
nuttx-5ac1c9adabdb5bd299c3bedaf7e09f1971797d04.zip
examples/cpuhog and serialblaster from Bob Doiron
-rw-r--r--apps/ChangeLog.txt4
-rw-r--r--apps/examples/Kconfig2
-rw-r--r--apps/examples/Make.defs8
-rw-r--r--apps/examples/Makefile23
-rw-r--r--apps/examples/README.txt16
-rw-r--r--apps/examples/cpuhog/.gitignore11
-rw-r--r--apps/examples/cpuhog/Kconfig13
-rw-r--r--apps/examples/cpuhog/Makefile109
-rw-r--r--apps/examples/cpuhog/cpuhog_main.c163
-rw-r--r--apps/examples/serialblaster/.gitignore11
-rw-r--r--apps/examples/serialblaster/Kconfig13
-rw-r--r--apps/examples/serialblaster/Makefile109
-rw-r--r--apps/examples/serialblaster/serialblaster_main.c81
-rw-r--r--nuttx/configs/sam4s-xplained-pro/TODO.txt54
-rw-r--r--nuttx/configs/sam4s-xplained-pro/include/board.h6
-rw-r--r--nuttx/configs/sam4s-xplained-pro/nsh/defconfig102
16 files changed, 618 insertions, 107 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index a0fae4402..f8d611761 100644
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -891,4 +891,6 @@
* apps/system/sdcard: Remove an STM32 dependency. From Bob Doiron
(2014-4-21).
* apps/nshlib: malloc/free IOBUFFER for 'cat' and 'hexdump' commands
- instead of using the stack. From Bob Doiron (2014-4-21). \ No newline at end of file
+ instead of using the stack. From Bob Doiron (2014-4-21).
+ * apps/examples/cpuhog and serialblaster: Stress test examples added
+ by Bob Doiron (2014-4-22).
diff --git a/apps/examples/Kconfig b/apps/examples/Kconfig
index 3d3f4edc7..4e3db375d 100644
--- a/apps/examples/Kconfig
+++ b/apps/examples/Kconfig
@@ -8,6 +8,7 @@ source "$APPSDIR/examples/buttons/Kconfig"
source "$APPSDIR/examples/can/Kconfig"
source "$APPSDIR/examples/cc3000/Kconfig"
source "$APPSDIR/examples/configdata/Kconfig"
+source "$APPSDIR/examples/cpuhog/Kconfig"
source "$APPSDIR/examples/cxxtest/Kconfig"
source "$APPSDIR/examples/dhcpd/Kconfig"
source "$APPSDIR/examples/elf/Kconfig"
@@ -49,6 +50,7 @@ source "$APPSDIR/examples/relays/Kconfig"
source "$APPSDIR/examples/rgmp/Kconfig"
source "$APPSDIR/examples/romfs/Kconfig"
source "$APPSDIR/examples/sendmail/Kconfig"
+source "$APPSDIR/examples/serialblaster/Kconfig"
source "$APPSDIR/examples/serloop/Kconfig"
source "$APPSDIR/examples/slcd/Kconfig"
source "$APPSDIR/examples/flash_test/Kconfig"
diff --git a/apps/examples/Make.defs b/apps/examples/Make.defs
index e2c741eae..ed1375717 100644
--- a/apps/examples/Make.defs
+++ b/apps/examples/Make.defs
@@ -54,6 +54,10 @@ ifeq ($(CONFIG_EXAMPLES_CONFIGDATA),y)
CONFIGURED_APPS += examples/configdata
endif
+ifeq ($(CONFIG_EXAMPLES_CPUHOG),y)
+CONFIGURED_APPS += examples/cpuhog
+endif
+
ifeq ($(CONFIG_EXAMPLES_CXXTEST),y)
CONFIGURED_APPS += examples/cxxtest
endif
@@ -222,6 +226,10 @@ ifeq ($(CONFIG_EXAMPLES_SENDMAIL),y)
CONFIGURED_APPS += examples/sendmail
endif
+ifeq ($(CONFIG_EXAMPLES_SERIALBLASTER),y)
+CONFIGURED_APPS += examples/serialblaster
+endif
+
ifeq ($(CONFIG_EXAMPLES_SERLOOP),y)
CONFIGURED_APPS += examples/serloop
endif
diff --git a/apps/examples/Makefile b/apps/examples/Makefile
index 3691ca664..f59667a81 100644
--- a/apps/examples/Makefile
+++ b/apps/examples/Makefile
@@ -37,14 +37,15 @@
# Sub-directories
-SUBDIRS = adc buttons can cc3000 cxxtest dhcpd discover elf flash_test
-SUBDIRS += ftpc ftpd hello helloxx hidkbd igmp i2schar json keypadtest
-SUBDIRS += lcdrw mm modbus mount mtdpart nettest nrf24l01_term nsh null nx
-SUBDIRS += nxconsole nxffs nxflat nxhello nximage nxlines nxtext ostest
-SUBDIRS += pashello pipe poll posix_spawn pwm qencoder random relays rgmp
-SUBDIRS += romfs sendmail serloop slcd smart smart_test tcpecho telnetd
-SUBDIRS += thttpd tiff touchscreen udp uip usbserial usbterm watchdog
-SUBDIRS += wget wgetjson xmlrpc
+SUBDIRS = adc buttons can cc3000 cpuhog cxxtest dhcpd discover elf
+SUBDIRS += flash_test ftpc ftpd hello helloxx hidkbd igmp i2schar json
+SUBDIRS += keypadtest lcdrw mm modbus mount mtdpart nettest nrf24l01_term
+SUBDIRS += nsh null nx nxconsole nxffs nxflat nxhello nximage nxlines
+SUBDIRS += nxtext ostest pashello pipe poll posix_spawn pwm qencoder random
+SUBDIRS += relays rgmp romfs sendmail serialblaster serloop slcd smart
+SUBDIRS += smart_test tcpecho telnetd thttpd tiff touchscreen udp uip
+SUBDIRS += usbserial usbterm watchdog wget wgetjson xmlrpc
+
# Sub-directories that might need context setup. Directories may need
# context setup for a variety of reasons, but the most common is because
@@ -53,11 +54,11 @@ SUBDIRS += wget wgetjson xmlrpc
CNTXTDIRS = pwm
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
-CNTXTDIRS += adc can cc3000 cxxtest dhcpd discover flash_test ftpd
+CNTXTDIRS += adc can cc3000 cpuhog cxxtest dhcpd discover flash_test ftpd
CNTXTDIRS += hello helloxx i2schar json keypadtestmodbus lcdrw mtdpart
CNTXTDIRS += nettest nx nxhello nximage nxlines nxtext nrf24l01_term
-CNTXTDIRS += ostest random relays qencoder slcd smart_test tcpecho telnetd
-CNTXTDIRS += tiff touchscreen usbterm watchdog wgetjson
+CNTXTDIRS += ostest random relays qencoder serialblasterslcd smart_test
+CNTXTDIRS += tcpecho telnetd tiff touchscreen usbterm watchdog wgetjson
endif
all: nothing
diff --git a/apps/examples/README.txt b/apps/examples/README.txt
index 23e83f48f..3af7ccdad 100644
--- a/apps/examples/README.txt
+++ b/apps/examples/README.txt
@@ -121,11 +121,18 @@ examples/configdata
This is a Unit Test for the MTD configuration data driver
+examples/cpuhog
+^^^^^^^^^^^^^^^
+
+ Attempts to keep the system busy by passing data through a pipe in loop
+ back mode. This may be useful if you are trying run down other problems
+ that you think might only occur when the system is very busy.
+
examples/cxxtest
^^^^^^^^^^^^^^^^
This is a test of the C++ standard library. At present a port of the uClibc++
- C++ library is available. Due to licensinging issues, the uClibc++ C++ library
+ C++ library is available. Due to licensing issues, the uClibc++ C++ library
is not included in the NuttX source tree by default, but must be installed
(see misc/uClibc++/README.txt for installation).
@@ -1442,6 +1449,13 @@ examples/sendmail
CONFIG_NETUTILS_UIPLIB=y
CONFIG_NETUTILS_SMTP=y
+examples/serialblaster
+^^^^^^^^^^^^^^^^^^^^^^
+
+ Sends a repeating pattern (the alphabet) out a serial por continuously.
+ This may be useful if you are trying run down other problems that you
+ think might only occur when the serial port usage is high.
+
examples/serloop
^^^^^^^^^^^^^^^^
diff --git a/apps/examples/cpuhog/.gitignore b/apps/examples/cpuhog/.gitignore
new file mode 100644
index 000000000..fa1ec7579
--- /dev/null
+++ b/apps/examples/cpuhog/.gitignore
@@ -0,0 +1,11 @@
+/Make.dep
+/.depend
+/.built
+/*.asm
+/*.obj
+/*.rel
+/*.lst
+/*.sym
+/*.adb
+/*.lib
+/*.src
diff --git a/apps/examples/cpuhog/Kconfig b/apps/examples/cpuhog/Kconfig
new file mode 100644
index 000000000..a74074537
--- /dev/null
+++ b/apps/examples/cpuhog/Kconfig
@@ -0,0 +1,13 @@
+#
+# For a description of the syntax of this configuration file,
+# see misc/tools/kconfig-language.txt.
+#
+
+config EXAMPLES_CPUHOG
+ bool "CPU Hog"
+ default n
+ ---help---
+ Enable the cpuhog example
+
+if EXAMPLES_CPUHOG
+endif
diff --git a/apps/examples/cpuhog/Makefile b/apps/examples/cpuhog/Makefile
new file mode 100644
index 000000000..995380b0e
--- /dev/null
+++ b/apps/examples/cpuhog/Makefile
@@ -0,0 +1,109 @@
+############################################################################
+# apps/examples/cpuhog/Makefile
+#
+# 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.
+#
+############################################################################
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# do nothing loop to use up cpu time
+
+ASRCS =
+CSRCS = cpuhog_main.c
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS)
+OBJS = $(AOBJS) $(COBJS)
+
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
+ BIN = ..\..\libapps$(LIBEXT)
+else
+ifeq ($(WINTOOL),y)
+ BIN = ..\\..\\libapps$(LIBEXT)
+else
+ BIN = ../../libapps$(LIBEXT)
+endif
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# Built-in application info
+
+APPNAME = cpuhog
+PRIORITY = SCHED_PRIORITY_LOW
+STACKSIZE = 1024
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend distclean
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+.built: $(OBJS)
+ $(call ARCHIVE, $(BIN), $(OBJS))
+ @touch .built
+
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+
+context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
+else
+context:
+endif
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ $(call DELFILE, .built)
+ $(call CLEAN)
+
+distclean: clean
+ $(call DELFILE, Make.dep)
+ $(call DELFILE, .depend)
+
+-include Make.dep
diff --git a/apps/examples/cpuhog/cpuhog_main.c b/apps/examples/cpuhog/cpuhog_main.c
new file mode 100644
index 000000000..26c456952
--- /dev/null
+++ b/apps/examples/cpuhog/cpuhog_main.c
@@ -0,0 +1,163 @@
+/****************************************************************************
+ * examples/cpuhog/cpuhog_main.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 <stdint.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <nuttx/clock.h>
+#include <nuttx/arch.h>
+#include <semaphore.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define CPUHOG_FIFO_FNAME "/dev/cpuhogfifo"
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct state_s
+{
+ volatile bool initialized;
+ sem_t sem;
+ int count;
+} g_state;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int cpuhog_main(int argc, char *argv[])
+{
+ int id = -1;
+ char buf[256];
+ int fd = -1;
+
+ if (!g_state.initialized)
+ {
+ sem_init(&g_state.sem, 0, 1);
+ mkfifo(CPUHOG_FIFO_FNAME, 0666);
+ g_state.count = 0;
+ g_state.initialized = true;
+ printf("cpuhog initialized\n");
+ }
+
+ while(1)
+ {
+ /* To test semaphore interaction (debugging system crashes...) */
+
+ while (sem_wait(&g_state.sem) != 0)
+ {
+ ASSERT(errno == EINTR);
+ }
+
+ /* Burn some inside semlock */
+
+ up_udelay(3000);
+ sem_post(&g_state.sem);
+
+ /* Unassigned */
+
+ if (id == -1)
+ {
+ id = g_state.count++;
+ printf("cpuhog %d", id);
+ if (id == 0)
+ {
+ printf(": consumer\n");
+ fd = open(CPUHOG_FIFO_FNAME, O_RDONLY);
+ }
+ else if (id == 1)
+ {
+ printf(": producer\n");
+ fd = open(CPUHOG_FIFO_FNAME, O_WRONLY);
+ }
+ else
+ {
+ printf("\n");
+ }
+ }
+
+ /* Consumer */
+
+ else if (id == 0)
+ {
+ if (read(fd, buf, sizeof(buf)) > 0)
+ {
+ printf("-");
+ }
+ else
+ {
+ perror("fifo: ");
+ }
+ }
+
+ /* Producer */
+
+ else if (id == 1)
+ {
+ if (write(fd, buf, sizeof(buf)) > 0)
+ {
+ printf("+");
+ }
+ else
+ {
+ perror("fifo: ");
+ }
+ }
+
+ /* Otherwise just a cpu burner */
+
+ else
+ {
+ /* Burn some outside semlock */
+
+ up_udelay(3000);
+ }
+ }
+
+ return 0;
+}
diff --git a/apps/examples/serialblaster/.gitignore b/apps/examples/serialblaster/.gitignore
new file mode 100644
index 000000000..fa1ec7579
--- /dev/null
+++ b/apps/examples/serialblaster/.gitignore
@@ -0,0 +1,11 @@
+/Make.dep
+/.depend
+/.built
+/*.asm
+/*.obj
+/*.rel
+/*.lst
+/*.sym
+/*.adb
+/*.lib
+/*.src
diff --git a/apps/examples/serialblaster/Kconfig b/apps/examples/serialblaster/Kconfig
new file mode 100644
index 000000000..2cb733445
--- /dev/null
+++ b/apps/examples/serialblaster/Kconfig
@@ -0,0 +1,13 @@
+#
+# For a description of the syntax of this configuration file,
+# see misc/tools/kconfig-language.txt.
+#
+
+config EXAMPLES_SERIALBLASTER
+ bool "Serial Blaster example"
+ default n
+ ---help---
+ Enable the serial blaster example
+
+if EXAMPLES_SERIALBLASTER
+endif
diff --git a/apps/examples/serialblaster/Makefile b/apps/examples/serialblaster/Makefile
new file mode 100644
index 000000000..da9eb45a9
--- /dev/null
+++ b/apps/examples/serialblaster/Makefile
@@ -0,0 +1,109 @@
+############################################################################
+# apps/examples/serialblaster/Makefile
+#
+# 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.
+#
+############################################################################
+
+-include $(TOPDIR)/.config
+-include $(TOPDIR)/Make.defs
+include $(APPDIR)/Make.defs
+
+# For testing: Blast canned characters at a designated serial port
+
+ASRCS =
+CSRCS = serialblaster_main.c
+
+AOBJS = $(ASRCS:.S=$(OBJEXT))
+COBJS = $(CSRCS:.c=$(OBJEXT))
+
+SRCS = $(ASRCS) $(CSRCS)
+OBJS = $(AOBJS) $(COBJS)
+
+ifeq ($(CONFIG_WINDOWS_NATIVE),y)
+ BIN = ..\..\libapps$(LIBEXT)
+else
+ifeq ($(WINTOOL),y)
+ BIN = ..\\..\\libapps$(LIBEXT)
+else
+ BIN = ../../libapps$(LIBEXT)
+endif
+endif
+
+ROOTDEPPATH = --dep-path .
+
+# Built-in application info
+
+APPNAME = serialblaster
+PRIORITY = SCHED_PRIORITY_DEFAULT
+STACKSIZE = 2048
+
+# Common build
+
+VPATH =
+
+all: .built
+.PHONY: clean depend distclean
+
+$(AOBJS): %$(OBJEXT): %.S
+ $(call ASSEMBLE, $<, $@)
+
+$(COBJS): %$(OBJEXT): %.c
+ $(call COMPILE, $<, $@)
+
+.built: $(OBJS)
+ $(call ARCHIVE, $(BIN), $(OBJS))
+ @touch .built
+
+ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
+$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
+ $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
+
+context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
+else
+context:
+endif
+
+.depend: Makefile $(SRCS)
+ @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
+ @touch $@
+
+depend: .depend
+
+clean:
+ $(call DELFILE, .built)
+ $(call CLEAN)
+
+distclean: clean
+ $(call DELFILE, Make.dep)
+ $(call DELFILE, .depend)
+
+-include Make.dep
diff --git a/apps/examples/serialblaster/serialblaster_main.c b/apps/examples/serialblaster/serialblaster_main.c
new file mode 100644
index 000000000..b4421e984
--- /dev/null
+++ b/apps/examples/serialblaster/serialblaster_main.c
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * examples/serialblaster/serialblaster_main.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 <stdint.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <nuttx/clock.h>
+
+#include <nuttx/fs/fs.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define BUFFERED_IO
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const char s[] = "abcdefghijklmnopqrstuvwxyz";
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * serloop_main
+ ****************************************************************************/
+
+int serialblaster_main(int argc, char *argv[])
+{
+ while(1)
+ {
+#ifdef BUFFERED_IO
+ int ret = fputs(s, stdout);
+#else
+ int ret = write(1, s, sizeof(s)-1);
+#endif
+ }
+
+ return 0;
+}
diff --git a/nuttx/configs/sam4s-xplained-pro/TODO.txt b/nuttx/configs/sam4s-xplained-pro/TODO.txt
index 0048df71d..5c1a088ab 100644
--- a/nuttx/configs/sam4s-xplained-pro/TODO.txt
+++ b/nuttx/configs/sam4s-xplained-pro/TODO.txt
@@ -1,12 +1,56 @@
- 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.
+ - 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.
+
+ - once implemented, the free() cmd replacement can show flash information.
- Seen crashes when running serial ports below 921600
+
+ - COM34 (UART1, ttyS1) runs the smoothest with 'serialblaster' test...
+ the other two (UART0, USART1) seem to stutter...
+
+ - created a cpuhog test. Each instance takes a semaphore, burns cpu for 6ms and then releases
+ the sem to exercises semaphores passing and a busy cpu. The first two instances become a
+ producer/consumer pair using a pipe (FIFO) to exercise the fileio data passing.
+ -> no crashes with 8 instances running. (No MMU, No BASEPRI)
+ -> no crashes with 8 instances running. (MMU + BASEPRI)
+ -> not however that the serial ports are very finicky with BASEPRI enabled!
+ This setup sends single charactes for each produced or consumed block,
+ and doesn't seem to have any issues:
+ NuttShell (NSH)
+ nsh> cpuhog > /dev/ttyS1 &
+ cpuhog [5:50]
+ nsh> cpuhog > /dev/ttyS2 &
+ cpuhog [7:50]
+ nsh> cpuhog &
+ cpuhog [8:50]
+ nsh> cpuhog 2
+ cpuhog &
+ cpuhog [9:50]
+ nsh> cpuhog 3
+ cpuhog &
+ cpuhog [10:50]
+ nsh> cpuhog 4
+ cpuhog &
+ cpuhog [11:50]
+ nsh> cpuhog 5
+
+ nsh> cpuhog &
+ cpuhog [12:50]
+ nsh> cpuhog 6
+
+ nsh> cpuhog &
+ cpuhog [13:50]
+ nsh> cpuhog 7
+
- 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.
+ - Inbound hardware flow control requires dma.
+
+Current Test:
+
+40mA: 120Mhz (240 MHz PLL) with SDCard mounted, UART0+UART1+USART1 enabled, USB Device availible (but nothing plugged in)
+37.8mA: 120Mhz (120 MHz PLL) with SDCard mounted, UART0+UART1+USART1 enabled
+16.9mA: "" with WFI added to up_idle()
diff --git a/nuttx/configs/sam4s-xplained-pro/include/board.h b/nuttx/configs/sam4s-xplained-pro/include/board.h
index 064494b51..05de1ea67 100644
--- a/nuttx/configs/sam4s-xplained-pro/include/board.h
+++ b/nuttx/configs/sam4s-xplained-pro/include/board.h
@@ -135,6 +135,7 @@
#define HSMCI_SDXFR_CLKDIV (2 << HSMCI_MR_CLKDIV_SHIFT)
#define HSMCI_SDWIDEXFR_CLKDIV HSMCI_SDXFR_CLKDIV
+#ifdef CONFIG_SAM34_UDP
/* The PLL clock (USB_48M or UDPCK) is driven from the output of the PLL,
* PLLACK. The PLL clock must be 48MHz. PLLACK can be divided down via the
* PMC USB register to provide the PLL clock. So in order to use the USB
@@ -144,8 +145,9 @@
* PLLACK = 192MHz, USBDIV=5, USB_48M = 192 MHz / (3 + 1) = 48MHz
*/
-#define BOARD_PMC_USBS (0)
-#define BOARD_PMC_USBDIV (4 << PMC_USB_USBDIV_SHIFT)
+# define BOARD_PMC_USBS (0)
+# define BOARD_PMC_USBDIV (4 << PMC_USB_USBDIV_SHIFT)
+#endif
/* FLASH wait states:
*
diff --git a/nuttx/configs/sam4s-xplained-pro/nsh/defconfig b/nuttx/configs/sam4s-xplained-pro/nsh/defconfig
index 0564f3843..e25f354db 100644
--- a/nuttx/configs/sam4s-xplained-pro/nsh/defconfig
+++ b/nuttx/configs/sam4s-xplained-pro/nsh/defconfig
@@ -50,7 +50,6 @@ CONFIG_ARCH_HAVE_STACKCHECK=y
#
# CONFIG_DEBUG_MM is not set
# CONFIG_DEBUG_SCHED is not set
-# CONFIG_DEBUG_USB is not set
# CONFIG_DEBUG_FS is not set
# CONFIG_DEBUG_LIB is not set
# CONFIG_DEBUG_BINFMT is not set
@@ -222,7 +221,7 @@ CONFIG_SAM34_SMC=y
# CONFIG_SAM34_TWIS1 is not set
CONFIG_SAM34_UART0=y
CONFIG_SAM34_UART1=y
-CONFIG_SAM34_UDP=y
+# CONFIG_SAM34_UDP is not set
# CONFIG_SAM34_USART0 is not set
CONFIG_SAM34_USART1=y
CONFIG_SAM34_WDT=y
@@ -251,11 +250,6 @@ 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=y
@@ -265,7 +259,7 @@ 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_PRIORITY=220
CONFIG_WDT_THREAD_STACKSIZE=512
#
@@ -280,9 +274,8 @@ CONFIG_ARCH_HAVE_IRQPRIO=y
CONFIG_ARCH_HAVE_VFORK=y
# CONFIG_ARCH_HAVE_MMU is not set
# CONFIG_ARCH_NAND_HWECC is not set
-CONFIG_ARCH_IRQPRIO=y
+# CONFIG_ARCH_IRQPRIO is not set
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
@@ -438,7 +431,7 @@ CONFIG_PTHREAD_STACK_DEFAULT=4096
#
# Device Drivers
#
-CONFIG_DISABLE_POLL=y
+# CONFIG_DISABLE_POLL is not set
CONFIG_DEV_NULL=y
CONFIG_DEV_ZERO=y
# CONFIG_LOOP is not set
@@ -473,14 +466,13 @@ CONFIG_MMCSD_SDIO=y
# CONFIG_SDIO_MUXBUS is not set
CONFIG_SDIO_BLOCKSETUP=y
# CONFIG_MTD is not set
-# CONFIG_PIPES is not set
+CONFIG_PIPES=y
# CONFIG_PM is not set
# CONFIG_POWER is not set
# CONFIG_SENSORS is not set
# 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=y
@@ -510,6 +502,7 @@ CONFIG_ARCH_HAVE_USART1=y
CONFIG_USART1_ISUART=y
CONFIG_MCU_SERIAL=y
CONFIG_STANDARD_SERIAL=y
+CONFIG_SERIAL_NPOLLWAITERS=2
# CONFIG_SERIAL_TIOCSERGSTRUCT is not set
CONFIG_UART0_SERIAL_CONSOLE=y
# CONFIG_UART1_SERIAL_CONSOLE is not set
@@ -521,7 +514,7 @@ CONFIG_UART0_SERIAL_CONSOLE=y
#
CONFIG_UART0_RXBUFSIZE=256
CONFIG_UART0_TXBUFSIZE=256
-CONFIG_UART0_BAUD=912600
+CONFIG_UART0_BAUD=115200
CONFIG_UART0_BITS=8
CONFIG_UART0_PARITY=0
CONFIG_UART0_2STOP=0
@@ -533,7 +526,7 @@ CONFIG_UART0_2STOP=0
#
CONFIG_UART1_RXBUFSIZE=256
CONFIG_UART1_TXBUFSIZE=256
-CONFIG_UART1_BAUD=921600
+CONFIG_UART1_BAUD=115200
CONFIG_UART1_BITS=8
CONFIG_UART1_PARITY=0
CONFIG_UART1_2STOP=0
@@ -545,7 +538,7 @@ CONFIG_UART1_2STOP=0
#
CONFIG_USART1_RXBUFSIZE=256
CONFIG_USART1_TXBUFSIZE=256
-CONFIG_USART1_BAUD=921600
+CONFIG_USART1_BAUD=115200
CONFIG_USART1_BITS=8
CONFIG_USART1_PARITY=0
CONFIG_USART1_2STOP=0
@@ -553,49 +546,7 @@ CONFIG_USART1_2STOP=0
# 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_USBDEV is not set
# CONFIG_USBHOST is not set
# CONFIG_WIRELESS is not set
@@ -688,8 +639,8 @@ CONFIG_BUILTIN=y
#
# Standard C Library Options
#
-CONFIG_STDIO_BUFFER_SIZE=64
-CONFIG_STDIO_LINEBUFFER=y
+CONFIG_STDIO_BUFFER_SIZE=0
+# CONFIG_STDIO_LINEBUFFER is not set
CONFIG_NUNGET_CHARS=2
# CONFIG_LIBM is not set
# CONFIG_NOPRINTF_FIELDWIDTH is not set
@@ -714,14 +665,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512
# Non-standard Library Support
#
CONFIG_SCHED_WORKQUEUE=y
-CONFIG_SCHED_HPWORK=y
-CONFIG_SCHED_WORKPRIORITY=192
-CONFIG_SCHED_WORKPERIOD=50000
-CONFIG_SCHED_WORKSTACKSIZE=2048
-CONFIG_SCHED_LPWORK=y
-CONFIG_SCHED_LPWORKPRIORITY=50
-CONFIG_SCHED_LPWORKPERIOD=50000
-CONFIG_SCHED_LPWORKSTACKSIZE=2048
+# CONFIG_SCHED_HPWORK is not set
# CONFIG_LIB_KBDCODEC is not set
# CONFIG_LIB_SLCDCODEC is not set
@@ -753,6 +697,7 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024
# CONFIG_EXAMPLES_BUTTONS is not set
# CONFIG_EXAMPLES_CAN is not set
# CONFIG_EXAMPLES_CONFIGDATA is not set
+CONFIG_EXAMPLES_CPUHOG=y
# CONFIG_EXAMPLES_CXXTEST is not set
# CONFIG_EXAMPLES_DHCPD is not set
# CONFIG_EXAMPLES_ELF is not set
@@ -787,6 +732,7 @@ CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
# CONFIG_EXAMPLES_RGMP is not set
# CONFIG_EXAMPLES_ROMFS is not set
# CONFIG_EXAMPLES_SENDMAIL is not set
+CONFIG_EXAMPLES_SERIALBLASTER=y
# CONFIG_EXAMPLES_SERLOOP is not set
# CONFIG_EXAMPLES_SLCD is not set
# CONFIG_EXAMPLES_SMART_TEST is not set
@@ -910,12 +856,10 @@ 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_USBDEV_TRACE is not set
CONFIG_NSH_CONDEV="/dev/console"
CONFIG_NSH_ARCHINIT=y
@@ -1013,13 +957,6 @@ 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
@@ -1032,15 +969,6 @@ CONFIG_SYSTEM_CDCACM_TRACEINTERRUPTS=y
#
# 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