diff --git a/Application.mk b/Application.mk index cd9d247c2..5b7a4e5ad 100644 --- a/Application.mk +++ b/Application.mk @@ -90,13 +90,13 @@ endif .built: $(OBJS) $(call ARCHIVE, $(BIN), $(OBJS)) - $(Q) touch .built + $(Q) touch $@ ifeq ($(CONFIG_BUILD_KERNEL),y) $(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ) @echo "LD: $(PROGNAME)" $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS) - $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) install: $(BIN_DIR)$(DELIM)$(PROGNAME) else diff --git a/ChangeLog.txt b/ChangeLog.txt index b17e2577b..cf8d02332 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1583,4 +1583,19 @@ of the RTC driver (2016-04-03). * apps/examples/nximage: No configuration option to select greyscale. - + * apps/canutils/uavcan: Update UAVCAN version. From Paul Alexander + Patience (2016-05-03) + * Several Makefiles: Add .PHONY definitions to prevent 'clean up to date' + message weirdness; Add default definitions for some commonly used + things when 'make clean' is used without .config or Make.defs files + installed (2016-05-10). + * apps/canutils/libcanard: Add libcanard UAVCAN library. From Paul + Alexander Patience (2016-05-12) + * apps/examples/watchdog: Remove call to up_wdginitialize(). This + interface should not be accessed from application code (2016-05-18). + * apps/system/sched_note: Move the schduler note monitor from examples/ + to system/ (2016-05-18). + * apps/platform/nucleo-144: Add platform files for NUCLEO-144 + (NUCLEO-F746ZG). From Mark Olsson (2016-05-19). + * apps/netutils/esp8266: ESP8266 driver application. From Pierre-noel + Bouteville (2016-05-21). diff --git a/canutils/Kconfig b/canutils/Kconfig index 59830cba2..5fe2e45ce 100644 --- a/canutils/Kconfig +++ b/canutils/Kconfig @@ -5,6 +5,7 @@ menu "CAN Utilities" -source "$APPSDIR/canutils/uavcan/Kconfig" +source "$APPSDIR/canutils/libcanard/Kconfig" +source "$APPSDIR/canutils/libuavcan/Kconfig" endmenu # CAN Utilities diff --git a/canutils/libcanard/.gitignore b/canutils/libcanard/.gitignore new file mode 100644 index 000000000..5ca33bd27 --- /dev/null +++ b/canutils/libcanard/.gitignore @@ -0,0 +1,2 @@ +/.built +/libcanard-* diff --git a/canutils/libcanard/Kconfig b/canutils/libcanard/Kconfig new file mode 100644 index 000000000..e4635cb63 --- /dev/null +++ b/canutils/libcanard/Kconfig @@ -0,0 +1,27 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config CANUTILS_LIBCANARD + bool "libcanard UAVCAN Library" + default n + depends on CAN && CAN_EXTID + ---help--- + Enable the libcanard UAVCAN library. + +if CANUTILS_LIBCANARD + +config LIBCANARD_URL + string "libcanard URL" + default "https://github.com/UAVCAN/libcanard/archive" + ---help--- + libcanard URL. + +config LIBCANARD_VERSION + string "libcanard Version" + default "34195e7f13637bdc79198c94bd1b2e5ecffe9383" + ---help--- + libcanard version. + +endif diff --git a/examples/sched_note/Make.defs b/canutils/libcanard/Make.defs similarity index 87% rename from examples/sched_note/Make.defs rename to canutils/libcanard/Make.defs index ba503e473..22cd3e077 100644 --- a/examples/sched_note/Make.defs +++ b/canutils/libcanard/Make.defs @@ -1,9 +1,9 @@ ############################################################################ -# apps/examples/note/Make.defs +# apps/canutils/libcanard/Make.defs # Adds selected applications to apps/ build # -# Copyright (C) 2016 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved. +# Author: Paul Alexander Patience # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -34,6 +34,6 @@ # ############################################################################ -ifeq ($(CONFIG_EXAMPLES_NOTE),y) -CONFIGURED_APPS += examples/sched_note +ifeq ($(CONFIG_CANUTILS_LIBCANARD),y) +CONFIGURED_APPS += canutils/libcanard endif diff --git a/canutils/libcanard/Makefile b/canutils/libcanard/Makefile new file mode 100644 index 000000000..79c2bb853 --- /dev/null +++ b/canutils/libcanard/Makefile @@ -0,0 +1,111 @@ +############################################################################ +# apps/canutils/libcanard/Makefile +# +# Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved. +# Authors: Paul Alexander Patience +# +# 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)/Make.defs +include $(APPDIR)/Make.defs + +WGET = wget +UNPACK = unzip +PACKEXT = .zip + +LIBCANARD_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARD_URL))) +LIBCANARD_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARD_VERSION))) +LIBCANARD_UNPACKNAME = libcanard-$(LIBCANARD_VERSION) +LIBCANARD_PACKNAME = $(LIBCANARD_UNPACKNAME)$(PACKEXT) +LIBCANARD_SRCDIR = $(LIBCANARD_UNPACKNAME)$(DELIM)src + +CSRCS = $(LIBCANARD_SRCDIR)$(DELIM)canard.c +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(CSRCS) +OBJS = $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)$(DELIM)libapps$(LIBEXT)}" +else + BIN = $(APPDIR)$(DELIM)libapps$(LIBEXT) +endif + +ROOTDEPPATH = --dep-path . + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(LIBCANARD_PACKNAME): + @echo "Downloading: $@" + $(Q) $(WGET) -O $@ $(LIBCANARD_URL)$(DELIM)$(LIBCANARD_VERSION)$(PACKEXT) + +$(LIBCANARD_UNPACKNAME): $(LIBCANARD_PACKNAME) + @echo "Unpacking: $< -> $@" + $(Q) $(UNPACK) $< + $(Q) touch $@ + +$(LIBCANARD_SRCDIR)$(DELIM)canard.h: $(LIBCANARD_UNPACKNAME) + +$(APPDIR)$(DELIM)include$(DELIM)canutils$(DELIM)canard.h: $(LIBCANARD_SRCDIR)$(DELIM)canard.h + $(Q) cp $< $@ + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + $(Q) touch $@ + +install: + +context: $(APPDIR)$(DELIM)include$(DELIM)canutils$(DELIM)canard.h + +.depend: Makefile $(SRCS) + $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + $(foreach OBJ, $(OBJS), $(call DELFILE, $(OBJ))) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + $(call DELFILE, $(APPDIR)$(DELIM)include$(DELIM)canutils$(DELIM)canard.h) + $(call DELDIR, $(LIBCANARD_UNPACKNAME)) + $(call DELFILE, $(LIBCANARD_PACKNAME)) + +-include Make.dep diff --git a/canutils/uavcan/.gitignore b/canutils/libuavcan/.gitignore similarity index 100% rename from canutils/uavcan/.gitignore rename to canutils/libuavcan/.gitignore diff --git a/canutils/uavcan/Kconfig b/canutils/libuavcan/Kconfig similarity index 68% rename from canutils/uavcan/Kconfig rename to canutils/libuavcan/Kconfig index 0985ba88d..64d7157dd 100644 --- a/canutils/uavcan/Kconfig +++ b/canutils/libuavcan/Kconfig @@ -3,8 +3,8 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -config CANUTILS_UAVCAN - bool "UAVCAN Library" +config CANUTILS_LIBUAVCAN + bool "libuavcan Library" default n depends on STM32_HAVE_CAN1 depends on !STM32_CAN1 @@ -14,47 +14,47 @@ config CANUTILS_UAVCAN depends on HAVE_CXX depends on !DISABLE_POLL ---help--- - Enables support for the UAVCAN library. + Enables support for the libuavcan library. -if CANUTILS_UAVCAN +if CANUTILS_LIBUAVCAN -config UAVCAN_LIBUAVCAN_URL - string "UAVCAN URL" +config LIBUAVCAN_URL + string "libuavcan URL" default "https://github.com/UAVCAN/libuavcan/archive" ---help--- - UAVCAN URL. + libuavcan URL. -config UAVCAN_LIBUAVCAN_VERSION - string "UAVCAN Version" - default "c152f28a620ceec9f63581a7c99fe77c89938048" +config LIBUAVCAN_VERSION + string "libuavcan Version" + default "b04396ace50155573e545ed9bf2fb09964ee2367" ---help--- - UAVCAN version. + libuavcan version. -config UAVCAN_DSDL_URL +config LIBUAVCAN_DSDL_URL string "DSDL URL" default "https://github.com/UAVCAN/dsdl/archive" ---help--- DSDL URL. -config UAVCAN_DSDL_VERSION +config LIBUAVCAN_DSDL_VERSION string "DSDL Version" default "9804a3e6972825586be252ce08dd899f44994b14" ---help--- DSDL version. -config UAVCAN_PYUAVCAN_URL - string "Python UAVCAN URL" +config LIBUAVCAN_PYUAVCAN_URL + string "pyuavcan URL" default "https://github.com/UAVCAN/pyuavcan/archive" ---help--- - Python UAVCAN URL. + pyuavcan URL. -config UAVCAN_PYUAVCAN_VERSION - string "Python UAVCAN Version" +config LIBUAVCAN_PYUAVCAN_VERSION + string "pyuavcan Version" default "c58477a644d20ccf95a20c151f3a0402f271c3b8" ---help--- - Python UAVCAN version. + pyuavcan version. -config UAVCAN_STM32_NUM_IFACES +config LIBUAVCAN_STM32_NUM_IFACES int "Number of CAN Interfaces" default 1 range 1 1 if !STM32_HAVE_CAN2 @@ -62,44 +62,44 @@ config UAVCAN_STM32_NUM_IFACES choice prompt "Timer" - default UAVCAN_STM32_TIM2 if !STM32_TIM2 - default UAVCAN_STM32_TIM3 if STM32_HAVE_TIM3 && !STM32_TIM3 - default UAVCAN_STM32_TIM4 if STM32_HAVE_TIM4 && !STM32_TIM4 - default UAVCAN_STM32_TIM5 if STM32_HAVE_TIM5 && !STM32_TIM5 - default UAVCAN_STM32_TIM6 if STM32_HAVE_TIM6 && !STM32_TIM6 - default UAVCAN_STM32_TIM7 if STM32_HAVE_TIM7 && !STM32_TIM7 + default LIBUAVCAN_STM32_TIM2 if !STM32_TIM2 + default LIBUAVCAN_STM32_TIM3 if STM32_HAVE_TIM3 && !STM32_TIM3 + default LIBUAVCAN_STM32_TIM4 if STM32_HAVE_TIM4 && !STM32_TIM4 + default LIBUAVCAN_STM32_TIM5 if STM32_HAVE_TIM5 && !STM32_TIM5 + default LIBUAVCAN_STM32_TIM6 if STM32_HAVE_TIM6 && !STM32_TIM6 + default LIBUAVCAN_STM32_TIM7 if STM32_HAVE_TIM7 && !STM32_TIM7 -config UAVCAN_STM32_TIM2 +config LIBUAVCAN_STM32_TIM2 bool "TIM2" depends on !STM32_TIM2 ---help--- The library will use TIM2. -config UAVCAN_STM32_TIM3 +config LIBUAVCAN_STM32_TIM3 bool "TIM3" depends on STM32_HAVE_TIM3 && !STM32_TIM3 ---help--- The library will use TIM3. -config UAVCAN_STM32_TIM4 +config LIBUAVCAN_STM32_TIM4 bool "TIM4" depends on STM32_HAVE_TIM4 && !STM32_TIM4 ---help--- The library will use TIM4. -config UAVCAN_STM32_TIM5 +config LIBUAVCAN_STM32_TIM5 bool "TIM5" depends on STM32_HAVE_TIM5 && !STM32_TIM5 ---help--- The library will use TIM5. -config UAVCAN_STM32_TIM6 +config LIBUAVCAN_STM32_TIM6 bool "TIM6" depends on STM32_HAVE_TIM6 && !STM32_TIM6 ---help--- The library will use TIM6. -config UAVCAN_STM32_TIM7 +config LIBUAVCAN_STM32_TIM7 bool "TIM7" depends on STM32_HAVE_TIM7 && !STM32_TIM7 ---help--- @@ -109,111 +109,111 @@ endchoice choice prompt "C++ Version" - default UAVCAN_CPP03 + default LIBUAVCAN_CPP03 -config UAVCAN_CPP03 +config LIBUAVCAN_CPP03 bool "C++03" ---help--- The library will use C++03. -config UAVCAN_CPP11 +config LIBUAVCAN_CPP11 bool "C++11" ---help--- The library will use C++11. endchoice -config UAVCAN_DEBUG +config LIBUAVCAN_DEBUG bool "Debug" default n ---help--- Enables debug. -config UAVCAN_EXCEPTIONS +config LIBUAVCAN_EXCEPTIONS bool "Exceptions" default n ---help--- Enables exceptions. -config UAVCAN_TINY +config LIBUAVCAN_TINY bool "Tiny" default n ---help--- Removes some features to save memory. -config UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY +config LIBUAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY bool "No Global Data Type Registry" default n ---help--- Removes the global data type registry. -config UAVCAN_TOSTRING +config LIBUAVCAN_TOSTRING bool "Implement toString" default n - depends on UAVCAN_EXCEPTIONS + depends on LIBUAVCAN_EXCEPTIONS ---help--- The library will add a toString method to most of its classes. -config UAVCAN_IMPLEMENT_PLACEMENT_NEW +config LIBUAVCAN_IMPLEMENT_PLACEMENT_NEW bool "Implement Placement new" default n ---help--- The library will implement placement new. -config UAVCAN_USE_EXTERNAL_SNPRINTF +config LIBUAVCAN_USE_EXTERNAL_SNPRINTF bool "Use External snprintf" default n ---help--- The library will use an external snprintf. -config UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION +config LIBUAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION bool "Use External float16 Conversion" default n ---help--- The library will use an external float16 conversion. -config UAVCAN_NO_ASSERTIONS +config LIBUAVCAN_NO_ASSERTIONS bool "No Assertions" default n ---help--- Disables assertions. -config UAVCAN_MEM_POOL_BLOCK_SIZE +config LIBUAVCAN_MEM_POOL_BLOCK_SIZE int "Memory Pool Block Size" default 0 ---help--- Specifies the memory pool block size. If the value is 0, the library will use a default value. -config UAVCAN_FLOAT_COMPARISON_EPSILON_MULT +config LIBUAVCAN_FLOAT_COMPARISON_EPSILON_MULT int "Float Comparion Epsilon Mult" default 0 ---help--- Specifies the float comparison epsilon mult. If the value is 0, the library will use a default value. -config UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS +config LIBUAVCAN_MAX_CAN_ACCEPTANCE_FILTERS int "Max CAN Acceptance Filters" default 0 ---help--- Specifies the maximum number of CAN acceptance filters. If the value is 0, the library will use a default value. -config UAVCAN_MAX_NETWORK_SIZE_HINT +config LIBUAVCAN_MAX_NETWORK_SIZE_HINT int "Max Network Size Hint" default 0 ---help--- Specifies the maximum network size. If the value is 0, the library will use a default value. -config UAVCAN_RX_QUEUE_CAPACITY +config LIBUAVCAN_RX_QUEUE_CAPACITY int "Rx Queue Capacity" default 0 ---help--- Specifies the rx queue capacity. If the value is 0, the library will use a default value. -config UAVCAN_BIT_RATE +config LIBUAVCAN_BIT_RATE int "Bit Rate" default 0 range 0 1000000 @@ -221,7 +221,7 @@ config UAVCAN_BIT_RATE Specifies the CAN bit rate. If the value is 0, the library will automatically detect the bit rate. -config UAVCAN_INIT_RETRIES +config LIBUAVCAN_INIT_RETRIES int "Initialization Retries" default 0 ---help--- diff --git a/canutils/uavcan/Make.defs b/canutils/libuavcan/Make.defs similarity index 90% rename from canutils/uavcan/Make.defs rename to canutils/libuavcan/Make.defs index fa3c9c602..de45b2130 100644 --- a/canutils/uavcan/Make.defs +++ b/canutils/libuavcan/Make.defs @@ -1,7 +1,7 @@ ############################################################################ -# apps/canutils/uavcan/Make.defs +# apps/canutils/libuavcan/Make.defs # -# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. +# Copyright (C) 2015-2016 Omni Hoverboards Inc. All rights reserved. # Author: Paul Alexander Patience # # Redistribution and use in source and binary forms, with or without @@ -33,6 +33,6 @@ # ############################################################################ -ifeq ($(CONFIG_CANUTILS_UAVCAN),y) -CONFIGURED_APPS += canutils/uavcan +ifeq ($(CONFIG_CANUTILS_LIBUAVCAN),y) +CONFIGURED_APPS += canutils/libuavcan endif diff --git a/canutils/uavcan/Makefile b/canutils/libuavcan/Makefile similarity index 68% rename from canutils/uavcan/Makefile rename to canutils/libuavcan/Makefile index 9ad5f4216..05fc45f61 100644 --- a/canutils/uavcan/Makefile +++ b/canutils/libuavcan/Makefile @@ -1,7 +1,7 @@ ############################################################################ -# apps/canutils/uavcan/Makefile +# apps/canutils/libuavcan/Makefile # -# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. +# Copyright (C) 2015-2016 Omni Hoverboards Inc. All rights reserved. # Author: Paul Alexander Patience # # Redistribution and use in source and binary forms, with or without @@ -41,21 +41,21 @@ WGET = wget UNPACK = unzip PACKEXT = .zip -LIBUAVCAN_URL = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_LIBUAVCAN_URL))) -LIBUAVCAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_LIBUAVCAN_VERSION))) +LIBUAVCAN_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBUAVCAN_URL))) +LIBUAVCAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBUAVCAN_VERSION))) LIBUAVCAN_UNPACKNAME = libuavcan-$(LIBUAVCAN_VERSION) LIBUAVCAN_PACKNAME = $(LIBUAVCAN_UNPACKNAME)$(PACKEXT) LIBUAVCAN_DSDL_PATH = libuavcan$(DELIM)dsdl LIBUAVCAN_PYUAVCAN_PATH = libuavcan$(DELIM)libuavcan$(DELIM)dsdl_compiler$(DELIM)pyuavcan LIBUAVCAN_PATCHNAME = nuttx-$(LIBUAVCAN_VERSION).patch -DSDL_URL = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_DSDL_URL))) -DSDL_VERSION = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_DSDL_VERSION))) +DSDL_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBUAVCAN_DSDL_URL))) +DSDL_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBUAVCAN_DSDL_VERSION))) DSDL_UNPACKNAME = dsdl-$(DSDL_VERSION) DSDL_PACKNAME = $(DSDL_UNPACKNAME)$(PACKEXT) -PYUAVCAN_URL = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_PYUAVCAN_URL))) -PYUAVCAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_PYUAVCAN_VERSION))) +PYUAVCAN_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBUAVCAN_PYUAVCAN_URL))) +PYUAVCAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBUAVCAN_PYUAVCAN_VERSION))) PYUAVCAN_UNPACKNAME = pyuavcan-$(PYUAVCAN_VERSION) PYUAVCAN_PACKNAME = $(PYUAVCAN_UNPACKNAME)$(PACKEXT) @@ -70,24 +70,24 @@ CXXFLAGS += -I$(TOPDIR)$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)stm32 CXXFLAGS += -D__KERNEL__ CXXFLAGS += -DUAVCAN_STM32_NUTTX=1 -CXXFLAGS += -DUAVCAN_STM32_NUM_IFACES=$(CONFIG_UAVCAN_STM32_NUM_IFACES) +CXXFLAGS += -DUAVCAN_STM32_NUM_IFACES=$(CONFIG_LIBUAVCAN_STM32_NUM_IFACES) -ifeq ($(CONFIG_UAVCAN_STM32_TIM2),y) +ifeq ($(CONFIG_LIBUAVCAN_STM32_TIM2),y) CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=2 else -ifeq ($(CONFIG_UAVCAN_STM32_TIM3),y) +ifeq ($(CONFIG_LIBUAVCAN_STM32_TIM3),y) CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=3 else -ifeq ($(CONFIG_UAVCAN_STM32_TIM4),y) +ifeq ($(CONFIG_LIBUAVCAN_STM32_TIM4),y) CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=4 else -ifeq ($(CONFIG_UAVCAN_STM32_TIM5),y) +ifeq ($(CONFIG_LIBUAVCAN_STM32_TIM5),y) CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=5 else -ifeq ($(CONFIG_UAVCAN_STM32_TIM6),y) +ifeq ($(CONFIG_LIBUAVCAN_STM32_TIM6),y) CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=6 else -ifeq ($(CONFIG_UAVCAN_STM32_TIM7),y) +ifeq ($(CONFIG_LIBUAVCAN_STM32_TIM7),y) CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=7 endif endif @@ -96,68 +96,68 @@ endif endif endif -ifeq ($(CONFIG_UAVCAN_CPP03),y) +ifeq ($(CONFIG_LIBUAVCAN_CPP03),y) CXXFLAGS += -std=c++03 -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 else -ifeq ($(CONFIG_UAVCAN_CPP11),y) +ifeq ($(CONFIG_LIBUAVCAN_CPP11),y) CXXFLAGS += -std=c++11 -DUAVCAN_CPP_VERSION=UAVCAN_CPP11 endif endif -ifeq ($(CONFIG_UAVCAN_DEBUG),y) +ifeq ($(CONFIG_LIBUAVCAN_DEBUG),y) CXXFLAGS += -DUAVCAN_DEBUG=1 endif -ifeq ($(CONFIG_UAVCAN_EXCEPTIONS),y) +ifeq ($(CONFIG_LIBUAVCAN_EXCEPTIONS),y) CXXFLAGS += -DUAVCAN_EXCEPTIONS=1 else CXXFLAGS += -DUAVCAN_EXCEPTIONS=0 endif -ifeq ($(CONFIG_UAVCAN_TINY),y) +ifeq ($(CONFIG_LIBUAVCAN_TINY),y) CXXFLAGS += -DUAVCAN_TINY=1 endif -ifeq ($(CONFIG_UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY),y) +ifeq ($(CONFIG_LIBUAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY),y) CXXFLAGS += -DUAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY=1 endif -ifeq ($(CONFIG_UAVCAN_TOSTRING),y) +ifeq ($(CONFIG_LIBUAVCAN_TOSTRING),y) CXXFLAGS += -DUAVCAN_TOSTRING=1 else CXXFLAGS += -DUAVCAN_TOSTRING=0 endif -ifeq ($(CONFIG_UAVCAN_IMPLEMENT_PLACEMENT_NEW),y) +ifeq ($(CONFIG_LIBUAVCAN_IMPLEMENT_PLACEMENT_NEW),y) CXXFLAGS += -DUAVCAN_IMPLEMENT_PLACEMENT_NEW=1 endif -ifeq ($(CONFIG_UAVCAN_USE_EXTERNAL_SNPRINTF),y) +ifeq ($(CONFIG_LIBUAVCAN_USE_EXTERNAL_SNPRINTF),y) CXXFLAGS += -DUAVCAN_USE_EXTERNAL_SNPRINTF=1 endif -ifeq ($(CONFIG_UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION),y) +ifeq ($(CONFIG_LIBUAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION),y) CXXFLAGS += -DUAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION=1 endif -ifeq ($(CONFIG_UAVCAN_NO_ASSERTIONS),y) +ifeq ($(CONFIG_LIBUAVCAN_NO_ASSERTIONS),y) CXXFLAGS += -DUAVCAN_NO_ASSERTIONS=1 endif -ifneq ($(CONFIG_UAVCAN_MEM_POOL_BLOCK_SIZE),0) -CXXFLAGS += -DUAVCAN_MEM_POOL_BLOCK_SIZE=$(CONFIG_UAVCAN_MEM_POOL_BLOCK_SIZE) +ifneq ($(CONFIG_LIBUAVCAN_MEM_POOL_BLOCK_SIZE),0) +CXXFLAGS += -DUAVCAN_MEM_POOL_BLOCK_SIZE=$(CONFIG_LIBUAVCAN_MEM_POOL_BLOCK_SIZE) endif -ifneq ($(CONFIG_UAVCAN_FLOAT_COMPARISON_EPSILON_MULT),0) -CXXFLAGS += -DUAVCAN_FLOAT_COMPARISON_EPSILON_MULT=$(CONFIG_UAVCAN_FLOAT_COMPARISON_EPSILON_MULT) +ifneq ($(CONFIG_LIBUAVCAN_FLOAT_COMPARISON_EPSILON_MULT),0) +CXXFLAGS += -DUAVCAN_FLOAT_COMPARISON_EPSILON_MULT=$(CONFIG_LIBUAVCAN_FLOAT_COMPARISON_EPSILON_MULT) endif -ifneq ($(CONFIG_UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS),0) -CXXFLAGS += -DUAVCAN_MAX_CAN_ACCEPTANCE_FILTERS=$(CONFIG_UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS) +ifneq ($(CONFIG_LIBUAVCAN_MAX_CAN_ACCEPTANCE_FILTERS),0) +CXXFLAGS += -DUAVCAN_MAX_CAN_ACCEPTANCE_FILTERS=$(CONFIG_LIBUAVCAN_MAX_CAN_ACCEPTANCE_FILTERS) endif -ifneq ($(CONFIG_UAVCAN_MAX_NETWORK_SIZE_HINT),0) -CXXFLAGS += -DUAVCAN_MAX_NETWORK_SIZE_HINT=$(CONFIG_UAVCAN_MAX_NETWORK_SIZE_HINT) +ifneq ($(CONFIG_LIBUAVCAN_MAX_NETWORK_SIZE_HINT),0) +CXXFLAGS += -DUAVCAN_MAX_NETWORK_SIZE_HINT=$(CONFIG_LIBUAVCAN_MAX_NETWORK_SIZE_HINT) endif CXXEXT = .cpp @@ -177,34 +177,38 @@ all: .built .PHONY: clean depend distclean $(LIBUAVCAN_PACKNAME): - @echo "Downloading: $(LIBUAVCAN_PACKNAME)" - $(Q) $(WGET) -O $(LIBUAVCAN_PACKNAME) $(LIBUAVCAN_URL)$(DELIM)$(LIBUAVCAN_VERSION)$(PACKEXT) + @echo "Downloading: $@" + $(Q) $(WGET) -O $@ $(LIBUAVCAN_URL)$(DELIM)$(LIBUAVCAN_VERSION)$(PACKEXT) $(LIBUAVCAN_UNPACKNAME): $(LIBUAVCAN_PACKNAME) - @echo "Unpacking: $(LIBUAVCAN_PACKNAME) -> $(LIBUAVCAN_UNPACKNAME)" - $(Q) $(UNPACK) $(LIBUAVCAN_PACKNAME) - $(Q) touch $(LIBUAVCAN_UNPACKNAME) + @echo "Unpacking: $< -> $@" + $(call DELDIR, $@) + $(Q) $(UNPACK) $< + $(Q) touch $@ $(DSDL_PACKNAME): - @echo "Downloading: $(DSDL_PACKNAME)" - $(Q) $(WGET) -O $(DSDL_PACKNAME) $(DSDL_URL)$(DELIM)$(DSDL_VERSION)$(PACKEXT) + @echo "Downloading: $@" + $(Q) $(WGET) -O $@ $(DSDL_URL)$(DELIM)$(DSDL_VERSION)$(PACKEXT) $(DSDL_UNPACKNAME): $(DSDL_PACKNAME) - @echo "Unpacking: $(DSDL_PACKNAME) -> $(DSDL_UNPACKNAME)" - $(Q) $(UNPACK) $(DSDL_PACKNAME) - $(Q) touch $(DSDL_UNPACKNAME) + @echo "Unpacking: $< -> $@" + $(call DELDIR, $@) + $(Q) $(UNPACK) $< + $(Q) touch $@ $(PYUAVCAN_PACKNAME): - @echo "Downloading: $(PYUAVCAN_PACKNAME)" - $(Q) $(WGET) -O $(PYUAVCAN_PACKNAME) $(PYUAVCAN_URL)$(DELIM)$(PYUAVCAN_VERSION)$(PACKEXT) + @echo "Downloading: $@" + $(Q) $(WGET) -O $@ $(PYUAVCAN_URL)$(DELIM)$(PYUAVCAN_VERSION)$(PACKEXT) $(PYUAVCAN_UNPACKNAME): $(PYUAVCAN_PACKNAME) - @echo "Unpacking: $(PYUAVCAN_PACKNAME) -> $(PYUAVCAN_UNPACKNAME)" - $(Q) $(UNPACK) $(PYUAVCAN_PACKNAME) - $(Q) touch $(PYUAVCAN_UNPACKNAME) + @echo "Unpacking: $< -> $@" + $(call DELDIR, $@) + $(Q) $(UNPACK) $< + $(Q) touch $@ libuavcan: $(LIBUAVCAN_UNPACKNAME) $(DSDL_UNPACKNAME) $(PYUAVCAN_UNPACKNAME) - $(Q) cp -R $(LIBUAVCAN_UNPACKNAME) libuavcan + $(call DELDIR, $@) + $(Q) cp -R $(LIBUAVCAN_UNPACKNAME) $@ $(Q) if [ -r $(LIBUAVCAN_PATCHNAME) ]; then \ cat $(LIBUAVCAN_PATCHNAME) | patch -p0 || { echo "ERROR: Patch failed"; exit 1; }; \ fi @@ -212,6 +216,7 @@ libuavcan: $(LIBUAVCAN_UNPACKNAME) $(DSDL_UNPACKNAME) $(PYUAVCAN_UNPACKNAME) $(Q) cp -R $(DSDL_UNPACKNAME) $(LIBUAVCAN_DSDL_PATH) $(call DELDIR, $(LIBUAVCAN_PYUAVCAN_PATH)) $(Q) cp -R $(PYUAVCAN_UNPACKNAME) $(LIBUAVCAN_PYUAVCAN_PATH) + $(Q) touch $@ dsdlc_generated: libuavcan $(info $(shell $(LIBUAVCAN_DSDLC) $(UAVCAN_DSDL_DIR))) @@ -226,7 +231,7 @@ $(CXXOBJS): %$(OBJEXT): %$(CXXEXT) .built: $(CXXOBJS) $(call ARCHIVE, $(BIN), $(CXXOBJS)) - $(Q) touch .built + $(Q) touch $@ install: @@ -248,7 +253,7 @@ clean: distclean: clean $(call DELFILE, Make.dep) $(call DELFILE, .depend) - $(call DEFLFILE, .libuavcan_patched) + $(call DELDIR, libuavcan) $(call DELDIR, $(LIBUAVCAN_UNPACKNAME)) $(call DELFILE, $(LIBUAVCAN_PACKNAME)) $(call DELDIR, $(DSDL_UNPACKNAME)) diff --git a/canutils/uavcan/nuttx-c152f28a620ceec9f63581a7c99fe77c89938048.patch b/canutils/libuavcan/nuttx-b04396ace50155573e545ed9bf2fb09964ee2367.patch similarity index 100% rename from canutils/uavcan/nuttx-c152f28a620ceec9f63581a7c99fe77c89938048.patch rename to canutils/libuavcan/nuttx-b04396ace50155573e545ed9bf2fb09964ee2367.patch diff --git a/canutils/uavcan/platform_stm32.cpp b/canutils/libuavcan/platform_stm32.cpp similarity index 83% rename from canutils/uavcan/platform_stm32.cpp rename to canutils/libuavcan/platform_stm32.cpp index 026bbafc2..e1adeddf0 100644 --- a/canutils/uavcan/platform_stm32.cpp +++ b/canutils/libuavcan/platform_stm32.cpp @@ -1,7 +1,7 @@ /**************************************************************************** - * canutils/uavcan/uavcan_platform.cpp + * canutils/libuavcan/platform_stm32.cpp * - * Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. + * Copyright (C) 2015-2016 Omni Hoverboards Inc. All rights reserved. * Author: Paul Alexander Patience * * Redistribution and use in source and binary forms, with or without @@ -47,9 +47,9 @@ * Configuration ****************************************************************************/ -#if CONFIG_UAVCAN_RX_QUEUE_CAPACITY == 0 -# undef CONFIG_UAVCAN_RX_QUEUE_CAPACITY -# define CONFIG_UAVCAN_RX_QUEUE_CAPACITY +#if CONFIG_LIBUAVCAN_RX_QUEUE_CAPACITY == 0 +# undef CONFIG_LIBUAVCAN_RX_QUEUE_CAPACITY +# define CONFIG_LIBUAVCAN_RX_QUEUE_CAPACITY #endif /**************************************************************************** @@ -58,7 +58,8 @@ static void delay(void) { - std::usleep(uavcan_stm32::CanInitHelper:: + std::usleep(uavcan_stm32:: + CanInitHelper:: getRecommendedListeningDelay().toUSec()); } @@ -68,22 +69,22 @@ static void delay(void) uavcan::ICanDriver &getCanDriver(void) { - static uavcan_stm32::CanInitHelper can; + static uavcan_stm32::CanInitHelper can; static bool initialized = false; if (!initialized) { - uavcan::uint32_t bitrate = CONFIG_UAVCAN_BIT_RATE; + uavcan::uint32_t bitrate = CONFIG_LIBUAVCAN_BIT_RATE; -#if CONFIG_UAVCAN_INIT_RETRIES > 0 +#if CONFIG_LIBUAVCAN_INIT_RETRIES > 0 int retries = 0; #endif while (can.init(delay, bitrate) < 0) { -#if CONFIG_UAVCAN_INIT_RETRIES > 0 +#if CONFIG_LIBUAVCAN_INIT_RETRIES > 0 retries++; - if (retries >= CONFIG_UAVCAN_INIT_RETRIES) + if (retries >= CONFIG_LIBUAVCAN_INIT_RETRIES) { PANIC(); } diff --git a/examples/Kconfig b/examples/Kconfig index 780502cff..bf8a2b3de 100644 --- a/examples/Kconfig +++ b/examples/Kconfig @@ -68,7 +68,6 @@ source "$APPSDIR/examples/relays/Kconfig" source "$APPSDIR/examples/rgbled/Kconfig" source "$APPSDIR/examples/rgmp/Kconfig" source "$APPSDIR/examples/romfs/Kconfig" -source "$APPSDIR/examples/sched_note/Kconfig" source "$APPSDIR/examples/sendmail/Kconfig" source "$APPSDIR/examples/serialblaster/Kconfig" source "$APPSDIR/examples/serialrx/Kconfig" diff --git a/examples/README.txt b/examples/README.txt index ee603ace6..14291a07f 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -1751,11 +1751,6 @@ examples/romfs * CONFIG_EXAMPLES_ROMFS_MOUNTPOINT The location to mount the ROM disk. Deafault: "/usr/local/share" -examples/sched_note -^^^^^^^^^^^^^^^^^^^ - - This is a simple test of the Scheduler instrumentation logic. - examples/sendmail ^^^^^^^^^^^^^^^^^ diff --git a/examples/elf/tests/errno/Makefile b/examples/elf/tests/errno/Makefile index 89e3f2bfd..6b2d4e0b4 100644 --- a/examples/elf/tests/errno/Makefile +++ b/examples/elf/tests/errno/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/errno/Makefile # -# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -69,6 +72,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/elf/tests/hello/Makefile b/examples/elf/tests/hello/Makefile index f89759a66..28ad22211 100644 --- a/examples/elf/tests/hello/Makefile +++ b/examples/elf/tests/hello/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/hello/Makefile # -# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -69,6 +72,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/elf/tests/helloxx/Makefile b/examples/elf/tests/helloxx/Makefile index 4ab072a21..135bbd1b8 100644 --- a/examples/elf/tests/helloxx/Makefile +++ b/examples/elf/tests/helloxx/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/helloxx/Makefile # -# Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014-2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -98,6 +101,7 @@ LDLIBSTDC_STUBS_DIR = $(TOPDIR)/libxx LDLIBSTDC_STUBS_LIB = $(LDLIBSTDC_STUBS_DIR)/liblibxx.a all: $(BIN1) $(BIN2) $(BIN3) $(BIN4) $(BIN5) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.cpp @echo "CC: $<" diff --git a/examples/elf/tests/longjmp/Makefile b/examples/elf/tests/longjmp/Makefile index 26fa393bd..da76c2dbb 100644 --- a/examples/elf/tests/longjmp/Makefile +++ b/examples/elf/tests/longjmp/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/longjmp/Makefile # -# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -69,6 +72,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/elf/tests/mutex/Makefile b/examples/elf/tests/mutex/Makefile index f8ce4f613..865ccf497 100644 --- a/examples/elf/tests/mutex/Makefile +++ b/examples/elf/tests/mutex/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/mutex/Makefile # -# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -69,6 +72,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/elf/tests/pthread/Makefile b/examples/elf/tests/pthread/Makefile index 9d4ce496b..370dab604 100644 --- a/examples/elf/tests/pthread/Makefile +++ b/examples/elf/tests/pthread/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/pthread/Makefile # -# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -69,6 +72,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/elf/tests/signal/Makefile b/examples/elf/tests/signal/Makefile index c442ae9c6..22b1185d5 100644 --- a/examples/elf/tests/signal/Makefile +++ b/examples/elf/tests/signal/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/signal/Makefile # -# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -69,6 +72,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/elf/tests/struct/Makefile b/examples/elf/tests/struct/Makefile index 8fe7cf710..8045ed386 100644 --- a/examples/elf/tests/struct/Makefile +++ b/examples/elf/tests/struct/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/struct/Makefile # -# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + CELFFLAGS += -I. ifeq ($(WINTOOL),y) @@ -70,6 +73,7 @@ SRCS = struct_main.c struct_dummy.c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/elf/tests/task/Makefile b/examples/elf/tests/task/Makefile index 572d1072e..88289fcc6 100644 --- a/examples/elf/tests/task/Makefile +++ b/examples/elf/tests/task/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/task/Makefile # -# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -69,6 +72,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/module/Makefile b/examples/module/Makefile index f869adf30..680b6e58c 100644 --- a/examples/module/Makefile +++ b/examples/module/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/module/Makefile # -# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,10 @@ -include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs + +OBJEXT ?= .o +DELIM ?= / + include $(APPDIR)/Make.defs # Module example built-in application info diff --git a/examples/module/drivers/chardev/Makefile b/examples/module/drivers/chardev/Makefile index 256e5821f..67ae38255 100644 --- a/examples/module/drivers/chardev/Makefile +++ b/examples/module/drivers/chardev/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/module/drivers/chardev/Makefile # -# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,9 @@ -include $(TOPDIR)/Make.defs +OBJEXT ?= .o +DELIM ?= / + ifeq ($(WINTOOL),y) NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" else @@ -71,6 +74,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=$(OBJEXT)) all: $(BIN) +.PHONY: clean install $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" diff --git a/examples/posix_spawn/filesystem/hello/Makefile b/examples/posix_spawn/filesystem/hello/Makefile index 4097c6f86..728f49904 100644 --- a/examples/posix_spawn/filesystem/hello/Makefile +++ b/examples/posix_spawn/filesystem/hello/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/hello/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -41,6 +41,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=.o) all: $(BIN) +.PHONY: clean install $(OBJS): %.o: %.c @echo "CC: $<" diff --git a/examples/posix_spawn/filesystem/redirect/Makefile b/examples/posix_spawn/filesystem/redirect/Makefile index c6259d819..fa1a9a818 100644 --- a/examples/posix_spawn/filesystem/redirect/Makefile +++ b/examples/posix_spawn/filesystem/redirect/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/posix_spawn/filesystem/redirect/Makefile # -# Copyright (C) 2013 Gregory Nutt. All rights reserved. +# Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -41,6 +41,7 @@ SRCS = $(BIN).c OBJS = $(SRCS:.c=.o) all: $(BIN) +.PHONY: clean install $(OBJS): %.o: %.c @echo "CC: $<" diff --git a/examples/smp/smp_main.c b/examples/smp/smp_main.c index 59987758b..8ed0f942b 100644 --- a/examples/smp/smp_main.c +++ b/examples/smp/smp_main.c @@ -309,7 +309,7 @@ int smp_main(int argc, char *argv[]) for (i = 0; i < CONFIG_EXAMPLES_SMP_NBARRIER_THREADS; i++) { - if (threadid[i] != 0); + if (threadid[i] != 0) { ret = pthread_join(threadid[i], &result); show_cpu_conditional(" Main", 0); diff --git a/examples/thttpd/content/hello/Makefile b/examples/thttpd/content/hello/Makefile index 2856490ab..046684981 100644 --- a/examples/thttpd/content/hello/Makefile +++ b/examples/thttpd/content/hello/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/thttpd/content/hello/Makefile # -# Copyright (C) 2009 Gregory Nutt. All rights reserved. +# Copyright (C) 2009, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,15 +35,16 @@ -include $(TOPDIR)/Make.defs -BIN = hello +BIN = hello -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) +R1SRCS = $(BIN).c +R1OBJS = $(R1SRCS:.c=.o) -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) +R2SRC = $(BIN)-thunk.S +R2OBJ = $(R2SRC:.S=.o) all: $(BIN) +.PHONY: clean install $(R1OBJS): %.o: %.c @echo "CC: $<" diff --git a/examples/thttpd/content/netstat/Makefile b/examples/thttpd/content/netstat/Makefile index 6d89bcd88..9b8c84b9c 100644 --- a/examples/thttpd/content/netstat/Makefile +++ b/examples/thttpd/content/netstat/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/thttpd/content/netstat/Makefile # -# Copyright (C) 2009 Gregory Nutt. All rights reserved. +# Copyright (C) 2009, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,15 +35,16 @@ -include $(TOPDIR)/Make.defs -BIN = netstat +BIN = netstat -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) +R1SRCS = $(BIN).c +R1OBJS = $(R1SRCS:.c=.o) -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) +R2SRC = $(BIN)-thunk.S +R2OBJ = $(R2SRC:.S=.o) all: $(BIN) +.PHONY: clean install $(R1OBJS): %.o: %.c @echo "CC: $<" diff --git a/examples/thttpd/content/tasks/Makefile b/examples/thttpd/content/tasks/Makefile index 418fca2b3..0754b1ed4 100644 --- a/examples/thttpd/content/tasks/Makefile +++ b/examples/thttpd/content/tasks/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/thttpd/content/tasks/Makefile # -# Copyright (C) 2009 Gregory Nutt. All rights reserved. +# Copyright (C) 2009, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,15 +35,19 @@ -include $(TOPDIR)/Make.defs -BIN = tasks +OBJEXT ?= .o +DELIM ?= / -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) +BIN = tasks -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) +R1SRCS = $(BIN).c +R1OBJS = $(R1SRCS:.c=.o) + +R2SRC = $(BIN)-thunk.S +R2OBJ = $(R2SRC:.S=.o) all: $(BIN) +.PHONY: clean install $(R1OBJS): %.o: %.c @echo "CC: $<" diff --git a/examples/uavcan/Kconfig b/examples/uavcan/Kconfig index 6d47c3b57..a8b980fb5 100644 --- a/examples/uavcan/Kconfig +++ b/examples/uavcan/Kconfig @@ -6,7 +6,7 @@ config EXAMPLES_UAVCAN bool "UAVCAN example" default n - depends on CANUTILS_UAVCAN + depends on CANUTILS_LIBUAVCAN ---help--- Enable the UAVCAN example diff --git a/examples/usbserial/Makefile b/examples/usbserial/Makefile index f7d0b9602..3b8444449 100644 --- a/examples/usbserial/Makefile +++ b/examples/usbserial/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/usbserial/Makefile # -# Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2010-2012, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without diff --git a/examples/usbserial/Makefile.host b/examples/usbserial/Makefile.host index c6ebf54e5..6abf77966 100644 --- a/examples/usbserial/Makefile.host +++ b/examples/usbserial/Makefile.host @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/usbserial/Makefile.host # -# Copyright (C) 2008, 2011, 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2011, 2015-2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -37,27 +37,28 @@ -include $(TOPDIR)/Make.defs -SRC = host.c -BIN = host$(EXEEXT) +SRC = host.c +BIN = host$(EXEEXT) -DEFINES = +DEFINES = ifeq ($(CONFIG_EXAMPLES_USBSERIAL_INONLY),y) -DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_INONLY=1 +DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_INONLY=1 endif ifeq ($(CONFIG_EXAMPLES_USBSERIAL_OUTONLY),y) -DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_OUTONLY=1 +DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_OUTONLY=1 endif ifeq ($(CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL),y) -DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_ONLYSMALL=1 +DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_ONLYSMALL=1 endif ifeq ($(CONFIG_EXAMPLES_USBSERIAL_ONLYBIG),y) -DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_ONLYBIG=1 +DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_ONLYBIG=1 endif ifeq ($(CONFIG_CDCACM),y) -DEFINES += -DCONFIG_CDCACM=1 +DEFINES += -DCONFIG_CDCACM=1 endif all: $(BIN) +.PHONY: clean $(BIN): $(SRC) @$(HOSTCC) $(HOSTCFLAGS) $(DEFINES) $^ -o $@ diff --git a/examples/watchdog/Kconfig b/examples/watchdog/Kconfig index 6e9e5c55f..3d7faaef9 100644 --- a/examples/watchdog/Kconfig +++ b/examples/watchdog/Kconfig @@ -9,6 +9,28 @@ config EXAMPLES_WATCHDOG ---help--- Enable the watchdog timer example + In order to use this example, board specific logic must register the + watchdog timer driver. That would be in the board bring-up logic + in the configs//src directory for the board. + + The way that this is done depends on the underlying MCU architecture. + For STM32, this would be done like: + + #include "stm32_wdg.h" + + #if defined(CONFIG_STM32_WWDG) + stm32_wwdginitialize(CONFIG_STM32_WDG_DEVPATH); + #elif defined(CONFIG_STM32_IWDG) + stm32_iwdginitialize(CONFIG_STM32_WDG_DEVPATH, CONFIG_STM32_LSIFREQ); + #endif + + For some Atmel SAM configurations, the board-specific initialization + sequence would be like: + + #include "sam_wdt.h" + + sam_wdt_initialize(); + if EXAMPLES_WATCHDOG config EXAMPLES_WATCHDOG_DEVPATH diff --git a/examples/watchdog/watchdog_main.c b/examples/watchdog/watchdog_main.c index aeff559dd..edce88b4e 100644 --- a/examples/watchdog/watchdog_main.c +++ b/examples/watchdog/watchdog_main.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/watchdog/watchdog_main.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -53,10 +53,6 @@ #include "watchdog.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - /**************************************************************************** * Private Types ****************************************************************************/ @@ -68,18 +64,6 @@ struct wdog_example_s uint32_t timeout; }; -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -238,17 +222,6 @@ int wdog_main(int argc, char *argv[]) parse_args(&wdog, argc, argv); - /* Initialization of the WATCHDOG hardware is performed by logic external to - * this test. - */ - - ret = up_wdginitialize(); - if (ret != OK) - { - printf("wdog_main: up_wdginitialize failed: %d\n", ret); - goto errout; - } - /* Open the watchdog device for reading */ fd = open(CONFIG_EXAMPLES_WATCHDOG_DEVPATH, O_RDONLY); diff --git a/include/canutils/.gitignore b/include/canutils/.gitignore new file mode 100644 index 000000000..369d64802 --- /dev/null +++ b/include/canutils/.gitignore @@ -0,0 +1 @@ +/canard.h diff --git a/include/netutils/esp8266.h b/include/netutils/esp8266.h new file mode 100644 index 000000000..2df3e4e0a --- /dev/null +++ b/include/netutils/esp8266.h @@ -0,0 +1,122 @@ +/**************************************************************************** + * apps/include/netutils/esp8266.h + * + * Copyright (C) 2015 Pierre-Noel Bouteville. All rights reserved. + * Author: Pierre-Noel Bouteville + * + * 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. + * + ****************************************************************************/ + +#ifndef __APPS_INCLUDE_NETUTILS_ESP8266_H +#define __APPS_INCLUDE_NETUTILS_ESP8266_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "nuttx/config.h" + +#include + +#ifdef CONFIG_NETUTILS_ESP8266 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define lespBSSID_SIZE 6 + +#define lespIP(x1,x2,x3,x4) ((x1) << 24 | (x2) << 16 | (x3) << 8 | (x4) << 0) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +typedef enum +{ + lesp_eMODE_AP = 0, + lesp_eMODE_STATION = 1, + lesp_eMODE_BOTH = 2 +} lesp_mode_t; + +typedef enum +{ + lesp_eSECURITY_NONE=0, + lesp_eSECURITY_WEP, + lesp_eSECURITY_WPA_PSK, + lesp_eSECURITY_WPA2_PSK, + lesp_eSECURITY_WPA_WPA2_PSK, + lesp_eSECURITY_NBR +} lesp_security_t; + +typedef struct +{ + lesp_security_t security; + const char *ssid; + uint8_t bssid[lespBSSID_SIZE]; + int rssi; +} lesp_ap_t; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +int lesp_initialize(void); +int lesp_soft_reset(void); + +const char *lesp_security_to_str(lesp_security_t security); + +int lesp_ap_connect(const char* ssid_name, const char* ap_key, int timeout_s); + +int lesp_ap_is_connected(void); + +int lesp_set_dhcp(lesp_mode_t mode,bool enable); +int lesp_set_net(lesp_mode_t mode, + in_addr_t ip, + in_addr_t mask, + in_addr_t gateway + ); + +typedef void (*lesp_cb_t)(lesp_ap_t* wlan); + +int lesp_list_access_points(lesp_cb_t cb); + +int lesp_socket(int domain, int type, int protocol); +int lesp_closesocket(int sockfd); +int lesp_bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen); +int lesp_connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen); +int lesp_listen(int sockfd, int backlog); +int lesp_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); +ssize_t lesp_send(int sockfd, FAR const uint8_t *buf, size_t len, int flags); +ssize_t lesp_recv(int sockfd, FAR uint8_t *buf, size_t len, int flags); +int lesp_setsockopt(int sockfd, int level, int option, + FAR const void *value, socklen_t value_len); + +#endif /* CONFIG_NETUTILS_ESP8266 */ +#endif /* __APPS_INCLUDE_NETUTILS_ESP8266_H */ diff --git a/interpreters/micropython/Makefile b/interpreters/micropython/Makefile index fec76d913..1fdc67676 100644 --- a/interpreters/micropython/Makefile +++ b/interpreters/micropython/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/ interpreters/micropython/Makefile # -# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2015, 2016 Gregory Nutt. All rights reserved. # Authors: Gregory Nutt # Dave Marples # @@ -55,7 +55,7 @@ MICROPYTHON_UNPACKNAME = micropython-$(MICROPYTHON_VERSION) UNPACK ?= tar -zxf MICROPYTHON_UNPACKDIR = $(WD)/$(MICROPYTHON_UNPACKNAME) -MICROPTHYON_SRCDIR = $(MICROPYTHON_UNPACKDIR)/py +MICROPYTHON_SRCDIR = $(MICROPYTHON_UNPACKDIR)/py # Get the Micro Python build environment. mkenv.mk has these dependencies # @@ -63,7 +63,7 @@ MICROPTHYON_SRCDIR = $(MICROPYTHON_UNPACKDIR)/py # CROSS_COMPILE - Tool prefix (same as CROSSDEV in NuttX) CROSS_COMPILE ?= $(CROSSDEV) --include $(MICROPTHYON_SRCDIR)/mkenv.mk +-include $(MICROPYTHON_SRCDIR)/mkenv.mk # qstr definitions (must come before including py.mk) @@ -71,7 +71,7 @@ QSTR_DEFS = qstrdefsport.h # Include py core make definitions --include $(MICROPTHYON_SRCDIR)/py.mk +-include $(MICROPYTHON_SRCDIR)/py.mk # c99 is needed for Micro Python @@ -127,6 +127,7 @@ ROOTDEPPATH = --dep-path . # Common build all: .built +.PHONY: install context clean distclean $(MICROPYTHON_TARBALL): @echo "Downloading: $(MICROPYTHON_TARBALL)" @@ -139,13 +140,13 @@ $(MICROPYTHON_UNPACKNAME): $(MICROPYTHON_TARBALL) .built: $(MICROPYTHON_UNPACKNAME) $(OBJ) $(call ARCHIVE, $(BIN), $(OBJ)) - @touch .built + @touch $@ ifeq ($(CONFIG_BUILD_KERNEL),y) $(BIN_DIR)$(DELIM)$(PROGNAME): $(MICROPYTHON_UNPACKNAME) $(OBJ) $(MAINOBJ) @echo "LD: $(PROGNAME)" $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS) - $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) install: $(BIN_DIR)$(DELIM)$(PROGNAME) else @@ -179,5 +180,5 @@ distclean: clean $(call DELFILE, .downloaded) $(call DELFILE, $(MICROPYTHON_TARBALL)) --include $(MICROPTHYON_SRCDIR)/mkrules.mk +-include $(MICROPYTHON_SRCDIR)/mkrules.mk -include Make.dep diff --git a/netutils/Kconfig b/netutils/Kconfig index 023e33f82..2f439ce7d 100644 --- a/netutils/Kconfig +++ b/netutils/Kconfig @@ -9,6 +9,7 @@ source "$APPSDIR/netutils/chat/Kconfig" source "$APPSDIR/netutils/codecs/Kconfig" source "$APPSDIR/netutils/dhcpc/Kconfig" source "$APPSDIR/netutils/dhcpd/Kconfig" +source "$APPSDIR/netutils/esp8266/Kconfig" source "$APPSDIR/netutils/ftpc/Kconfig" source "$APPSDIR/netutils/ftpd/Kconfig" source "$APPSDIR/netutils/json/Kconfig" diff --git a/netutils/Make.defs b/netutils/Make.defs index 25fb73601..d03af9969 100644 --- a/netutils/Make.defs +++ b/netutils/Make.defs @@ -2,7 +2,7 @@ # apps/netutils/Make.defs # Adds selected applications to apps/ build # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in include and binary forms, with or without @@ -50,6 +50,10 @@ ifeq ($(CONFIG_NETUTILS_DHCPD),y) CONFIGURED_APPS += netutils/dhcpd endif +ifeq ($(CONFIG_NETUTILS_ESP8266),y) +CONFIGURED_APPS += netutils/esp8266 +endif + ifeq ($(CONFIG_NETUTILS_FTPC),y) CONFIGURED_APPS += netutils/ftpc endif diff --git a/netutils/Makefile b/netutils/Makefile index 69c3e8df7..2bafef333 100644 --- a/netutils/Makefile +++ b/netutils/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/netutils/Makefile # -# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -37,7 +37,7 @@ # Sub-directories -SUBDIRS = chat json codecs +SUBDIRS = chat json codecs esp8266 ifeq ($(CONFIG_NET),y) SUBDIRS += netlib dhcpc dhcpd discover ftpc ftpd smtp telnetd SUBDIRS += webclient webserver tftpc thttpd xmlrpc pppd diff --git a/netutils/README.txt b/netutils/README.txt index 88be41dd4..50ea2d189 100644 --- a/netutils/README.txt +++ b/netutils/README.txt @@ -45,6 +45,8 @@ highly influenced by uIP) include: device class so that groups of devices can be discovered. It is also possible to address all classes with a kind of broadcast discover. (Contributed by Max Holtzberg). + esp8266 - An ESP8266 networking layer contributed by Pierre-noel + Bouteville json - cJSON is an ultra-lightweight, portable, single-file, simple-as-can-be ANSI-C compliant JSON parser, under MIT license. Embeddable Lightweight XML-RPC Server discussed at diff --git a/netutils/esp8266/.gitignore b/netutils/esp8266/.gitignore new file mode 100644 index 000000000..f21c854d1 --- /dev/null +++ b/netutils/esp8266/.gitignore @@ -0,0 +1,6 @@ +/.built +/.depend +/Make.dep +/*.src +/*.obj +/*.lst diff --git a/netutils/esp8266/Kconfig b/netutils/esp8266/Kconfig new file mode 100644 index 000000000..f08d763fe --- /dev/null +++ b/netutils/esp8266/Kconfig @@ -0,0 +1,34 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config NETUTILS_ESP8266 + bool "ESP8266" + default n + ---help--- + Enable support for ESP8266 application interface. + +if NETUTILS_ESP8266 + +config NETUTILS_ESP8266_DEV_PATH + string "Serial device path" + default "/dev/ttyS1" + +config NETUTILS_ESP8266_BAUDRATE + int "Serial BAUD rate" + default 115200 + +config NETUTILS_ESP8266_MAXTXLEN + int "Max. TX length" + default 256 + +config NETUTILS_ESP8266_MAXRXLEN + int "Max. RX length" + default 256 + +config NETUTILS_ESP8266_THREADPRIO + int "Worker thread priority" + default 100 + +endif diff --git a/netutils/esp8266/Makefile b/netutils/esp8266/Makefile new file mode 100644 index 000000000..7aac00a5a --- /dev/null +++ b/netutils/esp8266/Makefile @@ -0,0 +1,98 @@ +############################################################################ +# apps/netutils/esp8266/Makefile +# +# Copyright (C) 2016 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# 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 + +# ESP8266 Library + +ASRCS = +CSRCS = esp8266.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 . + +# Common build + +VPATH = + +all: .built +.PHONY: context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + $(Q) touch .built + +install: + +context: + +.depend: Makefile $(SRCS) + $(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/netutils/esp8266/esp8266.c b/netutils/esp8266/esp8266.c new file mode 100644 index 000000000..ee2b71e40 --- /dev/null +++ b/netutils/esp8266/esp8266.c @@ -0,0 +1,1451 @@ +/**************************************************************************** + * apps/netutils/esp8266/esp8266.c + * + * Derives from an application to demo an Arduino connected to the ESPRESSIF + * ESP8266 with AT command firmware. + * + * Copyright (C) 2015 Pierre-Noel Bouteville. All rights reserved. + * Author: Pierre-Noel Bouteville + * + * 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "sys/socket.h" + +#include "apps/netutils/esp8266.h" + +#ifdef CONFIG_NETUTILS_ESP8266 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define NETAPP_IPCONFIG_MAC_OFFSET (20) + +#ifndef CONFIG_NETUTILS_ESP8266_MAXTXLEN +# define CONFIG_NETUTILS_ESP8266_MAXTXLEN 256 +#endif + +#ifndef CONFIG_NETUTILS_ESP8266_MAXRXLEN +# define CONFIG_NETUTILS_ESP8266_MAXRXLEN 256 +#endif + +#define BUF_CMD_LEN CONFIG_NETUTILS_ESP8266_MAXTXLEN +#define BUF_ANS_LEN CONFIG_NETUTILS_ESP8266_MAXRXLEN +#define BUF_WORKER_LEN 1024 + +#define CON_NBR 4 + +#define ESP8266_ACCESS_POINT_NBR_MAX 32 + +#define lespWAITING_OK_POLLING_MS 250 +#define lespTIMEOUT_MS 1000 +#define lespTIMEOUT_MS_SEND 1000 +#define lespTIMEOUT_MS_CONNECTION 30000 +#define lespTIMEOUT_MS_LISP_AP 5000 +#define lespTIMEOUT_FLOODING_OFFSET_S 3 +#define lespTIMEOUT_MS_RECV_S 60 + +#define lespCON_USED_MASK(idx) (1<<(idx)) +#define lespPOLLING_TIME_MS 1000 + +/* Must be a power of 2 */ + +#define SOCKET_FIFO_SIZE 2048 +#define SOCKET_NBR 4 + +#define FLAGS_SOCK_USED (1 << 0) +#define FLAGS_SOCK_CONNECTED (1 << 1) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +typedef struct +{ + sem_t *sem; + uint8_t flags; + uint16_t inndx; + uint16_t outndx; + uint8_t rxbuf[SOCKET_FIFO_SIZE]; +} lesp_socket_t; + +typedef struct +{ + bool running; + pthread_t thread; + uint8_t buf[BUF_WORKER_LEN]; + int bufsize; +} lesp_worker_t; + +typedef struct +{ + pthread_mutex_t mutex; + bool is_initialized; + int fd; + lesp_worker_t worker; + lesp_socket_t sockets[SOCKET_NBR]; + sem_t sem; + char buf[BUF_ANS_LEN]; + char bufans[BUF_ANS_LEN]; + char bufcmd[BUF_CMD_LEN]; +} lesp_state_t; + +/**************************************************************************** + * Private Functions prototypes + ****************************************************************************/ + +static int lesp_low_level_read(uint8_t* buf,int size); +static inline int lesp_read_ipd(void); +static lesp_socket_t* get_sock(int sockfd); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +lesp_state_t g_lesp_state = +{ + .mutex = PTHREAD_MUTEX_INITIALIZER, + .is_initialized = false, + .fd = -1, + .worker.running = false, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: get_sock + * + * Description: + * Get socket structure pointer of sockfd. + * + * Input Parmeters: + * sockfd : socket id + * + * Returned Value: + * socket id pointer, NULL on error. + * + ****************************************************************************/ + +static lesp_socket_t *get_sock(int sockfd) +{ + if (!g_lesp_state.is_initialized) + { + nvdbg("Esp8266 not initialized; can't list access points\n"); + return NULL; + } + + if (((unsigned int)sockfd) >= SOCKET_NBR) + { + nvdbg("Esp8266 invalid sockfd\n", sockfd); + return NULL; + } + + if ((g_lesp_state.sockets[sockfd].flags & FLAGS_SOCK_USED) == 0) + { + ndbg("Connection id %d not Created!\n", sockfd); + return NULL; + } + + return &g_lesp_state.sockets[sockfd]; +} + +/**************************************************************************** + * Name: lesp_low_level_read + * + * Description: + * put size data from esp8266 into buf. + * + * Input Parmeters: + * buf : buffer to store read data + * size : size of data to read + * + * Returned Value: + * number of byte read, -1 in case of error. + * + ****************************************************************************/ + +static int lesp_low_level_read(uint8_t* buf, int size) +{ + int ret = 0; + + struct pollfd fds[1]; + + memset(fds, 0, sizeof( struct pollfd)); + fds[0].fd = g_lesp_state.fd; + fds[0].events = POLLIN; + + /* poll return 1=>even occur 0=>timeout or -1=>error */ + + ret = poll(fds, 1, lespPOLLING_TIME_MS); + if (ret < 0) + { + int err = errno; + ndbg("worker read Error %d (errno %d)\n", ret, err); + UNUSED(err); + } + else if ((fds[0].revents & POLLERR) && (fds[0].revents & POLLHUP)) + { + ndbg("worker poll read Error %d\n", ret); + ret = -1; + } + else if (fds[0].revents & POLLIN) + { + ret = read(g_lesp_state.fd, buf, size); + } + + if (ret < 0) + { + return -1; + } + + return ret; +} + +/**************************************************************************** + * Name: lesp_read_ipd + * + * Description: + * Try to treat an '+IPD' command in worker buffer. Worker buffer should + * already contain '+IPD,,:' + * + * Input Parmeters: + * None + * + * Returned Value: + * 1 was an IPD, 0 is not an IPD, -1 on error. + * + ****************************************************************************/ + +static inline int lesp_read_ipd(void) +{ + int sockfd; + lesp_socket_t *sock; + char *ptr; + int len; + + ptr = (char *)g_lesp_state.worker.buf; + + /* Put a null at end */ + + *(ptr + g_lesp_state.worker.bufsize) = '\0'; + + if (memcmp(ptr,"+IPD,",5) != 0) + { + return 0; + } + + ptr += 5; + + sockfd = strtol(ptr, &ptr, 10); + + sock = get_sock(sockfd); + + if (sock == NULL) + { + return -1; + } + + if (*ptr++ != ',') + { + return -1; + } + + len = strtol(ptr,&ptr,10); + + if (*ptr != ':') + { + return -1; + } + + nvdbg("Read %d bytes for socket %d \n", len, sockfd); + + while(len) + { + int size; + uint8_t *buf = g_lesp_state.worker.buf; + + size = len; + if (size >= BUF_WORKER_LEN) + { + size = BUF_WORKER_LEN; + } + + size = lesp_low_level_read(buf,size); + if (size <= 0) + { + return -1; + } + + len -= size; + pthread_mutex_lock(&g_lesp_state.mutex); + while (size--) + { + int next; + uint8_t b; + + /* Read the next byte from the buffer */ + + b = *buf++; + + /* Pre-calculate the next 'inndx'. We do this so that we can + * check if the FIFO is full. + */ + + next = sock->inndx + 1; + if (next >= SOCKET_FIFO_SIZE) + { + next -= SOCKET_FIFO_SIZE; + } + + /* Is there space in the circular buffer for another byte? If + * the next 'inndx' would be equal to the 'outndx', then the + * circular buffer is full. + */ + + if (next != sock->outndx) + { + /* Yes.. add the byte to the circular buffer */ + + sock->rxbuf[sock->inndx] = b; + sock->inndx = next; + } + else + { + /* No.. the we have lost data */ + + nvdbg("overflow socket 0x%02X\n", b); + } + } + + if (sock->sem) + { + sem_post(sock->sem); + } + + pthread_mutex_unlock(&g_lesp_state.mutex); + } + + return 0; +} + +/**************************************************************************** + * Name: lesp_vsend_cmd + * + * Description: + * Send cmd with format and argument like sprintf. + * + * Input Parmeters: + * format : null terminated format string to send. + * ap : format values. + * + * Returned Value: + * len of cmd on success, -1 on error. + * + ****************************************************************************/ + +int lesp_vsend_cmd(FAR const IPTR char *format, va_list ap) +{ + int ret = 0; + + ret = vsnprintf(g_lesp_state.bufcmd,BUF_CMD_LEN,format,ap); + if (ret >= BUF_CMD_LEN) + { + g_lesp_state.bufcmd[BUF_CMD_LEN-1]='\0'; + nvdbg("Buffer too small for '%s'...\n", g_lesp_state.bufcmd); + ret = -1; + } + + nvdbg("Write:%s\n", g_lesp_state.bufcmd); + + ret = write(g_lesp_state.fd,g_lesp_state.bufcmd,ret); + if (ret < 0) + { + ret = -1; + } + + return ret; +} + +/**************************************************************************** + * Name: lesp_send_cmd + * + * Description: + * Send cmd with format and argument like sprintf. + * + * Input Parmeters: + * format : null terminated format string to send. + * ... : format values. + * + * Returned Value: + * len of cmd on success, -1 on error. + * + ****************************************************************************/ + +static int lesp_send_cmd(FAR const IPTR char *format, ...) +{ + int ret = 0; + va_list ap; + + /* Let lesp_vsend_cmd do the real work */ + + va_start(ap, format); + ret = lesp_vsend_cmd(format, ap); + va_end(ap); + + return ret; +} + +/**************************************************************************** + * Name: lesp_read + * + * Description: + * Read a answer line with timeout. + * + * Input Parmeters: + * timeout_ms : timeout in millisecond. + * + * Returned Value: + * len of line without line return on success, -1 on error. + * + ****************************************************************************/ + +static int lesp_read(int timeout_ms) +{ + int ret = 0; + + struct timespec ts; + + if (! g_lesp_state.is_initialized) + { + nvdbg("Esp8266 not initialized; can't list access points\n"); + return -1; + } + + if (clock_gettime(CLOCK_REALTIME,&ts) < 0) + { + return -1; + } + + ts.tv_sec += (timeout_ms/1000) + lespTIMEOUT_FLOODING_OFFSET_S; + + do + { + if (sem_timedwait(&g_lesp_state.sem,&ts) < 0) + { + return -1; + } + + pthread_mutex_lock(&g_lesp_state.mutex); + + ret = strlen(g_lesp_state.buf); + if (ret > 0) + { + memcpy(g_lesp_state.bufans,g_lesp_state.buf,ret+1); /* +1 to copy null */ + } + + g_lesp_state.buf[0] = '\0'; + + pthread_mutex_unlock(&g_lesp_state.mutex); + + } + while (ret == 0); + + nvdbg("read %d=>%s\n", ret, g_lesp_state.bufans); + + return ret; +} + +/**************************************************************************** + * Name: lesp_flush + * + * Description: + * Read and discard all waiting data in rx buffer. + * + * Input Parmeters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void lesp_flush(void) +{ + while (lesp_read(lespTIMEOUT_MS) >= 0); +} + +/**************************************************************************** + * Name: lesp_read_ans_ok + * + * Description: + * Read up to read OK, ERROR, or FAIL. + * + * Input Parmeters: + * timeout_ms : timeout in millisecond. + * + * Returned Value: + * 0 on OK, -1 on error. + * + ****************************************************************************/ + +int lesp_read_ans_ok(int timeout_ms) +{ + time_t end; + end = time(NULL) + (timeout_ms/1000) + lespTIMEOUT_FLOODING_OFFSET_S; + do + { + if (lesp_read(timeout_ms) < 0) + { + return -1; + } + + /* Answers sorted in probability case */ + + if (strcmp(g_lesp_state.bufans,"OK") == 0) + { + return 0; + } + + if (strcmp(g_lesp_state.bufans,"FAIL") == 0) + { + return -1; + } + + if (strcmp(g_lesp_state.bufans,"ERROR") == 0) + { + return -1; + } + + nvdbg("Got:%s\n", g_lesp_state.bufans); + + /* Ro quit in case of message flooding */ + } + while (time(NULL) < end); + + lesp_flush(); + + return -1; +} + +/**************************************************************************** + * Name: lesp_ask_ans_ok + * + * Description: + * Ask and ignore line start with '+' and except a "OK" answer. + * + * Input Parmeters: + * cmd : command sent + * timeout_ms : timeout in millisecond + * + * Returned Value: + * len of line without line return on success, -1 on error. + * + ****************************************************************************/ + +static int lesp_ask_ans_ok(int timeout_ms, FAR const IPTR char *format, ...) +{ + int ret = 0; + va_list ap; + + va_start(ap, format); + ret = lesp_vsend_cmd(format, ap); + va_end(ap); + + if (ret >= 0) + { + ret = lesp_read_ans_ok(timeout_ms); + } + + return ret; +} + +/**************************************************************************** + * Name: + * + * Description: + * Try to decode @b +CWLAP line. + * see in: + * https://room-15.github.io/blog/2015/03/26/esp8266-at-command-reference/ + * + * +CWLAP:(0,"FreeWifi",-90,"00:07:cb:07:b6:00",1) + * 0 => security + * "FreeWifi" => ssid + * -90 => rssi + * "00:07:cb:07:b6:00" => mac + * + * Note: Content of ptr is modified and string in ap point into ptr string. + * + * Input Parmeters: + * ptr : +CWLAP line null terminated string pointer. + * ap : ap result of parsing. + * + * Returned Value: + * 0 on success, -1 in case of error. + * + ****************************************************************************/ + +static int lesp_parse_cwlap_ans_line(char* ptr, lesp_ap_t *ap) +{ + int field_idx; + char* ptr_next; + + for(field_idx = 0; field_idx <= 5; field_idx++) + { + if (field_idx == 0) + { + ptr_next = strchr(ptr,'('); + } + else if (field_idx == 5) + { + ptr_next = strchr(ptr,')'); + } + else + { + ptr_next = strchr(ptr,','); + } + + if (ptr_next == NULL) + { + return -1; + } + + *ptr_next = '\0'; + + switch (field_idx) + { + case 0: + if (strcmp(ptr,"+CWLAP:") != 0) + { + return -1; + } + + break; + + case 1: + { + int i = *ptr - '0'; + + if ((i < 0) || (i >= lesp_eSECURITY_NBR)) + { + return -1; + } + + ap->security = i; + } + break; + + case 2: + ptr++; /* Remove first '"' */ + *(ptr_next -1 ) = '\0'; + ap->ssid = ptr; + break; + + case 3: + { + int i = atoi(ptr); + + if (i > 0) + { + i = -i; + } + + ap->rssi = i; + } + break; + + case 4: + { + int i; + + ptr++; /* Remove first '"' */ + *(ptr_next - 1) = '\0'; + + for (i = 0; i < lespBSSID_SIZE ; i++) + { + ap->bssid[i] = strtol(ptr,&ptr,16); + if (*ptr == ':') + { + ptr++; + } + } + } + break; + } + + ptr = ptr_next + 1; + } + + return 0; +} + +static void *lesp_worker(void *args) +{ + int ret = 0; + + lesp_worker_t *p = &g_lesp_state.worker; + + UNUSED(args); + + pthread_mutex_lock(&g_lesp_state.mutex); + nvdbg("worker Started \n"); + p->bufsize = 0; + pthread_mutex_unlock(&g_lesp_state.mutex); + + while(p->running) + { + uint8_t c; + + ret = lesp_low_level_read(&c,1); + + if (ret < 0) + { + ndbg("worker read data Error %d\n", ret); + } + else if (ret > 0) + { + //nvdbg("c:0x%02X (%c)\n", c); + + pthread_mutex_lock(&g_lesp_state.mutex); + if (c == '\n') + { + if (p->buf[p->bufsize-1] == '\r') + { + p->bufsize--; + } + + if (p->bufsize != 0) + { + p->buf[p->bufsize] = '\0'; + memcpy(g_lesp_state.buf,p->buf,p->bufsize+1); + nvdbg("Read data:%s\n", g_lesp_state.buf); + sem_post(&g_lesp_state.sem); + p->bufsize = 0; + } + } + else if (p->bufsize < BUF_ANS_LEN - 1) + { + p->buf[p->bufsize++] = c; + } + else + { + nvdbg("Read char overflow:%c\n", c); + } + + pthread_mutex_unlock(&g_lesp_state.mutex); + + if ((c == ':') && (lesp_read_ipd() != 0)) + { + p->bufsize = 0; + } + } + } + + return NULL; +} + +static inline int lesp_create_worker(int priority) +{ + int ret = 0; + + /* Thread */ + + pthread_attr_t thread_attr; + + /* Ihm priority lower than normal */ + + struct sched_param param; + + ret = pthread_attr_init(&thread_attr); + + if (ret < 0) + { + ndbg("Cannot Set scheduler parameter thread (%d)\n", ret); + } + else + { + ret = pthread_attr_getschedparam(&thread_attr,¶m); + if (ret >= 0) + { + param.sched_priority += priority; + ret = pthread_attr_setschedparam(&thread_attr,¶m); + } + else + { + ndbg("Cannot Get/Set scheduler parameter thread (%d)\n", ret); + } + + g_lesp_state.worker.running = true; + + ret = pthread_create(&g_lesp_state.worker.thread, + (ret < 0)?NULL:&thread_attr, lesp_worker, NULL); + if (ret < 0) + { + ndbg("Cannot Create thread return (%d)\n", ret); + g_lesp_state.worker.running = false; + } + + if (pthread_attr_destroy(&thread_attr) < 0) + { + ndbg("Cannot destroy thread attribute (%d)\n", ret); + } + } + + return 0; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int lesp_initialize(void) +{ + int ret = 0; + + pthread_mutex_lock(&g_lesp_state.mutex); + + if (g_lesp_state.is_initialized) + { + nvdbg("Esp8266 already initialized\n"); + pthread_mutex_unlock(&g_lesp_state.mutex); + return 0; + } + + nvdbg("Initializing Esp8266...\n"); + + memset(g_lesp_state.sockets, 0, SOCKET_NBR * sizeof(lesp_socket_t)); + + if (sem_init(&g_lesp_state.sem, 0, 0) < 0) + { + nvdbg("Cannot create semaphore\n"); + pthread_mutex_unlock(&g_lesp_state.mutex); + return -1; + } + + if (g_lesp_state.fd < 0) + { + g_lesp_state.fd = open(CONFIG_NETUTILS_ESP8266_DEV_PATH, O_RDWR); + } + + if (g_lesp_state.fd < 0) + { + ndbg("Cannot open %s\n", CONFIG_NETUTILS_ESP8266_DEV_PATH); + ret = -1; + } + +#if 0 // lesp_set_baudrate is not defined + if (ret >= 0 && lesp_set_baudrate(g_lesp_state.fd, CONFIG_NETUTILS_ESP8266_BAUDRATE) < 0) + { + ndbg("Cannot set baud rate %d\n", CONFIG_NETUTILS_ESP8266_BAUDRATE); + ret = -1; + } +#endif + + if ((ret >= 0) && (g_lesp_state.worker.running == false)) + { + ret = lesp_create_worker(CONFIG_NETUTILS_ESP8266_THREADPRIO); + } + + pthread_mutex_unlock(&g_lesp_state.mutex); + g_lesp_state.is_initialized = true; + nvdbg("Esp8266 initialized\n"); + + return 0; +} + +int lesp_soft_reset(void) +{ + int ret = 0; + int i; + + /* Rry to close opened reset */ + + for(i = 0; i < SOCKET_NBR; i++) + { + if ((g_lesp_state.sockets[i].flags & FLAGS_SOCK_USED) != 0) + { + lesp_closesocket(i); + } + } + + /* Leave time to close socket */ + + sleep(1); + + /* Send reset */ + + lesp_send_cmd("AT+RST\r\n"); + + /* Leave time to reset */ + + sleep(1); + + lesp_flush(); + + while(lesp_ask_ans_ok(lespTIMEOUT_MS, "ATE0\r\n") < 0) + { + sleep(1); + lesp_flush(); + } + + if (ret >= 0) + { + ret = lesp_ask_ans_ok(lespTIMEOUT_MS,"AT+GMR\r\n"); + } + + /* Enable the module to act as a “Station” */ + + if (ret >= 0) + { + ret = lesp_ask_ans_ok(lespTIMEOUT_MS,"AT+CWMODE_CUR=1\r\n"); + } + + /* Enable the multi connection */ + + if (ret >= 0) + { + ret = lesp_ask_ans_ok(lespTIMEOUT_MS,"AT+CIPMUX=1\r\n"); + } + + if (ret < 0) + { + ret = -1; + } + + return 0; +} + +int lesp_ap_connect(const char* ssid_name, const char* ap_key, int timeout_s) +{ + int ret = 0; + + nvdbg("Starting manual connect...\n"); + + if (! g_lesp_state.is_initialized) + { + ndbg("ESP8266 not initialized; can't run manual connect\n"); + ret = -1; + } + else + { + ret = lesp_ask_ans_ok(timeout_s*1000, + "AT+CWJAP=\"%s\",\"%s\"\r\n", + ssid_name,ap_key); + } + + if (ret < 0) + { + return -1; + } + + nvdbg("Wifi connected\n"); + return 0; +} + +/**************************************************************************** + * Name: lesp_set_net + * + * Description: + * It will set network ip of mode. + * Warning: use lesp_eMODE_STATION or lesp_eMODE_AP. + * + * Input Parmeters: + * mode : mode to configure. + * ip : ip of interface. + * mask : network mask of interface. + * gateway : gateway ip of network. + * + * Returned Value: + * 0 on success, -1 on error. + * + ****************************************************************************/ + +int lesp_set_net(lesp_mode_t mode, in_addr_t ip, in_addr_t mask, in_addr_t gateway) +{ + int ret = 0; + + ret = lesp_ask_ans_ok(lespTIMEOUT_MS, + "AT+CIP%s_CUR=" + "\"%d.%d.%d.%d\"," + "\"%d.%d.%d.%d\"," + "\"%d.%d.%d.%d\"" + "\r\n", + (mode==lesp_eMODE_STATION)?"STA":"AP", + *((uint8_t*)&(ip)+0), + *((uint8_t*)&(ip)+1), + *((uint8_t*)&(ip)+2), + *((uint8_t*)&(ip)+3), + *((uint8_t*)&(gateway)+0), + *((uint8_t*)&(gateway)+1), + *((uint8_t*)&(gateway)+2), + *((uint8_t*)&(gateway)+3), + *((uint8_t*)&(mask)+0), + *((uint8_t*)&(mask)+1), + *((uint8_t*)&(mask)+2), + *((uint8_t*)&(mask)+3)); + + if (ret < 0) + { + return -1; + } + + return 0; +} + +/**************************************************************************** + * Name: lesp_set_dhcp + * + * Description: + * It will Enable or disable DHCP of mode. + * + * Input Parmeters: + * mode : mode to configure. + * enable : true for enable, false for disable. + * + * Returned Value: + * 0 on success, -1 on error. + * + ****************************************************************************/ + +int lesp_set_dhcp(lesp_mode_t mode,bool enable) +{ + int ret = 0; + + ret = lesp_ask_ans_ok(lespTIMEOUT_MS, + "AT+CWDHCP_CUR=%d,%c\r\n", + mode,(enable)?'1':'0'); + + if (ret < 0) + { + return -1; + } + + return 0; +} + +/**************************************************************************** + * Name: lesp_list_access_points + * + * Description: + * Search all access points. + * + * Input Parmeters: + * cb : call back call for each access point found. + * + * Returned Value: + * Number access point(s) found on success, -1 on error. + * + ****************************************************************************/ + +int lesp_list_access_points(lesp_cb_t cb) +{ + lesp_ap_t ap; + int ret = 0; + int number = 0; + + /* Check esp */ + + ret = lesp_ask_ans_ok(lespTIMEOUT_MS,"AT\r\n"); + + if (ret < 0) + { + ret = lesp_send_cmd("AT+CWLAP\r\n"); + } + + while (ret >= 0) + { + ret = lesp_read(lespTIMEOUT_MS_LISP_AP); + if (ret < 0) + { + continue; + } + + nvdbg("Read:%s\n", g_lesp_state.bufans); + + if (strcmp(g_lesp_state.bufans,"OK") == 0) + { + break; + } + + ret = lesp_parse_cwlap_ans_line(g_lesp_state.bufans,&ap); + if (ret < 0) + { + ndbg("Line badly formed."); + } + + cb(&ap); + number++; + } + + if (ret < 0) + { + return -1; + } + + nvdbg("Access Point list finished with %d ap founds\n", number); + + return number; +} + +const char *lesp_security_to_str(lesp_security_t security) +{ + switch(security) + { + case lesp_eSECURITY_NONE: + return "NONE"; + case lesp_eSECURITY_WEP: + return "WEP"; + case lesp_eSECURITY_WPA_PSK: + return "WPA_PSK"; + case lesp_eSECURITY_WPA2_PSK: + return "WPA2_PSK"; + case lesp_eSECURITY_WPA_WPA2_PSK: + return "WPA_WPA2_PSK"; + default: + return "Unknown"; + } +} + +int lesp_socket(int domain, int type, int protocol) +{ + int ret = 0; + int i = CON_NBR; + + if ((domain != PF_INET) && (type != SOCK_STREAM) && (IPPROTO_TCP)) + { + ndbg("Not Implemented!\n"); + return -1; + } + + pthread_mutex_lock(&g_lesp_state.mutex); + + ret = -1; + if (!g_lesp_state.is_initialized) + { + nvdbg("Esp8266 not initialized; can't list access points\n"); + } + else + { + for (i = 0; i < CON_NBR;i++) + { + if ((g_lesp_state.sockets[i].flags & FLAGS_SOCK_USED) == 0) + { + g_lesp_state.sockets[i].flags |= FLAGS_SOCK_USED; + ret = i; + break; + } + } + } + + pthread_mutex_unlock(&g_lesp_state.mutex); + + return ret; +} + +int lesp_closesocket(int sockfd) +{ + int ret = 0; + lesp_socket_t *sock; + + sock = get_sock(sockfd); + if (sock == NULL) + { + ret = -1; + } + + if (ret >= 0) + { + ret = lesp_ask_ans_ok(lespTIMEOUT_MS, + "AT+CIPCLOSE=%d\r\n", + sockfd); + + memset(sock, 0, sizeof(lesp_socket_t)); + sock->flags = 0; + sock->inndx = 0; + sock->outndx = 0; + } + + if (ret < 0) + { + return -1; + } + + return 0; +} + +int lesp_bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen) +{ + ndbg("Not implemented %s\n", __func__); + return -1; +} + +int lesp_connect(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen) +{ + int ret = 0; + lesp_socket_t *sock; + struct sockaddr_in *in; + unsigned short port; + in_addr_t ip; + + in = (struct sockaddr_in*)addr; + port = ntohs(in->sin_port); // e.g. htons(3490) + ip = in->sin_addr.s_addr; + + DEBUGASSERT(in->sin_family = AF_INET); + + sock = get_sock(sockfd); + if (sock == NULL) + { + ret = -1; + } + + if (ret >= 0) + { + ret = lesp_ask_ans_ok(lespTIMEOUT_MS, + "AT+CIPSTART=%d," + "\"TCP\"," + "\"%d.%d.%d.%d\"," + "%d" + "\r\n", + sockfd, + *((uint8_t*)&(ip)+0), + *((uint8_t*)&(ip)+1), + *((uint8_t*)&(ip)+2), + *((uint8_t*)&(ip)+3), + port); + } + + if (ret < 0) + { + return -1; + } + + return 0; +} + +int lesp_listen(int sockfd, int backlog) +{ + ndbg("Not implemented %s\n", __func__); + return -1; +} + +int lesp_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) +{ + ndbg("Not implemented %s\n", __func__); + return -1; +} + +ssize_t lesp_send(int sockfd, FAR const uint8_t *buf, size_t len, int flags) +{ + int ret = 0; + lesp_socket_t *sock; + + UNUSED(flags); + + sock = get_sock(sockfd); + if (sock == NULL) + { + ret = -1; + } + + if (ret >= 0) + { + ret = lesp_ask_ans_ok(lespTIMEOUT_MS,"AT+CIPSEND=%d,%d\r\n",sockfd,len); + } + + if (ret >= 0) + { + nvdbg("Sending in socket %d, %d bytes\n", sockfd,len); + ret = write(g_lesp_state.fd,buf,len); + } + + while (ret >= 0) + { + char * ptr = g_lesp_state.bufans; + ret = lesp_read(lespTIMEOUT_MS); + + if (ret < 0) + { + break; + } + + while ((*ptr != 0) && (*ptr != 'S')) + { + ptr++; + } + + if (*ptr == 'S') + { + if (strcmp(ptr,"SEND OK") == 0) + break; + } + } + + if (ret >= 0) + { + nvdbg("Sent\n"); + } + + if (ret < 0) + { + ndbg("Cannot send in socket %d, %d bytes\n", sockfd, len); + return -1; + } + + return 0; +} + +ssize_t lesp_recv(int sockfd, FAR uint8_t *buf, size_t len, int flags) +{ + int ret = 0; + lesp_socket_t *sock; + sem_t sem; + + if (sem_init(&sem, 0, 0) < 0) + { + nvdbg("Cannot create semaphore\n"); + return -1; + } + + pthread_mutex_lock(&g_lesp_state.mutex); + + UNUSED(flags); + + sock = get_sock(sockfd); + if (sock == NULL) + { + ret = -1; + } + + if (ret >= 0 && sock->inndx == sock->outndx) + { + struct timespec ts; + + if (clock_gettime(CLOCK_REALTIME,&ts) < 0) + { + ret = -1; + } + else + { + ts.tv_sec += lespTIMEOUT_MS_RECV_S; + sock->sem = &sem; + while (ret >= 0 && sock->inndx == sock->outndx) + { + pthread_mutex_unlock(&g_lesp_state.mutex); + ret = sem_timedwait(&sem,&ts); + pthread_mutex_lock(&g_lesp_state.mutex); + } + + sock->sem = NULL; + } + } + + if (ret >= 0) + { + ret = 0; + while (ret < len && sock->outndx != sock->inndx) + { + /* Remove one byte from the circular buffer */ + + int ndx = sock->outndx; + *buf++ = sock->rxbuf[ndx]; + + /* Increment the circular buffer 'outndx' */ + + if (++ndx >= SOCKET_FIFO_SIZE) + { + ndx -= SOCKET_FIFO_SIZE; + } + + sock->outndx = ndx; + + /* Increment the count of bytes returned */ + + ret++; + } + } + + pthread_mutex_unlock(&g_lesp_state.mutex); + + if (ret < 0) + { + return -1; + } + + return ret; +} + +int lesp_setsockopt(int sockfd, int level, int option, + FAR const void *value, socklen_t value_len) +{ + ndbg("Not implemented %s\n", __func__); + return -1; +} + +int lesp_getsockopt(int sockfd, int level, int option, FAR void *value, + FAR socklen_t *value_len) +{ + ndbg("Not implemented %s\n", __func__); + return -1; +} + +int lesp_gethostbyname(char *hostname, uint16_t usNameLen, + unsigned long *out_ip_addr) +{ + ndbg("Not implemented %s\n", __func__); + return -1; +} + +int lesp_mdnsadvertiser(uint16_t mdnsEnabled, char *deviceServiceName, + uint16_t deviceServiceNameLength) +{ + ndbg("Not implemented %s\n", __func__); + return -1; +} + +#endif /* CONFIG_NETUTILS_ESP8266 */ diff --git a/platform/Makefile b/platform/Makefile index 0e811ffc7..a6f030a89 100644 --- a/platform/Makefile +++ b/platform/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/platform/Makefile # -# Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2013-2014, 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -36,7 +36,9 @@ -include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs +CONFIG_ARCH_BOARD ?= dummy DELIM ?= $(strip /) + include $(APPDIR)$(DELIM)Make.defs # Platform-specific Appliction Support @@ -116,6 +118,8 @@ endif # Build context setup +$(TOPDIR)$(DELIM).config: + $(PLATFORMDIR): $(TOPDIR)$(DELIM).config @echo "LN: platform$(DELIM)board to $(LINKDIR)" $(Q) $(DIRUNLINK) $(PLATFORMDIR) @@ -135,7 +139,7 @@ depend: .depend # Clean targets -clean: $(PLATFORMDIR) +clean: $(call DELFILE, .built) $(Q) $(MAKE) -C bin TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" clean diff --git a/platform/nucleo-144/Kconfig b/platform/nucleo-144/Kconfig new file mode 100644 index 000000000..03bdaac41 --- /dev/null +++ b/platform/nucleo-144/Kconfig @@ -0,0 +1,8 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if CONFIG_ARCH_BOARD_NUCLEO_144 + +endif diff --git a/platform/nucleo-144/Make.defs b/platform/nucleo-144/Make.defs new file mode 100644 index 000000000..1a2218dd0 --- /dev/null +++ b/platform/nucleo-144/Make.defs @@ -0,0 +1,41 @@ +############################################################################ +# apps/platform/nucleo-144/Make.defs +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# Author: Mark Olsson +# +# 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. +# +############################################################################ + +# Add platform specific sources to ASRCS and CSRCS + +ifeq ($(CONFIG_HAVE_CXX),y) +CSRCS += stm32_cxxinitialize.c +endif diff --git a/platform/nucleo-144/stm32_cxxinitialize.c b/platform/nucleo-144/stm32_cxxinitialize.c new file mode 100644 index 000000000..3d81e480a --- /dev/null +++ b/platform/nucleo-144/stm32_cxxinitialize.c @@ -0,0 +1,154 @@ +/**************************************************************************** + * apps/platform/nucleo-144/stm32_cxxinitialize.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * Author: Mark Olsson + * + * 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 + +#include + +#include + +#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Debug ********************************************************************/ +/* Non-standard debug that may be enabled just for testing the static + * constructors + */ + +#ifndef CONFIG_DEBUG +# undef CONFIG_DEBUG_CXX +#endif + +#ifdef CONFIG_DEBUG_CXX +# define cxxdbg dbg +# define cxxlldbg lldbg +# ifdef CONFIG_DEBUG_VERBOSE +# define cxxvdbg vdbg +# define cxxllvdbg llvdbg +# else +# define cxxvdbg(x...) +# define cxxllvdbg(x...) +# endif +#else +# define cxxdbg(x...) +# define cxxlldbg(x...) +# define cxxvdbg(x...) +# define cxxllvdbg(x...) +#endif + +/**************************************************************************** + * Private Types + ****************************************************************************/ +/* This type defines one entry in initialization array */ + +typedef void (*initializer_t)(void); + +/**************************************************************************** + * External References + ****************************************************************************/ +/* _sinit and _einit are symbols exported by the linker script that mark the + * beginning and the end of the C++ initialization section. + */ + +extern initializer_t _sinit; +extern initializer_t _einit; + +/* _stext and _etext are symbols exported by the linker script that mark the + * beginning and the end of text. + */ + +extern uint32_t _stext; +extern uint32_t _etext; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_cxxinitialize + * + * Description: + * If C++ and C++ static constructors are supported, then this function + * must be provided by board-specific logic in order to perform + * initialization of the static C++ class instances. + * + * This function should then be called in the application-specific + * user_start logic in order to perform the C++ initialization. NOTE + * that no component of the core NuttX RTOS logic is involved; this + * function definition only provides the 'contract' between application + * specific C++ code and platform-specific toolchain support. + * + ****************************************************************************/ + +void up_cxxinitialize(void) +{ + initializer_t *initp; + + cxxdbg("_sinit: %p _einit: %p _stext: %p _etext: %p\n", + &_sinit, &_einit, &_stext, &_etext); + + /* Visit each entry in the initialization table */ + + for (initp = &_sinit; initp != &_einit; initp++) + { + initializer_t initializer = *initp; + cxxdbg("initp: %p initializer: %p\n", initp, initializer); + + /* Make sure that the address is non-NULL and lies in the text region + * defined by the linker script. Some toolchains may put NULL values + * or counts in the initialization table. + */ + + if ((void *)initializer > (void *)&_stext && + (void *)initializer < (void *)&_etext) + { + cxxdbg("Calling %p\n", initializer); + initializer(); + } + } +} + +#endif /* CONFIG_HAVE_CXX && CONFIG_HAVE_CXXINITIALIZE */ diff --git a/system/Kconfig b/system/Kconfig index 8ad2b6769..3a57198fb 100644 --- a/system/Kconfig +++ b/system/Kconfig @@ -22,6 +22,7 @@ source "$APPSDIR/system/mdio/Kconfig" source "$APPSDIR/system/sudoku/Kconfig" source "$APPSDIR/system/lm75/Kconfig" source "$APPSDIR/system/vi/Kconfig" +source "$APPSDIR/system/sched_note/Kconfig" source "$APPSDIR/system/stackmonitor/Kconfig" source "$APPSDIR/system/symtab/Kconfig" source "$APPSDIR/system/cdcacm/Kconfig" diff --git a/system/Make.defs b/system/Make.defs index 2caba6179..984d9f670 100644 --- a/system/Make.defs +++ b/system/Make.defs @@ -102,6 +102,10 @@ ifeq ($(CONFIG_SYSTEM_READLINE),y) CONFIGURED_APPS += system/readline endif +ifeq ($(CONFIG_SYSTEM_NOTE),y) +CONFIGURED_APPS += system/sched_note +endif + ifeq ($(CONFIG_SYSTEM_SUDOKU),y) CONFIGURED_APPS += system/sudoku endif diff --git a/system/hex2bin/Makefile b/system/hex2bin/Makefile index 9c49afad5..6c5b34340 100644 --- a/system/hex2bin/Makefile +++ b/system/hex2bin/Makefile @@ -87,11 +87,11 @@ else INSTALL_DIR = $(BIN_DIR) endif -CONFIG_EXAMPLES_HEX2BIN_PROGNAME ?= hex2bin$(EXEEXT) -HEX2BIN_PROGNAME = $(CONFIG_EXAMPLES_HEX2BIN_PROGNAME) +CONFIG_SYSTEM_HEX2BIN_PROGNAME ?= hex2bin$(EXEEXT) +HEX2BIN_PROGNAME = $(CONFIG_SYSTEM_HEX2BIN_PROGNAME) -CONFIG_EXAMPLES_HEX2MEM_PROGNAME ?= hex2mem$(EXEEXT) -HEX2MEM_PROGNAME = $(CONFIG_EXAMPLES_HEX2MEM_PROGNAME) +CONFIG_SYSTEM_HEX2MEM_PROGNAME ?= hex2mem$(EXEEXT) +HEX2MEM_PROGNAME = $(CONFIG_SYSTEM_HEX2MEM_PROGNAME) ROOTDEPPATH = --dep-path . VPATH = diff --git a/system/mdio/Makefile b/system/mdio/Makefile index 2fa178583..2d400ea09 100644 --- a/system/mdio/Makefile +++ b/system/mdio/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# apps/examples/mdio/Makefile +# apps/system/mdio/Makefile # # Copyright (C) 2008, 2010-2013 Gregory Nutt. All rights reserved. # Author: Gregory Nutt diff --git a/system/mdio/mdio_main.c b/system/mdio/mdio_main.c index 74549a27d..9300458ce 100644 --- a/system/mdio/mdio_main.c +++ b/system/mdio/mdio_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/mdio/mdio_main.c + * system/mdio/mdio_main.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/system/prun/prun.h b/system/prun/prun.h index ddb6ee650..fb5b96ab3 100644 --- a/system/prun/prun.h +++ b/system/prun/prun.h @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/prun/prun.h + * apps/system/prun/prun.h * * Copyright (C) 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __EXAMPLES_PASHELLO_H -#define __EXAMPLES_PASHELLO_H +#ifndef __APPS_SYSTEM_PRUN_H +#define __APPS_SYSTEM_PRUN_H /**************************************************************************** * Included Files @@ -52,4 +52,4 @@ extern void hello_register(void); -#endif /* __EXAMPLES_PASHELLO_H */ +#endif /* __APPS_SYSTEM_PRUN_H */ diff --git a/examples/sched_note/.gitignore b/system/sched_note/.gitignore similarity index 100% rename from examples/sched_note/.gitignore rename to system/sched_note/.gitignore diff --git a/examples/sched_note/Kconfig b/system/sched_note/Kconfig similarity index 64% rename from examples/sched_note/Kconfig rename to system/sched_note/Kconfig index eeae2e660..9ad1f1e0c 100644 --- a/examples/sched_note/Kconfig +++ b/system/sched_note/Kconfig @@ -3,16 +3,16 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -config EXAMPLES_NOTE - bool "Scheduler instrumentation example" +config SYSTEM_NOTE + bool "Scheduler monitor" default n depends on DRIVER_NOTE ---help--- - Enable the schedler instrumentation example + Enable the schedler instrumentation monitor -if EXAMPLES_NOTE +if SYSTEM_NOTE -config EXAMPLES_NOTE_PROGNAME +config SYSTEM_NOTE_PROGNAME string "Program name" default "note" depends on BUILD_KERNEL @@ -20,20 +20,20 @@ config EXAMPLES_NOTE_PROGNAME This is the name of the program that will be use when the NSH ELF program is installed. -config EXAMPLES_NOTE_PRIORITY +config SYSTEM_NOTE_PRIORITY int "Note daemon task priority" default 100 -config EXAMPLES_NOTE_STACKSIZE +config SYSTEM_NOTE_STACKSIZE int "Note daemon stack size" default 2048 -config EXAMPLES_NOTE_BUFFERSIZE +config SYSTEM_NOTE_BUFFERSIZE int "Note daemon I/O buffer size" default 1024 -config EXAMPLES_NOTE_DELAY +config SYSTEM_NOTE_DELAY int "Note daemon sample delay (msec)" default 1000 -endif # EXAMPLES_NOTE +endif # SYSTEM_NOTE diff --git a/examples/sched_note/Makefile b/system/sched_note/Makefile similarity index 86% rename from examples/sched_note/Makefile rename to system/sched_note/Makefile index 89d0bfee8..913d7ae20 100644 --- a/examples/sched_note/Makefile +++ b/system/sched_note/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# apps/examples/note/Makefile +# apps/system/note/Makefile # # Copyright (C) 2016 Gregory Nutt. All rights reserved. # Author: Gregory Nutt @@ -37,12 +37,12 @@ # LED driver test built-in application info -CONFIG_EXAMPLES_NOTE_PRIORITY ?= SCHED_PRIORITY_DEFAULT -CONFIG_EXAMPLES_NOTE_STACKSIZE ?= 2048 +CONFIG_SYSTEM_NOTE_PRIORITY ?= SCHED_PRIORITY_DEFAULT +CONFIG_SYSTEM_NOTE_STACKSIZE ?= 2048 APPNAME = note -PRIORITY = $(CONFIG_EXAMPLES_NOTE_PRIORITY) -STACKSIZE = $(CONFIG_EXAMPLES_NOTE_STACKSIZE) +PRIORITY = $(CONFIG_SYSTEM_NOTE_PRIORITY) +STACKSIZE = $(CONFIG_SYSTEM_NOTE_STACKSIZE) # LED driver test @@ -50,7 +50,7 @@ ASRCS = CSRCS = MAINSRC = note_main.c -CONFIG_EXAMPLES_NOTE_PROGNAME ?= note$(EXEEXT) -PROGNAME = $(CONFIG_EXAMPLES_NOTE_PROGNAME) +CONFIG_SYSTEM_NOTE_PROGNAME ?= note$(EXEEXT) +PROGNAME = $(CONFIG_SYSTEM_NOTE_PROGNAME) include $(APPDIR)/Application.mk diff --git a/examples/sched_note/note_main.c b/system/sched_note/note_main.c similarity index 97% rename from examples/sched_note/note_main.c rename to system/sched_note/note_main.c index dd0ea4219..fa76f8e5c 100644 --- a/examples/sched_note/note_main.c +++ b/system/sched_note/note_main.c @@ -1,5 +1,5 @@ /**************************************************************************** - * examples/note/note_main.c + * system/note/note_main.c * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -54,7 +54,7 @@ ****************************************************************************/ static bool g_note_daemon_started; -static uint8_t g_note_buffer[CONFIG_EXAMPLES_NOTE_BUFFERSIZE]; +static uint8_t g_note_buffer[CONFIG_SYSTEM_NOTE_BUFFERSIZE]; /* Names of task/thread states */ @@ -377,13 +377,13 @@ static int note_daemon(int argc, char *argv[]) for (; ; ) { - nread = read(fd, g_note_buffer, CONFIG_EXAMPLES_NOTE_BUFFERSIZE); + nread = read(fd, g_note_buffer, CONFIG_SYSTEM_NOTE_BUFFERSIZE); if (nread > 0) { dump_notes(nread); } - usleep(CONFIG_EXAMPLES_NOTE_DELAY * 1000L); + usleep(CONFIG_SYSTEM_NOTE_DELAY * 1000L); } (void)close(fd); @@ -422,8 +422,8 @@ int note_main(int argc, FAR char *argv[]) ledargv[0] = "note_daemon"; ledargv[1] = NULL; - ret = task_create("note_daemon", CONFIG_EXAMPLES_NOTE_PRIORITY, - CONFIG_EXAMPLES_NOTE_STACKSIZE, note_daemon, + ret = task_create("note_daemon", CONFIG_SYSTEM_NOTE_PRIORITY, + CONFIG_SYSTEM_NOTE_STACKSIZE, note_daemon, (FAR char * const *)ledargv); if (ret < 0) { diff --git a/system/zmodem/host/nuttx/ascii.h b/system/zmodem/host/nuttx/ascii.h index 6c11ba8e0..67a6d088c 100644 --- a/system/zmodem/host/nuttx/ascii.h +++ b/system/zmodem/host/nuttx/ascii.h @@ -1,4 +1,4 @@ -**************************************************************************** +/**************************************************************************** * apps/system/zmodem/host/ascii.h * ASCII Control Codes *