diff options
author | px4dev <px4@purgatory.org> | 2013-01-14 21:01:58 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2013-01-14 21:01:58 -0800 |
commit | 854c6436b4e3b292fd04843795d0369dc8856783 (patch) | |
tree | 4d5602f5c70926d2dcd01294561ddd8df4378462 /apps/examples | |
parent | 6d138a845aabad31060bd00da0d20d177d3f4be4 (diff) | |
parent | c38ad4ded570eddadeeca3579d02dfc63dcc8a9d (diff) | |
download | px4-firmware-854c6436b4e3b292fd04843795d0369dc8856783.tar.gz px4-firmware-854c6436b4e3b292fd04843795d0369dc8856783.tar.bz2 px4-firmware-854c6436b4e3b292fd04843795d0369dc8856783.zip |
Pull NuttX up to the 6.24 release.
Merge branch 'nuttx-merge-5447'
Diffstat (limited to 'apps/examples')
26 files changed, 534 insertions, 446 deletions
diff --git a/apps/examples/Kconfig b/apps/examples/Kconfig index 865268add..ae5f0a61a 100644 --- a/apps/examples/Kconfig +++ b/apps/examples/Kconfig @@ -3,206 +3,60 @@ # see misc/tools/kconfig-language.txt. # -menu "ADC Example" source "$APPSDIR/examples/adc/Kconfig" -endmenu - -menu "Buttons Example" source "$APPSDIR/examples/buttons/Kconfig" -endmenu - -menu "CAN Example" source "$APPSDIR/examples/can/Kconfig" -endmenu - -menu "USB CDC/ACM Class Driver Example" source "$APPSDIR/examples/cdcacm/Kconfig" -endmenu - -menu "USB composite Class Driver Example" source "$APPSDIR/examples/composite/Kconfig" -endmenu - -menu "DHCP Server Example" +source "$APPSDIR/examples/cxxtest/Kconfig" source "$APPSDIR/examples/dhcpd/Kconfig" -endmenu - -menu "FTP Client Example" +source "$APPSDIR/examples/elf/Kconfig" source "$APPSDIR/examples/ftpc/Kconfig" -endmenu - -menu "FTP Server Example" source "$APPSDIR/examples/ftpd/Kconfig" -endmenu - -menu "\"Hello, World!\" Example" source "$APPSDIR/examples/hello/Kconfig" -endmenu - -menu "\"Hello, World!\" C++ Example" source "$APPSDIR/examples/helloxx/Kconfig" -endmenu - -menu "USB HID Keyboard Example" +source "$APPSDIR/examples/json/Kconfig" source "$APPSDIR/examples/hidkbd/Kconfig" -endmenu - -menu "IGMP Example" +source "$APPSDIR/examples/keypadtest/Kconfig" source "$APPSDIR/examples/igmp/Kconfig" -endmenu - -menu "LCD Read/Write Example" source "$APPSDIR/examples/lcdrw/Kconfig" -endmenu - -menu "Memory Management Example" source "$APPSDIR/examples/mm/Kconfig" -endmenu - -menu "File System Mount Example" source "$APPSDIR/examples/mount/Kconfig" -endmenu - -menu "FreeModBus Example" source "$APPSDIR/examples/modbus/Kconfig" -endmenu - -menu "Network Test Example" source "$APPSDIR/examples/nettest/Kconfig" -endmenu - -menu "NuttShell (NSH) Example" source "$APPSDIR/examples/nsh/Kconfig" -endmenu - -menu "NULL Example" source "$APPSDIR/examples/null/Kconfig" -endmenu - -menu "NX Graphics Example" source "$APPSDIR/examples/nx/Kconfig" -endmenu - -menu "NxConsole Example" source "$APPSDIR/examples/nxconsole/Kconfig" -endmenu - -menu "NXFFS File System Example" source "$APPSDIR/examples/nxffs/Kconfig" -endmenu - -menu "NXFLAT Example" source "$APPSDIR/examples/nxflat/Kconfig" -endmenu - -menu "NX Graphics \"Hello, World!\" Example" source "$APPSDIR/examples/nxhello/Kconfig" -endmenu - -menu "NX Graphics image Example" source "$APPSDIR/examples/nximage/Kconfig" -endmenu - -menu "NX Graphics lines Example" source "$APPSDIR/examples/nxlines/Kconfig" -endmenu - -menu "NX Graphics Text Example" source "$APPSDIR/examples/nxtext/Kconfig" -endmenu - -menu "OS Test Example" source "$APPSDIR/examples/ostest/Kconfig" -endmenu - -menu "Pascal \"Hello, World!\"example" source "$APPSDIR/examples/pashello/Kconfig" -endmenu - -menu "Pipe Example" source "$APPSDIR/examples/pipe/Kconfig" -endmenu - -menu "Poll Example" source "$APPSDIR/examples/poll/Kconfig" -endmenu - -menu "Pulse Width Modulation (PWM) Example" source "$APPSDIR/examples/pwm/Kconfig" -endmenu - -menu "Quadrature Encoder Example" source "$APPSDIR/examples/qencoder/Kconfig" -endmenu - -menu "RGMP Example" +source "$APPSDIR/examples/relays/Kconfig" source "$APPSDIR/examples/rgmp/Kconfig" -endmenu - -menu "ROMFS Example" source "$APPSDIR/examples/romfs/Kconfig" -endmenu - -menu "sendmail Example" source "$APPSDIR/examples/sendmail/Kconfig" -endmenu - -menu "Serial Loopback Example" source "$APPSDIR/examples/serloop/Kconfig" -endmenu - -menu "Telnet Daemon Example" source "$APPSDIR/examples/telnetd/Kconfig" -endmenu - -menu "THTTPD Web Server Example" source "$APPSDIR/examples/thttpd/Kconfig" -endmenu - -menu "TIFF Generation Example" source "$APPSDIR/examples/tiff/Kconfig" -endmenu - -menu "Touchscreen Example" source "$APPSDIR/examples/touchscreen/Kconfig" -endmenu - -menu "UDP Example" source "$APPSDIR/examples/udp/Kconfig" -endmenu - -menu "UDP Discovery Daemon Example" source "$APPSDIR/examples/discover/Kconfig" -endmenu - -menu "uIP Web Server Example" source "$APPSDIR/examples/uip/Kconfig" -endmenu - -menu "USB Serial Test Example" source "$APPSDIR/examples/usbserial/Kconfig" -endmenu - -menu "USB Mass Storage Class Example" source "$APPSDIR/examples/usbstorage/Kconfig" -endmenu - -menu "USB Serial Terminal Example" source "$APPSDIR/examples/usbterm/Kconfig" -endmenu - -menu "Watchdog timer Example" source "$APPSDIR/examples/watchdog/Kconfig" -endmenu - -menu "wget Example" source "$APPSDIR/examples/wget/Kconfig" -endmenu - -menu "WLAN Example" +source "$APPSDIR/examples/wgetjson/Kconfig" source "$APPSDIR/examples/wlan/Kconfig" -endmenu - -menu "XML RPC Example" source "$APPSDIR/examples/xmlrpc/Kconfig" -endmenu diff --git a/apps/examples/Make.defs b/apps/examples/Make.defs index d03b976d2..91f1331df 100644 --- a/apps/examples/Make.defs +++ b/apps/examples/Make.defs @@ -54,6 +54,10 @@ ifeq ($(CONFIG_EXAMPLES_COMPOSITE),y) CONFIGURED_APPS += examples/composite endif +ifeq ($(CONFIG_EXAMPLES_CXXTEST),y) +CONFIGURED_APPS += examples/cxxtest +endif + ifeq ($(CONFIG_EXAMPLES_DHCPD),y) CONFIGURED_APPS += examples/dhcpd endif @@ -62,6 +66,10 @@ ifeq ($(CONFIG_EXAMPLES_DISCOVER),y) CONFIGURED_APPS += examples/discover endif +ifeq ($(CONFIG_EXAMPLES_ELF),y) +CONFIGURED_APPS += examples/elf +endif + ifeq ($(CONFIG_EXAMPLES_FTPC),y) CONFIGURED_APPS += examples/ftpc endif @@ -86,6 +94,14 @@ ifeq ($(CONFIG_EXAMPLES_IGMP),y) CONFIGURED_APPS += examples/igmp endif +ifeq ($(CONFIG_EXAMPLES_JSON),y) +CONFIGURED_APPS += examples/json +endif + +ifeq ($(CONFIG_EXAMPLES_KEYPADTEST),y) +CONFIGURED_APPS += examples/keypadtest +endif + ifeq ($(CONFIG_EXAMPLES_LCDRW),y) CONFIGURED_APPS += examples/lcdrw endif @@ -94,6 +110,10 @@ ifeq ($(CONFIG_EXAMPLES_MM),y) CONFIGURED_APPS += examples/mm endif +ifeq ($(CONFIG_EXAMPLES_MODBUS),y) +CONFIGURED_APPS += examples/modbus +endif + ifeq ($(CONFIG_EXAMPLES_MOUNT),y) CONFIGURED_APPS += examples/mount endif @@ -166,6 +186,10 @@ ifeq ($(CONFIG_EXAMPLES_QENCODER),y) CONFIGURED_APPS += examples/qencoder endif +ifeq ($(CONFIG_EXAMPLES_RELAYS),y) +CONFIGURED_APPS += examples/relays +endif + ifeq ($(CONFIG_EXAMPLES_RGMP),y) CONFIGURED_APPS += examples/rgmp endif @@ -226,6 +250,10 @@ ifeq ($(CONFIG_EXAMPLES_WGET),y) CONFIGURED_APPS += examples/wget endif +ifeq ($(CONFIG_EXAMPLES_WGETJSON),y) +CONFIGURED_APPS += examples/wgetjson +endif + ifeq ($(CONFIG_EXAMPLES_WLAN),y) CONFIGURED_APPS += examples/wlan endif diff --git a/apps/examples/Makefile b/apps/examples/Makefile index 453f99ce7..bdbfd4de8 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -37,12 +37,12 @@ # Sub-directories -SUBDIRS = adc buttons can cdcacm composite dhcpd discover ftpc ftpd hello -SUBDIRS += helloxx hidkbd igmp lcdrw mm modbus mount nettest nsh null nx -SUBDIRS += nxconsole nxffs nxflat nxhello nximage nxlines nxtext ostest -SUBDIRS += pashello pipe poll pwm qencoder rgmp romfs serloop telnetd -SUBDIRS += thttpd tiff touchscreen udp uip usbserial sendmail usbstorage -SUBDIRS += usbterm watchdog wget wlan +SUBDIRS = adc buttons can cdcacm composite cxxtest dhcpd discover elf ftpc +SUBDIRS += ftpd hello helloxx hidkbd igmp json keypadtest lcdrw mm modbus mount +SUBDIRS += nettest nsh null nx nxconsole nxffs nxflat nxhello nximage +SUBDIRS += nxlines nxtext ostest pashello pipe poll pwm qencoder relays +SUBDIRS += rgmp romfs serloop telnetd thttpd tiff touchscreen udp uip +SUBDIRS += usbserial sendmail usbstorage usbterm watchdog wget wgetjson wlan # Sub-directories that might need context setup. Directories may need # context setup for a variety of reasons, but the most common is because @@ -57,8 +57,8 @@ SUBDIRS += usbterm watchdog wget wlan CNTXTDIRS = pwm ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -CNTXTDIRS += adc can cdcacm composite discover ftpd dhcpd modbus nettest -CNTXTDIRS += qencoder telnetd watchdog +CNTXTDIRS += adc can cdcacm composite cxxtest dhcpd discover ftpd json keypadtest +CNTXTDIRS += modbus nettest nxlines relays qencoder telnetd watchdog wgetjson endif ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y) @@ -79,9 +79,6 @@ endif ifeq ($(CONFIG_EXAMPLES_NXIMAGE_BUILTIN),y) CNTXTDIRS += nximage endif -ifeq ($(CONFIG_EXAMPLES_LINES_BUILTIN),y) -CNTXTDIRS += nxlines -endif ifeq ($(CONFIG_EXAMPLES_NXTEXT_BUILTIN),y) CNTXTDIRS += nxtext endif @@ -105,27 +102,25 @@ all: nothing .PHONY: nothing context depend clean distclean +define SDIR_template +$(1)_$(2): + $(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" +endef + +$(foreach SDIR, $(CNTXTDIRS), $(eval $(call SDIR_template,$(SDIR),context))) +$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),depend))) +$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),clean))) +$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),distclean))) + nothing: -context: - @for dir in $(CNTXTDIRS) ; do \ - $(MAKE) -C $$dir context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done - -depend: - @for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir depend TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done - -clean: - @for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done - -distclean: clean - @for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir distclean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done +context: $(foreach SDIR, $(CNTXTDIRS), $(SDIR)_context) + +depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend) + +clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean) + +distclean: clean $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean) -include Make.dep diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 763427e32..e40a63be9 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -239,6 +239,29 @@ examples/composite CONFIG_EXAMPLES_COMPOSITE_TRACEINTERRUPTS Show interrupt-related events. +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 + is not included in the NuttX source tree by default, but must be installed + (see misc/uClibc++/README.txt for installation). + + The NuttX setting that are required include: + + CONFIG_HAVE_CXX=y + CONFIG_HAVE_CXXINITIALIZE=y + CONFIG_UCLIBCXX=y + + Additional uClibc++ settings may be required in your build environment. + + The uClibc++ test includes simple test of: + + - iostreams, + - STL, + - RTTI, and + - Exceptions + examples/dhcpd ^^^^^^^^^^^^^^ @@ -297,6 +320,68 @@ examples/discover CONFIG_EXAMPLES_DISCOVER_DRIPADDR - Router IP address CONFIG_EXAMPLES_DISCOVER_NETMASK - Network Mask +examples/elf +^^^^^^^^^^^^ + + This example builds a small ELF loader test case. This includes several + test programs under examples/elf tests. These tests are build using + the relocatable ELF format and installed in a ROMFS file system. At run time, + each program in the ROMFS file system is executed. Requires CONFIG_ELF. + Other configuration options: + + CONFIG_EXAMPLES_ELF_DEVMINOR - The minor device number of the ROMFS block. + For example, the N in /dev/ramN. Used for registering the RAM block driver + that will hold the ROMFS file system containing the ELF executables to be + tested. Default: 0 + + CONFIG_EXAMPLES_ELF_DEVPATH - The path to the ROMFS block driver device. This + must match EXAMPLES_ELF_DEVMINOR. Used for registering the RAM block driver + that will hold the ROMFS file system containing the ELF executables to be + tested. Default: "/dev/ram0" + + NOTES: + + 1. CFLAGS should be provided in CELFFLAGS. RAM and FLASH memory regions + may require long allcs. For ARM, this might be: + + CELFFLAGS = $(CFLAGS) -mlong-calls + + Similarly for C++ flags which must be provided in CXXELFFLAGS. + + 2. Your top-level nuttx/Make.defs file must alos include an approproate definition, + LDELFFLAGS, to generate a relocatable ELF object. With GNU LD, this should + include '-r' and '-e main' (or _main on some platforms). + + LDELFFLAGS = -r -e main + + If you use GCC to link, you make also need to include '-nostdlib' or + '-nostartfiles' and '-nodefaultlibs'. + + 3. This example also requires genromfs. genromfs can be build as part of the + nuttx toolchain. Or can built from the genromfs sources that can be found + at misc/tools/genromfs-0.5.2.tar.gz. In any event, the PATH variable must + include the path to the genromfs executable. + + 4. ELF size: The ELF files in this example are, be default, quite large + because they include a lot of "build garbage". You can greatly reduce the + size of the ELF binaries are using the 'objcopy --strip-unneeded' command to + remove un-necessary information from the ELF files. + + 5. Simulator. You cannot use this example with the the NuttX simulator on + Cygwin. That is because the Cygwin GCC does not generate ELF file but + rather some Windows-native binary format. + + If you really want to do this, you can create a NuttX x86 buildroot toolchain + and use that be build the ELF executables for the ROMFS file system. + + 6. Linker scripts. You might also want to use a linker scripts to combine + sections better. An example linker script is at nuttx/binfmt/libelf/gnu-elf.ld. + That example might have to be tuned for your particular linker output to + position additional sections correctly. The GNU LD LDELFFLAGS then might + be: + + LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/libelf/gnu-elf.ld + examples/ftpc ^^^^^^^^^^^^^ @@ -482,6 +567,32 @@ examples/igmp CONFIGURED_APPS += uiplib +examples/json +^^^^^^^^^^^^^ + + This example exercises the cJSON implementation at apps/netutils/json. + This example contains logic taken from the cJSON project: + + http://sourceforge.net/projects/cjson/ + + The example corresponds to SVN revision r42 (with lots of changes for + NuttX coding standards). As of r42, the SVN repository was last updated + on 2011-10-10 so I presume that the code is stable and there is no risk + of maintaining duplicate logic in the NuttX repository. + +examples/keypadtest +^^^^^^^^^^^^^^^^^^^ + + This is a generic keypad test example. It is similar to the USB hidkbd + example, but makes no assumptions about the underlying keyboard interface. + It uses the interfaces of include/nuttx/input/keypad.h. + + CONFIG_EXAMPLES_KEYPADTEST - Selects the keypadtest example (only need + if the mconf/Kconfig tool is used. + + CONFIG_EXAMPLES_KEYPAD_DEVNAME - The name of the keypad device that will + be opened in order to perform the keypad test. Default: "/dev/keypad" + examples/lcdrw ^^^^^^^^^^^^^^ @@ -496,6 +607,11 @@ examples/lcdrw * CONFIG_EXAMPLES_LDCRW_YRES LCD Y resolution. Default: 320 + NOTE: This test exercises internal lcd driver interfaces. As such, it + relies on internal OS interfaces that are not normally available to a + user-space program. As a result, this example cannot be used if a + NuttX is built as a protected, supervisor kernel (CONFIG_NUTTX_KERNEL). + examples/mm ^^^^^^^^^^^ @@ -838,8 +954,6 @@ examplex/nxlines The following configuration options can be selected: - CONFIG_EXAMPLES_NXLINES_BUILTIN -- Build the NXLINES example as a "built-in" - that can be executed from the NSH command line CONFIG_EXAMPLES_NXLINES_VPLANE -- The plane to select from the frame- buffer driver for use in the test. Default: 0 CONFIG_EXAMPLES_NXLINES_DEVNO - The LCD device to select from the LCD @@ -877,6 +991,9 @@ examplex/nxlines FAR struct fb_vtable_s *up_nxdrvinit(unsigned int devno); #endif + CONFIG_NSH_BUILTIN_APPS - Build the NX lines examples as an NSH built-in + function. + examples/nxtext ^^^^^^^^^^^^^^^ @@ -984,6 +1101,17 @@ examples/ostest Specifies the number of threads to create in the barrier test. The default is 8 but a smaller number may be needed on systems without sufficient memory to start so many threads. + * CONFIG_EXAMPLES_OSTEST_RR_RANGE + During round-robin scheduling test two threads are created. Each of the threads + searches for prime numbers in the configurable range, doing that configurable + number of times. + This value specifies the end of search range and together with number of runs + allows to configure the length of this test - it should last at least a few + tens of seconds. Allowed values [1; 32767], default 10000 + * CONFIG_EXAMPLES_OSTEST_RR_RUNS + During round-robin scheduling test two threads are created. Each of the threads + searches for prime numbers in the configurable range, doing that configurable + number of times. examples/pashello ^^^^^^^^^^^^^^^^^ @@ -1110,17 +1238,28 @@ examples/qencoder Specific configuration options for this example include: - CONFIG_EXAMPLES_QENCODER_DEVPATH - The path to the QE device. Default: - /dev/qe0 - CONFIG_EXAMPLES_QENCODER_NSAMPLES - If CONFIG_NSH_BUILTIN_APPS - is defined, then the number of samples is provided on the command line - and this value is ignored. Otherwise, this number of samples is - collected and the program terminates. Default: Samples are collected - indefinitely. - CONFIG_EXAMPLES_QENCODER_DELAY - This value provides the delay (in - milliseonds) between each sample. If CONFIG_NSH_BUILTIN_APPS - is defined, then this value is the default delay if no other delay is - provided on the command line. Default: 100 milliseconds + CONFIG_EXAMPLES_QENCODER_DEVPATH - The path to the QE device. Default: + /dev/qe0 + CONFIG_EXAMPLES_QENCODER_NSAMPLES - If CONFIG_NSH_BUILTIN_APPS + is defined, then the number of samples is provided on the command line + and this value is ignored. Otherwise, this number of samples is + collected and the program terminates. Default: Samples are collected + indefinitely. + CONFIG_EXAMPLES_QENCODER_DELAY - This value provides the delay (in + milliseonds) between each sample. If CONFIG_NSH_BUILTIN_APPS + is defined, then this value is the default delay if no other delay is + provided on the command line. Default: 100 milliseconds + +examples/relays +^^^^^^^^^^^^^^^ + + Requires CONFIG_ARCH_RELAYS. + Contributed by Darcy Gong. + + NOTE: This test exercises internal relay driver interfaces. As such, it + relies on internal OS interfaces that are not normally available to a + user-space program. As a result, this example cannot be used if a + NuttX is built as a protected, supervisor kernel (CONFIG_NUTTX_KERNEL). examples/rgmp ^^^^^^^^^^^^^ @@ -1672,7 +1811,16 @@ examples/wget CONFIGURED_APPS += resolv CONFIGURED_APPS += webclient +examples/wget +^^^^^^^^^^^^^ + + Uses wget to get a JSON encoded file, then decodes the file. + + CONFIG_EXAMPLES_WDGETJSON_MAXSIZE - Max. JSON Buffer Size + CONFIG_EXAMPLES_EXAMPLES_WGETJSON_URL - wget URL + examples/xmlrpc +^^^^^^^^^^^^^^^ This example exercises the "Embeddable Lightweight XML-RPC Server" which is discussed at: diff --git a/apps/examples/adc/Makefile b/apps/examples/adc/Makefile index 6357dfc3d..69862b383 100644 --- a/apps/examples/adc/Makefile +++ b/apps/examples/adc/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/adc/Makefile # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -76,9 +80,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -90,16 +92,17 @@ endif context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/adc/adc_main.c b/apps/examples/adc/adc_main.c index 404fba8c1..553658fee 100644 --- a/apps/examples/adc/adc_main.c +++ b/apps/examples/adc/adc_main.c @@ -289,7 +289,7 @@ int adc_main(int argc, char *argv[]) { message("adc_main: open %s failed: %d\n", g_adcstate.devpath, errno); errval = 2; - goto errout_with_dev; + goto errout; } /* Now loop the appropriate number of times, displaying the collected @@ -357,6 +357,11 @@ int adc_main(int argc, char *argv[]) } } + close(fd); + return OK; + + /* Error exits */ + errout_with_dev: close(fd); diff --git a/apps/examples/buttons/Makefile b/apps/examples/buttons/Makefile index 25d1ef2c2..77c1cd67d 100644 --- a/apps/examples/buttons/Makefile +++ b/apps/examples/buttons/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/buttons/Makefile # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -76,9 +80,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -90,16 +92,17 @@ endif context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/can/Makefile b/apps/examples/can/Makefile index c6dc5af84..8924797e3 100644 --- a/apps/examples/can/Makefile +++ b/apps/examples/can/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/can/Makefile # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -76,9 +80,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -90,16 +92,17 @@ endif context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/cdcacm/Makefile b/apps/examples/cdcacm/Makefile index 3fa886d56..e8d03807d 100644 --- a/apps/examples/cdcacm/Makefile +++ b/apps/examples/cdcacm/Makefile @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -80,9 +84,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -93,17 +95,18 @@ $(COBJS): %$(OBJEXT): %.c context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/hello/Makefile b/apps/examples/hello/Makefile index 1d78d723e..560b0da35 100644 --- a/apps/examples/hello/Makefile +++ b/apps/examples/hello/Makefile @@ -54,10 +54,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -76,9 +80,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -90,16 +92,17 @@ endif context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/helloxx/Makefile b/apps/examples/helloxx/Makefile index 8e85eab23..062da7d58 100644 --- a/apps/examples/helloxx/Makefile +++ b/apps/examples/helloxx/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/helloxx/Makefile # -# Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2009-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -50,10 +50,14 @@ CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) OBJS = $(AOBJS) $(COBJS) $(CXXOBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -69,7 +73,7 @@ STACKSIZE = 2048 VPATH = all: .built -.PHONY: clean depend disclean chkcxx +.PHONY: clean depend distclean chkcxx chkcxx: ifneq ($(CONFIG_HAVE_CXX),y) @@ -93,9 +97,7 @@ $(CXXOBJS): %$(OBJEXT): %.cxx $(call COMPILEXX, $<, $@) .built: chkcxx $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -107,16 +109,17 @@ endif context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/mm/Makefile b/apps/examples/mm/Makefile index 24ed4926f..5ba7f4eec 100644 --- a/apps/examples/mm/Makefile +++ b/apps/examples/mm/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/mm/Makefile # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -70,24 +74,23 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built context: .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/mount/Makefile b/apps/examples/mount/Makefile index 69cf970cf..133bdfa1f 100644 --- a/apps/examples/mount/Makefile +++ b/apps/examples/mount/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/Makefile # -# Copyright (C) 2007-2008, 2010-2010 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2010-2010, 2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -70,24 +74,23 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built context: .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/nsh/Makefile b/apps/examples/nsh/Makefile index bad40fb2e..c7d212fc2 100644 --- a/apps/examples/nsh/Makefile +++ b/apps/examples/nsh/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/nsh/Makefile # -# Copyright (C) 2007-2008, 2010-2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2010-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -70,24 +74,23 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built context: .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/null/Makefile b/apps/examples/null/Makefile index 634120600..47ec4cdaf 100644 --- a/apps/examples/null/Makefile +++ b/apps/examples/null/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/null/Makefile # -# Copyright (C) 2007-2008, 2010-2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2010-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -70,24 +74,23 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built context: .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/ostest/Kconfig b/apps/examples/ostest/Kconfig index 0da7e4ce3..c3fe8f21d 100644 --- a/apps/examples/ostest/Kconfig +++ b/apps/examples/ostest/Kconfig @@ -39,4 +39,31 @@ config EXAMPLES_OSTEST_NBARRIER_THREADS is 8 but a smaller number may be needed on systems without sufficient memory to start so many threads. +config EXAMPLES_OSTEST_RR_RANGE + int "Round-robin test - end of search range" + default 10000 + range 1 32767 + ---help--- + During round-robin scheduling test two threads are created. Each of the threads + searches for prime numbers in the configurable range, doing that configurable + number of times. + + This value specifies the end of search range and together with number of runs + allows to configure the length of this test - it should last at least a few + tens of seconds. Allowed values [1; 32767], default 10000 + +config EXAMPLES_OSTEST_RR_RUNS + int "Round-robin test - number of runs" + default 10 + range 1 32767 + ---help--- + During round-robin scheduling test two threads are created. Each of the threads + searches for prime numbers in the configurable range, doing that configurable + number of times. + + This value specifies the number of times the thread searches the range for + prime numbers and together with end of search range allows to configure the + length of this test - it should last at least a few tens of seconds. Allowed + values [1; 32767], default 10 + endif diff --git a/apps/examples/ostest/Makefile b/apps/examples/ostest/Makefile index 374964b39..3e78c64e8 100644 --- a/apps/examples/ostest/Makefile +++ b/apps/examples/ostest/Makefile @@ -98,10 +98,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -120,9 +124,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -134,16 +136,17 @@ endif context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/ostest/roundrobin.c b/apps/examples/ostest/roundrobin.c index 5167a857e..bfd344df3 100644 --- a/apps/examples/ostest/roundrobin.c +++ b/apps/examples/ostest/roundrobin.c @@ -1,7 +1,7 @@ /******************************************************************************** * examples/ostest/roundrobin.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008, 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ #include <nuttx/config.h> #include <stdio.h> +#include <stdbool.h> #include "ostest.h" #if CONFIG_RR_INTERVAL > 0 @@ -47,115 +48,87 @@ * Definitions ********************************************************************************/ -/* This number may need to be tuned for different processor speeds. Since these - * arrays must be large to very correct SCHED_RR behavior, this test may require - * too much memory on many targets. - */ +/* This numbers should be tuned for different processor speeds via .config file. + * With default values the test takes about 30s on Cortex-M3 @ 24MHz. With 32767 + * range and 10 runs it takes ~320s. */ -/* #define CONFIG_NINTEGERS 32768 Takes forever on 60Mhz ARM7 */ - -#define CONFIG_NINTEGERS 2048 - -/******************************************************************************** - * Private Data - ********************************************************************************/ +#ifndef CONFIG_EXAMPLES_OSTEST_RR_RANGE +# define CONFIG_EXAMPLES_OSTEST_RR_RANGE 10000 +# warning "CONFIG_EXAMPLES_OSTEST_RR_RANGE undefined, using default value = 10000" +#elif (CONFIG_EXAMPLES_OSTEST_RR_RANGE < 1) || (CONFIG_EXAMPLES_OSTEST_RR_RANGE > 32767) +# define CONFIG_EXAMPLES_OSTEST_RR_RANGE 10000 +# warning "Invalid value of CONFIG_EXAMPLES_OSTEST_RR_RANGE, using default value = 10000" +#endif -static int prime1[CONFIG_NINTEGERS]; -static int prime2[CONFIG_NINTEGERS]; +#ifndef CONFIG_EXAMPLES_OSTEST_RR_RUNS +# define CONFIG_EXAMPLES_OSTEST_RR_RUNS 10 +# warning "CONFIG_EXAMPLES_OSTEST_RR_RUNS undefined, using default value = 10" +#elif (CONFIG_EXAMPLES_OSTEST_RR_RUNS < 1) || (CONFIG_EXAMPLES_OSTEST_RR_RUNS > 32767) +# define CONFIG_EXAMPLES_OSTEST_RR_RUNS 10 +# warning "Invalid value of CONFIG_EXAMPLES_OSTEST_RR_RUNS, using default value = 10" +#endif /******************************************************************************** * Private Functions ********************************************************************************/ /******************************************************************************** - * Name: dosieve + * Name: get_primes * * Description - * This implements a "sieve of aristophanes" algorithm for finding prime number. - * Credit for this belongs to someone, but I am not sure who anymore. Anyway, - * the only purpose here is that we need some algorithm that takes a long period - * of time to execute. - * + * This function searches for prime numbers in the most primitive way possible. ********************************************************************************/ -static void dosieve(int *prime) +static void get_primes(int *count, int *last) { - int a,d; - int i; - int j; - - a = 2; - d = a; - - for (i = 0; i < CONFIG_NINTEGERS; i++) - { - prime[i] = i+2; - } - - for (i = 1; i < 10; i++) + int number; + int local_count = 0; + *last = 0; // to make compiler happy + + for (number = 1; number < CONFIG_EXAMPLES_OSTEST_RR_RANGE; number++) + { + int div; + bool is_prime = true; + + for (div = 2; div <= number / 2; div++) + if (number % div == 0) + { + is_prime = false; + break; + } + + if (is_prime) { - for (j = 0; j < CONFIG_NINTEGERS; j++) - { - d = a + d; - if (d < CONFIG_NINTEGERS) - { - prime[d]=0; - } - } - a++; - d = a; - i++; - } - + local_count++; + *last = number; #if 0 /* We don't really care what the numbers are */ - for (i = 0, j= 0; i < CONFIG_NINTEGERS; i++) - { - if (prime[i] != 0) - { - printf(" Prime %d: %d\n", j, prime[i]); - j++; - } - } + printf(" Prime %d: %d\n", local_count, number); #endif -} - -/******************************************************************************** - * Name: sieve1 - ********************************************************************************/ - -static void *sieve1(void *parameter) -{ - int i; - - printf("sieve1 started\n"); - - for (i = 0; i < 1000; i++) - { - dosieve(prime1); } + } - printf("sieve1 finished\n"); - - pthread_exit(NULL); - return NULL; /* To keep some compilers happy */ + *count = local_count; } /******************************************************************************** - * Name: sieve2 + * Name: get_primes_thread ********************************************************************************/ -static void *sieve2(void *parameter) +static void *get_primes_thread(void *parameter) { - int i; + int id = (int)parameter; + int i, count, last; - printf("sieve2 started\n"); + printf("get_primes_thread id=%d started, looking for primes < %d, doing %d run(s)\n", + id, CONFIG_EXAMPLES_OSTEST_RR_RANGE, CONFIG_EXAMPLES_OSTEST_RR_RUNS); - for (i = 0; i < 1000; i++) + for (i = 0; i < CONFIG_EXAMPLES_OSTEST_RR_RUNS; i++) { - dosieve(prime2); + get_primes(&count, &last); } - printf("sieve2 finished\n"); + printf("get_primes_thread id=%d finished, found %d primes, last one was %d\n", + id, count, last); pthread_exit(NULL); return NULL; /* To keep some compilers happy */ @@ -171,14 +144,13 @@ static void *sieve2(void *parameter) void rr_test(void) { - pthread_t sieve1_thread; - pthread_t sieve2_thread; + pthread_t get_primes1_thread; + pthread_t get_primes2_thread; struct sched_param sparam; pthread_attr_t attr; pthread_addr_t result; int status; - printf("rr_test: Starting sieve1 thread \n"); status = pthread_attr_init(&attr); if (status != OK) { @@ -203,29 +175,31 @@ void rr_test(void) } else { - printf("rr_test: Set thread policty to SCHED_RR\n"); + printf("rr_test: Set thread policy to SCHED_RR\n"); } - status = pthread_create(&sieve1_thread, &attr, sieve1, NULL); + printf("rr_test: Starting first get_primes_thread\n"); + + status = pthread_create(&get_primes1_thread, &attr, get_primes_thread, (void*)1); if (status != 0) { printf("rr_test: Error in thread 1 creation, status=%d\n", status); } - printf("rr_test: Starting sieve1 thread \n"); + printf("rr_test: Starting second get_primes_thread\n"); - status = pthread_create(&sieve2_thread, &attr, sieve2, NULL); + status = pthread_create(&get_primes2_thread, &attr, get_primes_thread, (void*)2); if (status != 0) { printf("rr_test: Error in thread 2 creation, status=%d\n", status); } - printf("rr_test: Waiting for sieves to complete -- this should take awhile\n"); + printf("rr_test: Waiting for threads to complete -- this should take awhile\n"); printf("rr_test: If RR scheduling is working, they should start and complete at\n"); printf("rr_test: about the same time\n"); - pthread_join(sieve2_thread, &result); - pthread_join(sieve1_thread, &result); + pthread_join(get_primes2_thread, &result); + pthread_join(get_primes1_thread, &result); printf("rr_test: Done\n"); } diff --git a/apps/examples/pipe/Makefile b/apps/examples/pipe/Makefile index 956c911b3..bed319085 100644 --- a/apps/examples/pipe/Makefile +++ b/apps/examples/pipe/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/pipe/Makefile # -# Copyright (C) 2008, 2010-2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -70,24 +74,23 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built context: .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/poll/Makefile b/apps/examples/poll/Makefile index aef61d199..13173f125 100644 --- a/apps/examples/poll/Makefile +++ b/apps/examples/poll/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/poll/Makefile # -# Copyright (C) 2008, 2010-2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -70,25 +74,25 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built context: .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ # Register application depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend host + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + $(call DELFILE, host$(HOSTEXEEXT)) -include Make.dep diff --git a/apps/examples/pwm/Makefile b/apps/examples/pwm/Makefile index efbdb048e..3a6f2520a 100644 --- a/apps/examples/pwm/Makefile +++ b/apps/examples/pwm/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/pwm/Makefile # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -76,9 +80,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -88,16 +90,17 @@ $(COBJS): %$(OBJEXT): %.c context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/pwm/pwm_main.c b/apps/examples/pwm/pwm_main.c index 775bdba6b..a46c10f55 100644 --- a/apps/examples/pwm/pwm_main.c +++ b/apps/examples/pwm/pwm_main.c @@ -48,6 +48,7 @@ #include <fcntl.h> #include <errno.h> #include <debug.h> +#include <string.h> #include <nuttx/pwm.h> diff --git a/apps/examples/qencoder/Makefile b/apps/examples/qencoder/Makefile index 3f3fc9def..7d2427c6b 100644 --- a/apps/examples/qencoder/Makefile +++ b/apps/examples/qencoder/Makefile @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -76,9 +80,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -90,16 +92,17 @@ endif context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/romfs/Makefile b/apps/examples/romfs/Makefile index ba930b77d..2b02952ed 100644 --- a/apps/examples/romfs/Makefile +++ b/apps/examples/romfs/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/romfs/Makefile # -# Copyright (C) 2008, 2010-2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -61,7 +65,7 @@ ROOTDEPPATH = --dep-path . VPATH = all: .built -.PHONY: checkgenromfs clean depend disclean +.PHONY: checkgenromfs clean depend distclean $(AOBJS): %$(OBJEXT): %.S $(call ASSEMBLE, $<, $@) @@ -86,26 +90,26 @@ romfs_testdir.h : testdir.img @xxd -i $< >$@ || { echo "xxd of $< failed" ; exit 1 ; } .built: romfs_testdir.h $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built context: .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ # Register application depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend testdir.img + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + $(call DELFILE, testdir.img) -include Make.dep diff --git a/apps/examples/serloop/Makefile b/apps/examples/serloop/Makefile index e1c415cdd..4a262884b 100644 --- a/apps/examples/serloop/Makefile +++ b/apps/examples/serloop/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/serloop/Makefile # -# Copyright (C) 2008, 2010-2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -70,26 +74,25 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built context: .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ # Register application depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep diff --git a/apps/examples/watchdog/Makefile b/apps/examples/watchdog/Makefile index d2739dbb0..9890959fb 100644 --- a/apps/examples/watchdog/Makefile +++ b/apps/examples/watchdog/Makefile @@ -48,10 +48,14 @@ COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) OBJS = $(AOBJS) $(COBJS) +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" + BIN = ..\\..\\libapps$(LIBEXT) else - BIN = "$(APPDIR)/libapps$(LIBEXT)" + BIN = ../../libapps$(LIBEXT) +endif endif ROOTDEPPATH = --dep-path . @@ -76,9 +80,7 @@ $(COBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) .built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) + $(call ARCHIVE, $(BIN), $(OBJS)) @touch .built .context: @@ -88,16 +90,17 @@ $(COBJS): %$(OBJEXT): %.c context: .context .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ depend: .depend clean: - @rm -f *.o *~ .*.swp .built + $(call DELFILE, .built) $(call CLEAN) distclean: clean - @rm -f Make.dep .depend + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) -include Make.dep |