From 3a8cfb6c04012994130a30b4d11a0eca70887814 Mon Sep 17 00:00:00 2001 From: Nobutaka Toyoshima Date: Mon, 8 Sep 2014 17:48:37 +0900 Subject: [PATCH 01/14] nshlib: Fix a resource leak in cmd_hexdump() Jira: PDFW15IS-265 Coverity-ID: 10786 Signed-off-by: Masayuki Ishikawa --- nshlib/nsh_dbgcmds.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nshlib/nsh_dbgcmds.c b/nshlib/nsh_dbgcmds.c index c86d77109..cc67a2708 100644 --- a/nshlib/nsh_dbgcmds.c +++ b/nshlib/nsh_dbgcmds.c @@ -395,6 +395,7 @@ int cmd_hexdump(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) buffer = (FAR uint8_t *)malloc(IOBUFFERSIZE); if(buffer == NULL) { + (void)close(fd); nsh_output(vtbl, g_fmtcmdfailed, "hexdump", "malloc", NSH_ERRNO); return ERROR; } From 523d7645c4ac02f79c793b536f93f58bd5452a4f Mon Sep 17 00:00:00 2001 From: Simon Piriou Date: Sun, 21 May 2017 16:24:49 +0200 Subject: [PATCH 02/14] wapi: add basic wapi_event_stream_extract implementation --- nshlib/Makefile | 2 ++ wireless/wapi/src/wireless.c | 59 ++++++++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/nshlib/Makefile b/nshlib/Makefile index 6490d74ee..47ea7ab9f 100644 --- a/nshlib/Makefile +++ b/nshlib/Makefile @@ -75,8 +75,10 @@ endif ifeq ($(CONFIG_NET),y) CSRCS += nsh_netinit.c nsh_netcmds.c ifeq ($(CONFIG_WIRELESS_WAPI),y) +ifeq ($(CONFIG_NSH_NETINIT),y) CSRCS += nsh_associate.c endif +endif ifeq ($(CONFIG_NET_ROUTE),y) CSRCS += nsh_routecmds.c endif diff --git a/wireless/wapi/src/wireless.c b/wireless/wapi/src/wireless.c index f76cd250b..c45dea472 100644 --- a/wireless/wapi/src/wireless.c +++ b/wireless/wapi/src/wireless.c @@ -224,7 +224,57 @@ static int wapi_event_stream_extract(FAR struct wapi_event_stream_s *stream, { #warning Missing logic // return iw_extract_event_stream((struct stream_descr *)stream, iwe, 0); -return -ENOSYS; + + int ret; + struct iw_event *iwe_stream; + + if (stream->current + offsetof(struct iw_event, u) > stream->end) + { + /* Nothing to process */ + + return 0; + } + + iwe_stream = (struct iw_event*)stream->current; + + if (stream->current + iwe_stream->len > stream->end || + iwe_stream->len < offsetof(struct iw_event, u)) + { + return -1; + } + + ret = 1; + + switch (iwe_stream->cmd) + { + case SIOCGIWESSID: + case IWEVGENIE: + iwe->cmd = iwe_stream->cmd; + iwe->len = offsetof(struct iw_event, u) + sizeof(struct iw_point); + iwe->u.data.flags = iwe_stream->u.data.flags; + iwe->u.data.length = iwe_stream->u.data.length; + + iwe->u.data.pointer = (FAR void*)(stream->current + + offsetof(struct iw_event, u) + + (unsigned long)iwe_stream->u.data.pointer); + break; + + default: + if (iwe_stream->len > sizeof(*iwe)) + { + WAPI_ERROR("Unhandled event size 0x%x %d\n", iwe_stream->cmd, + iwe_stream->len); + iwe->cmd = 0; + iwe->len = offsetof(struct iw_event, u); + break; + } + memcpy(iwe, iwe_stream, iwe_stream->len); + } + + /* Update stream to next event */ + + stream->current += iwe_stream->len; + return ret; } /**************************************************************************** @@ -1113,6 +1163,8 @@ alloc: return -errcode; } + printf("got %d bytes\n", wrq.u.data.length); + /* We have the results, process them. */ if (wrq.u.data.length) @@ -1125,7 +1177,8 @@ alloc: { /* Get the next event from the stream */ - if ((ret = wapi_event_stream_extract(&stream, &iwe)) >= 0) + ret = wapi_event_stream_extract(&stream, &iwe); + if (ret > 0) { int eventret = wapi_scan_event(&iwe, aps); if (eventret < 0) @@ -1133,7 +1186,7 @@ alloc: ret = eventret; } } - else + else if (ret < 0) { WAPI_ERROR("ERROR: wapi_event_stream_extract() failed!\n"); } From 2984fa3911196de3d857fdaa16da54ed052e7293 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 May 2017 10:51:26 -0600 Subject: [PATCH 03/14] apps/system/dhcpc: Add a command to renew or establish a lease on an IPv4 address. --- examples/buttons/Kconfig | 6 +- netutils/dhcpc/dhcpc.c | 1 + system/dhcpc/.gitignore | 11 +++ system/dhcpc/Kconfig | 32 +++++++++ system/dhcpc/Make.defs | 40 +++++++++++ system/dhcpc/Makefile | 142 ++++++++++++++++++++++++++++++++++++++ system/dhcpc/dhcpc_main.c | 138 ++++++++++++++++++++++++++++++++++++ 7 files changed, 367 insertions(+), 3 deletions(-) create mode 100644 system/dhcpc/.gitignore create mode 100644 system/dhcpc/Kconfig create mode 100644 system/dhcpc/Make.defs create mode 100644 system/dhcpc/Makefile create mode 100644 system/dhcpc/dhcpc_main.c diff --git a/examples/buttons/Kconfig b/examples/buttons/Kconfig index 96910293c..32a9e5aed 100644 --- a/examples/buttons/Kconfig +++ b/examples/buttons/Kconfig @@ -21,15 +21,15 @@ config EXAMPLES_BUTTONS_PROGNAME program is installed. config EXAMPLES_BUTTONS_PRIORITY - int "LED task priority" + int "Button task priority" default 100 config EXAMPLES_BUTTONS_STACKSIZE - int "LED stack size" + int "Button stack size" default 2048 config EXAMPLES_BUTTONS_DEVPATH - string "LED device path" + string "Button device path" default "/dev/buttons" config EXAMPLES_BUTTONS_NAMES diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c index 0f900df44..9f4c7e52d 100644 --- a/netutils/dhcpc/dhcpc.c +++ b/netutils/dhcpc/dhcpc.c @@ -541,6 +541,7 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult) { return ERROR; } + retries++; /* Get the ACK/NAK response to the REQUEST (or timeout) */ diff --git a/system/dhcpc/.gitignore b/system/dhcpc/.gitignore new file mode 100644 index 000000000..fa1ec7579 --- /dev/null +++ b/system/dhcpc/.gitignore @@ -0,0 +1,11 @@ +/Make.dep +/.depend +/.built +/*.asm +/*.obj +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src diff --git a/system/dhcpc/Kconfig b/system/dhcpc/Kconfig new file mode 100644 index 000000000..51d59bf22 --- /dev/null +++ b/system/dhcpc/Kconfig @@ -0,0 +1,32 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config SYSTEM_DHCPC + bool "DHCP Address Renewal" + default n + select NETUTILS_DHCPC + depends on NET_UDP && NET_BROADCAST && NET_IPv4 + ---help--- + Enble the DHCP client 'renew' command + +if SYSTEM_DHCPC + +config SYSTEM_DHCPC_PROGNAME + string "Program name" + default "renew" + depends on BUILD_KERNEL + ---help--- + This is the name of the program that will be use when the NSH ELF + program is installed. + +config SYSTEM_DHCPC_PRIORITY + int "DHCPC task priority" + default 100 + +config SYSTEM_DHCPC_STACKSIZE + int "DHCPC stack size" + default 2048 + +endif diff --git a/system/dhcpc/Make.defs b/system/dhcpc/Make.defs new file mode 100644 index 000000000..7e559c2a2 --- /dev/null +++ b/system/dhcpc/Make.defs @@ -0,0 +1,40 @@ +############################################################################ +# apps/system/dhcpc/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2017 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. +# +############################################################################ + +ifeq ($(CONFIG_SYSTEM_DHCPC),y) +CONFIGURED_APPS += system/dhcpc +endif + diff --git a/system/dhcpc/Makefile b/system/dhcpc/Makefile new file mode 100644 index 000000000..935277acf --- /dev/null +++ b/system/dhcpc/Makefile @@ -0,0 +1,142 @@ +############################################################################ +# apps/system/dhcpc/Makefile +# +# Copyright (C) 2017 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 + +# DHCPC address renewal built-in application info + +CONFIG_SYSTEM_DHCPC_PRIORITY ?= SCHED_PRIORITY_DEFAULT +CONFIG_SYSTEM_DHCPC_STACKSIZE ?= 2048 + +APPNAME = renew +PRIORITY = $(CONFIG_SYSTEM_DHCPC_PRIORITY) +STACKSIZE = $(CONFIG_SYSTEM_DHCPC_STACKSIZE) + +CONFIG_SYSTEM_DHCPC_PROGNAME ?= renew$(EXEEXT) +PROGNAME = $(CONFIG_SYSTEM_DHCPC_PROGNAME) + +# DHCPC address renewal + +ASRCS = +CSRCS = +MAINSRC = dhcpc_main.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) +MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) +OBJS = $(AOBJS) $(COBJS) + +ifneq ($(CONFIG_BUILD_KERNEL),y) + OBJS += $(MAINOBJ) +endif + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ifeq ($(WINTOOL),y) + INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}" +else + INSTALL_DIR = $(BIN_DIR) +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + @touch .built + +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) + +install: $(BIN_DIR)$(DELIM)$(PROGNAME) + +else +install: + +endif + +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat +else +context: +endif + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep +.PHONY: preconfig +preconfig: diff --git a/system/dhcpc/dhcpc_main.c b/system/dhcpc/dhcpc_main.c new file mode 100644 index 000000000..fd3deec1c --- /dev/null +++ b/system/dhcpc/dhcpc_main.c @@ -0,0 +1,138 @@ +/**************************************************************************** + * system/dhcpc/dhcpc_main.c + * + * Copyright (C) 2017 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +#include "netutils/netlib.h" +#include "netutils/dhcpc.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * dhcpc_showusage + ****************************************************************************/ + +static void dhcpc_showusage(FAR const char *progname, int exitcode) +{ + fprintf(stderr, "Usage: %s \n"); + exit(exitcode); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * dhcpc_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int dhcpc_main(int argc, char *argv[]) +#endif +{ + FAR const char *devname; + FAR void *handle; + uint8_t mac[IFHWADDRLEN]; + struct dhcpc_state ds; + int ret; + + /* One and only one argument is expected: The network device name. */ + + if (argc != 2) + { + fprintf(stderr, "ERROR: Invalid number of arguments\n"); + dhcpc_showusage(argv[0], EXIT_FAILURE); + } + + devname = argv[1]; + + /* Get the MAC address of the NIC */ + + netlib_getmacaddr(devname, mac); + + /* Set up the DHCPC modules */ + + handle = dhcpc_open(devname, &mac, IFHWADDRLEN); + if (handle == NULL) + { + fprintf(stderr, "ERROR: dhcpc_open() for '%s' failed\n", devname); + return EXIT_FAILURE; + } + + /* Get an IP address. */ + + ret = dhcpc_request(handle, &ds); + if (ret < 0) + { + (void)dhcpc_close(handle); + fprintf(stderr, "ERROR: dhcpc_request() failed\n"); + return EXIT_FAILURE; + } + + /* Save the addresses that we obtained. */ + + netlib_set_ipv4addr(devname, &ds.ipaddr); + + if (ds.netmask.s_addr != 0) + { + netlib_set_ipv4netmask(devname, &ds.netmask); + } + + if (ds.default_router.s_addr != 0) + { + netlib_set_dripv4addr(devname, &ds.default_router); + } + + if (ds.dnsaddr.s_addr != 0) + { + netlib_set_ipv4dnsaddr(&ds.dnsaddr); + } + + dhcpc_close(handle); + return EXIT_SUCCESS; +} From da9f0421c002532d8a62197f5edc7a1ba7d6afdb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 May 2017 10:53:45 -0600 Subject: [PATCH 04/14] apps/system/dhcpc: Currently only works with IPv4 and Ethernet MAC. --- system/dhcpc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/dhcpc/Kconfig b/system/dhcpc/Kconfig index 51d59bf22..9b88c0392 100644 --- a/system/dhcpc/Kconfig +++ b/system/dhcpc/Kconfig @@ -7,7 +7,7 @@ config SYSTEM_DHCPC bool "DHCP Address Renewal" default n select NETUTILS_DHCPC - depends on NET_UDP && NET_BROADCAST && NET_IPv4 + depends on NET_UDP && NET_BROADCAST && NET_IPv4 && NET_ETHERNET ---help--- Enble the DHCP client 'renew' command From c1a64d0cad68ab2da2b9948731aa1710fef250ab Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 May 2017 11:26:16 -0600 Subject: [PATCH 05/14] apps/system/ntpc: Add a command to start or stop the NTPC daemon. --- system/ntpc/.gitignore | 11 +++ system/ntpc/Kconfig | 25 ++++++ system/ntpc/Make.defs | 39 +++++++++ system/ntpc/Makefile | 155 +++++++++++++++++++++++++++++++++++ system/ntpc/ntpcstart_main.c | 70 ++++++++++++++++ system/ntpc/ntpcstop_main.c | 70 ++++++++++++++++ 6 files changed, 370 insertions(+) create mode 100644 system/ntpc/.gitignore create mode 100644 system/ntpc/Kconfig create mode 100644 system/ntpc/Make.defs create mode 100644 system/ntpc/Makefile create mode 100644 system/ntpc/ntpcstart_main.c create mode 100644 system/ntpc/ntpcstop_main.c diff --git a/system/ntpc/.gitignore b/system/ntpc/.gitignore new file mode 100644 index 000000000..fa1ec7579 --- /dev/null +++ b/system/ntpc/.gitignore @@ -0,0 +1,11 @@ +/Make.dep +/.depend +/.built +/*.asm +/*.obj +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src diff --git a/system/ntpc/Kconfig b/system/ntpc/Kconfig new file mode 100644 index 000000000..c9f6b52e3 --- /dev/null +++ b/system/ntpc/Kconfig @@ -0,0 +1,25 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config SYSTEM_NTPC + bool "NTP Daemon Commands" + default n + select NETUTILS_NTPCLIENT + depends on NET_UDP + ---help--- + Enble the NTP client 'start' and 'stop' commands + + +if SYSTEM_NTPC + +config SYSTEM_NTPC_PRIORITY + int "NTPC task priority" + default 100 + +config SYSTEM_NTPC_STACKSIZE + int "NTPC stack size" + default 2048 + +endif diff --git a/system/ntpc/Make.defs b/system/ntpc/Make.defs new file mode 100644 index 000000000..07ab398c9 --- /dev/null +++ b/system/ntpc/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# apps/system/ntpc/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2017 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. +# +############################################################################ + +ifeq ($(CONFIG_SYSTEM_NTPC),y) +CONFIGURED_APPS += system/ntpc +endif diff --git a/system/ntpc/Makefile b/system/ntpc/Makefile new file mode 100644 index 000000000..f30857d41 --- /dev/null +++ b/system/ntpc/Makefile @@ -0,0 +1,155 @@ +############################################################################ +# apps/system/ntpc/Makefile +# +# Copyright (C) 2017 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 + +# NTPC address renewal built-in application info + +CONFIG_SYSTEM_NTPC_PRIORITY ?= SCHED_PRIORITY_DEFAULT +CONFIG_SYSTEM_NTPC_STACKSIZE ?= 2048 + +APPNAME1 = ntpstart +APPNAME2 = ntpstop +PRIORITY = $(CONFIG_SYSTEM_NTPC_PRIORITY) +STACKSIZE = $(CONFIG_SYSTEM_NTPC_STACKSIZE) + +PROGNAME1 = ntpstart$(EXEEXT) +PROGNAME2 = ntpstop$(EXEEXT) + +# NTPC address renewal + +ASRCS = +CSRCS = +MAINSRC1 = ntpcstart_main.c +MAINSRC2 = ntpcstop_main.c +MAINSRC = $(MAINSRC1) $(MAINSRC2) + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) +MAINOBJ1 = $(MAINSRC1:.c=$(OBJEXT)) +MAINOBJ2 = $(MAINSRC2:.c=$(OBJEXT)) +MAINOBJ = $(MAINOBJ1) $(MAINOBJ2) + +SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) +OBJS = $(AOBJS) $(COBJS) + +ifneq ($(CONFIG_BUILD_KERNEL),y) + OBJS += $(MAINOBJ) +endif + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +ifeq ($(WINTOOL),y) + INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}" +else + INSTALL_DIR = $(BIN_DIR) +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + $(call ARCHIVE, $(BIN), $(OBJS)) + @touch .built + +ifeq ($(CONFIG_BUILD_KERNEL),y) +$(BIN_DIR)$(DELIM)$(PROGNAME1): $(OBJS) $(MAINOBJ1) + @echo "LD: $(PROGNAME1)" + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME1) $(ARCHCRT0OBJ) $(MAINOBJ1) $(LDLIBS) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME1) + +$(BIN_DIR)$(DELIM)$(PROGNAME2): $(OBJS) $(MAINOBJ2) + @echo "LD: $(PROGNAME2)" + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME2) $(ARCHCRT0OBJ) $(MAINOBJ2) $(LDLIBS) + $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME2) + +install: $(BIN_DIR)$(DELIM)$(PROGNAME1) $(BIN_DIR)$(DELIM)$(PROGNAME2) + +else +install: + +endif + +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME1),$(PRIORITY),$(STACKSIZE),$(APPNAME1)_main) + +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME2),$(PRIORITY),$(STACKSIZE),$(APPNAME2)_main) + +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat +else +context: +endif + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep +.PHONY: preconfig +preconfig: diff --git a/system/ntpc/ntpcstart_main.c b/system/ntpc/ntpcstart_main.c new file mode 100644 index 000000000..43ae234c7 --- /dev/null +++ b/system/ntpc/ntpcstart_main.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * system/ntpc/ntpcstart_main.c + * + * Copyright (C) 2017 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "netutils/ntpclient.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * ntpcstart_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int ntpcstart_main(int argc, char *argv[]) +#endif +{ + int pid = ntpc_start(); + if (pid < 0) + { + fprintf(stderr, "ERROR: ntpc_start() failed\n"); + return EXIT_FAILURE; + } + + printf("Started the NTP daemon as PID=%d\n", pid); + return EXIT_SUCCESS; +} diff --git a/system/ntpc/ntpcstop_main.c b/system/ntpc/ntpcstop_main.c new file mode 100644 index 000000000..06627efaf --- /dev/null +++ b/system/ntpc/ntpcstop_main.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * system/ntpc/ntpc_main.c + * + * Copyright (C) 2017 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "netutils/ntpclient.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * ntpcstop_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int ntpcstop_main(int argc, char *argv[]) +#endif +{ + int ret = ntpc_stop(); + if (ret < 0) + { + fprintf(stderr, "ERROR: ntpc_stop() failed\n"); + return EXIT_FAILURE; + } + + printf("Stopped the NTP daemon\n"); + return EXIT_SUCCESS; +} From ccb6282f5b33e7c20aae3573f19801b4d37a27af Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 May 2017 11:32:07 -0600 Subject: [PATCH 06/14] apps/system/dhcpc: Add missing argument of fprintf. --- system/dhcpc/dhcpc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/dhcpc/dhcpc_main.c b/system/dhcpc/dhcpc_main.c index fd3deec1c..496a9a0e8 100644 --- a/system/dhcpc/dhcpc_main.c +++ b/system/dhcpc/dhcpc_main.c @@ -57,7 +57,7 @@ static void dhcpc_showusage(FAR const char *progname, int exitcode) { - fprintf(stderr, "Usage: %s \n"); + fprintf(stderr, "Usage: %s \n", progname); exit(exitcode); } From 8c1446671c4310e6837830888c39d5c66839648b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 May 2017 12:00:55 -0600 Subject: [PATCH 07/14] apps/nshlib: Add a new option CONFIG_NSH_NETLOCAL that will suppress some built in operations and will support manual configuration of a wireless network --- nshlib/Kconfig | 26 +++++++++++++++++++++++++- nshlib/Makefile | 4 ++++ nshlib/nsh_netinit.c | 13 ++++++++----- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/nshlib/Kconfig b/nshlib/Kconfig index e3dd1fbae..deb9afa4c 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -1009,10 +1009,34 @@ config NSH_NETINIT if NSH_NETINIT +config NSH_NETLOCAL + bool "Local network initialization" + default n + ---help--- + If this option is selected, then NSH will only initialize the local + attributes of the network: The MAC address is needed and any IP + addresses as needed. More importantly, it will not do the following: + + - It will not bring the netup up. The can be done later with the + NSH ifup command. + - It will not associate any wireless devices to an access point. + - It will not attempt to obtain an IP address if DHCPC is selected. + This may be done later from the NSH command line with the + apps/system/dhcpc 'renew' command. + - It will not start the NTPC daemon. This may be done later from + the NSH command line with the apps/system/ntpc 'ntpcstart' command. + + This option permits you to divid the network configuration into two + parts: The local configuration of the network device and the dynamic + configuration of the device in the network. This may be important in + an environment when, for example, you need to manually scan for + available access points and associate the wireless driver with an + access point. + config NSH_NETINIT_THREAD bool "Network initialization thread" default n - depends on !DISABLE_PTHREAD + depends on !DISABLE_PTHREAD && !NSH_NETLOCAL ---help--- NSH is brought up through a series of sequential initialization steps. This includes networking. If the network is available on diff --git a/nshlib/Makefile b/nshlib/Makefile index 47ea7ab9f..50adedf40 100644 --- a/nshlib/Makefile +++ b/nshlib/Makefile @@ -74,11 +74,15 @@ endif ifeq ($(CONFIG_NET),y) CSRCS += nsh_netinit.c nsh_netcmds.c + ifeq ($(CONFIG_WIRELESS_WAPI),y) ifeq ($(CONFIG_NSH_NETINIT),y) +ifneq ($(CONFIG_NSH_NETLOCAL),y) CSRCS += nsh_associate.c endif endif +endif + ifeq ($(CONFIG_NET_ROUTE),y) CSRCS += nsh_routecmds.c endif diff --git a/nshlib/nsh_netinit.c b/nshlib/nsh_netinit.c index 00a952877..d030bf7d4 100644 --- a/nshlib/nsh_netinit.c +++ b/nshlib/nsh_netinit.c @@ -248,11 +248,12 @@ static void nsh_netinit_configure(void) struct in_addr addr; #endif -#if defined(CONFIG_NSH_DHCPC) +#if defined(CONFIG_NSH_DHCPC) && !defined(CONFIG_NSH_NETLOCAL) FAR void *handle; #endif -#if (defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_NOMAC)) && defined(HAVE_MAC) +#if (((defined(CONFIG_NSH_DHCPC) && !defined(CONFIG_NSH_NETLOCAL)) || \ + defined(CONFIG_NSH_NOMAC)) && defined(HAVE_MAC)) #if defined(CONFIG_NET_ETHERNET) uint8_t mac[IFHWADDRLEN]; #elif defined(CONFIG_NET_6LOWPAN) @@ -358,9 +359,10 @@ static void nsh_netinit_configure(void) netlib_set_ipv4dnsaddr(&addr); #endif - /* New versions of netlib_set_ipvXaddr will not bring the network up, - * So ensure the network is really up at this point. - */ + /* That completes the 'local' initialization of the network device. */ + +#ifndef CONFIG_NSH_NETLOCAL + /* Bring the network up. */ netlib_ifup("eth0"); @@ -413,6 +415,7 @@ static void nsh_netinit_configure(void) ntpc_start(); #endif +#endif /* CONFIG_NSH_NETLOCAL */ #endif /* NSH_HAVE_NETDEV */ ninfo("Exit\n"); From 4e7b17d78307c5b47d8b7e8a531d1378fd0e52df Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 May 2017 12:05:07 -0600 Subject: [PATCH 08/14] Fix some typos in comments. --- nshlib/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nshlib/Kconfig b/nshlib/Kconfig index deb9afa4c..3337e2995 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -1014,10 +1014,10 @@ config NSH_NETLOCAL default n ---help--- If this option is selected, then NSH will only initialize the local - attributes of the network: The MAC address is needed and any IP + attributes of the network: The MAC address if needed and any IP addresses as needed. More importantly, it will not do the following: - - It will not bring the netup up. The can be done later with the + - It will not bring the network up. That can be done later with the NSH ifup command. - It will not associate any wireless devices to an access point. - It will not attempt to obtain an IP address if DHCPC is selected. @@ -1026,7 +1026,7 @@ config NSH_NETLOCAL - It will not start the NTPC daemon. This may be done later from the NSH command line with the apps/system/ntpc 'ntpcstart' command. - This option permits you to divid the network configuration into two + This option permits you to divide the network configuration into two parts: The local configuration of the network device and the dynamic configuration of the device in the network. This may be important in an environment when, for example, you need to manually scan for From d9805d38e2b98e75b3f03335ca6c5f9332ec2fcb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 May 2017 12:12:45 -0600 Subject: [PATCH 09/14] apps/system/ramtest: Make stacksize and priority conigurable. --- system/ramtest/Kconfig | 20 ++++++++++++++++++++ system/ramtest/Makefile | 22 +++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/system/ramtest/Kconfig b/system/ramtest/Kconfig index b02a9bcdb..7c78efbb9 100644 --- a/system/ramtest/Kconfig +++ b/system/ramtest/Kconfig @@ -8,3 +8,23 @@ config SYSTEM_RAMTEST default n ---help--- Enable a simple RAM test. + +if SYSTEM_RAMTEST + +config SYSTEM_RAMTEST_PROGNAME + string "Program name" + default "ramtest" + depends on BUILD_KERNEL + ---help--- + This is the name of the program that will be use when the NSH ELF + program is installed. + +config SYSTEM_RAMTEST_PRIORITY + int "RAM test task priority" + default 100 + +config SYSTEM_RAMTEST_STACKSIZE + int "RAM test stack size" + default 1024 + +endif diff --git a/system/ramtest/Makefile b/system/ramtest/Makefile index a771e57bc..bdace6b1a 100644 --- a/system/ramtest/Makefile +++ b/system/ramtest/Makefile @@ -1,7 +1,7 @@ ############################################################################ # apps/system/ramtest/Makefile # -# Copyright (C) 2013 Gregory Nutt. All rights reserved. +# Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -39,8 +39,15 @@ include $(APPDIR)/Make.defs # RAM test -PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = 768 +CONFIG_SYSTEM_RAMTEST_PRIORITY ?= SCHED_PRIORITY_DEFAULT +CONFIG_SYSTEM_RAMTEST_STACKSIZE ?= 1024 + +APPNAME = ramtest +PRIORITY = $(CONFIG_SYSTEM_RAMTEST_PRIORITY) +STACKSIZE = $(CONFIG_SYSTEM_RAMTEST_STACKSIZE) + +CONFIG_SYSTEM_RAMTEST_PROGNAME ?= ramtest$(EXEEXT) +PROGNAME = $(CONFIG_SYSTEM_RAMTEST_PROGNAME) ASRCS = CSRCS = @@ -73,9 +80,6 @@ else INSTALL_DIR = $(BIN_DIR) endif -CONFIG_XYZ_PROGNAME ?= ramtest$(EXEEXT) -PROGNAME = $(CONFIG_XYZ_PROGNAME) - ROOTDEPPATH = --dep-path . # Common build @@ -111,10 +115,10 @@ endif # Register application ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)ramtest.bdat: $(DEPCONFIG) Makefile - $(call REGISTER,"ramtest",$(PRIORITY),$(STACKSIZE),ramtest_main) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME).bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) -context: $(BUILTIN_REGISTRY)$(DELIM)ramtest.bdat +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME).bdat else context: endif From 9043459c7b24634380da1522f46c28da6ee46811 Mon Sep 17 00:00:00 2001 From: Sebastien Lorquet Date: Mon, 22 May 2017 07:34:13 -0600 Subject: [PATCH 10/14] The dedicated windows tool at APPSDIR/tools/mkkconfig.bat uses , which is not a windows shell variable, and is left uninitialized, but in fact should be the current directory. --- tools/mkkconfig.bat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/mkkconfig.bat b/tools/mkkconfig.bat index cc58b8527..e7865cca2 100755 --- a/tools/mkkconfig.bat +++ b/tools/mkkconfig.bat @@ -75,6 +75,9 @@ REM GOTO :End REM ) ) +REM Get the current directory +SET APPSDIR=%~dp0 + Echo # > %kconfig% Echo # For a description of the syntax of this configuration file, >> %kconfig% Echo # see the file kconfig-language.txt in the NuttX tools repository. >> %kconfig% @@ -89,10 +92,9 @@ IF %menu% NEQ "" ( DIR /B /A:D >_tmp_.dat -Echo source "$APPSDIR/builtin/Kconfig" >> %kconfig% FOR /F "tokens=*" %%s IN (_tmp_.dat) do ( IF EXIST %%s\Kconfig ( - Echo source "$APPSDIR/%%s/Kconfig" >> %kconfig% + Echo source "%APPSDIR%/%%s/Kconfig" >> %kconfig% ) ) DEL _tmp_.dat From ecab40da6a680df14b93d4cdb4019d508d462e4d Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sun, 4 Jun 2017 12:22:33 -0400 Subject: [PATCH 11/14] remove extra semicolons --- examples/elf/tests/helloxx/hello++2.cpp | 6 +++--- examples/elf/tests/helloxx/hello++3.cpp | 6 +++--- examples/ltdc/dma2d.c | 2 +- examples/ltdc/ltdc_main.c | 2 +- examples/nxflat/tests/hello++/hello++2.cpp | 6 +++--- examples/nxflat/tests/hello++/hello++3.cpp | 6 +++--- examples/udp/udp-server.c | 2 +- modbus/ascii/mbascii.c | 2 +- modbus/functions/mbfunccoils.c | 2 +- modbus/functions/mbfuncdisc.c | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/elf/tests/helloxx/hello++2.cpp b/examples/elf/tests/helloxx/hello++2.cpp index 5d4ba9923..b148989ca 100644 --- a/examples/elf/tests/helloxx/hello++2.cpp +++ b/examples/elf/tests/helloxx/hello++2.cpp @@ -104,12 +104,12 @@ int main(int argc, char **argv) // Tell MyThingSayer that "Hello, World!" is the string to be said - printf("main: Calling MyThingSayer->Initialize\n");; + printf("main: Calling MyThingSayer->Initialize\n"); MyThingSayer->Initialize("Hello, World!"); // Tell MyThingSayer to say the thing we told it to say - printf("main: Calling MyThingSayer->SayThing\n");; + printf("main: Calling MyThingSayer->SayThing\n"); MyThingSayer->SayThing(); // We should see the message from the destructor, @@ -118,6 +118,6 @@ int main(int argc, char **argv) printf("main: Destroying MyThingSayer\n"); delete MyThingSayer; - printf("main: Returning\n");; + printf("main: Returning\n"); return 0; } diff --git a/examples/elf/tests/helloxx/hello++3.cpp b/examples/elf/tests/helloxx/hello++3.cpp index 6661a3fd1..b59774cd4 100644 --- a/examples/elf/tests/helloxx/hello++3.cpp +++ b/examples/elf/tests/helloxx/hello++3.cpp @@ -114,12 +114,12 @@ int main(int argc, char **argv) // Tell MyThingSayer that "Hello, World!" is the string to be said - printf("main: Calling MyThingSayer.Initialize\n");; + printf("main: Calling MyThingSayer.Initialize\n"); MyThingSayer.Initialize("Hello, World!"); // Tell MyThingSayer to say the thing we told it to say - printf("main: Calling MyThingSayer.SayThing\n");; + printf("main: Calling MyThingSayer.SayThing\n"); MyThingSayer.SayThing(); // We are finished, return. We should see the message from the @@ -127,6 +127,6 @@ int main(int argc, char **argv) // message. That is proof that the C++ static destructor logic // is working - printf("main: Returning. MyThingSayer should be destroyed\n");; + printf("main: Returning. MyThingSayer should be destroyed\n"); return 0; } diff --git a/examples/ltdc/dma2d.c b/examples/ltdc/dma2d.c index ea3cc0be4..b1ffc2043 100644 --- a/examples/ltdc/dma2d.c +++ b/examples/ltdc/dma2d.c @@ -800,7 +800,7 @@ static void ltdc_dma2d_fillarea(void) active->vinfo.xres, active->vinfo.yres, ltdc_color(&active->vinfo, LTDC_BLACK)); - area.xpos = active->vinfo.xres/2;; + area.xpos = active->vinfo.xres/2; area.ypos = active->vinfo.yres/2; active->layer->fillarea(active->layer, &area, diff --git a/examples/ltdc/ltdc_main.c b/examples/ltdc/ltdc_main.c index 4c05f6587..0bc9290fc 100644 --- a/examples/ltdc/ltdc_main.c +++ b/examples/ltdc/ltdc_main.c @@ -1730,7 +1730,7 @@ FAR struct fb_cmap_s * ltdc_createcmap(uint16_t ncolors) { _err("ERROR: malloc() failed\n"); free(cmap); - return NULL;; + return NULL; } #ifdef CONFIG_FB_TRANSPARENCY diff --git a/examples/nxflat/tests/hello++/hello++2.cpp b/examples/nxflat/tests/hello++/hello++2.cpp index 1c5a11fc5..b386ba432 100644 --- a/examples/nxflat/tests/hello++/hello++2.cpp +++ b/examples/nxflat/tests/hello++/hello++2.cpp @@ -104,12 +104,12 @@ int main(int argc, char **argv) // Tell MyThingSayer that "Hello, World!" is the string to be said - printf("main: Calling MyThingSayer->Initialize\n");; + printf("main: Calling MyThingSayer->Initialize\n"); MyThingSayer->Initialize("Hello, World!"); // Tell MyThingSayer to say the thing we told it to say - printf("main: Calling MyThingSayer->SayThing\n");; + printf("main: Calling MyThingSayer->SayThing\n"); MyThingSayer->SayThing(); // We should see the message from the destructor, @@ -118,6 +118,6 @@ int main(int argc, char **argv) printf("main: Destroying MyThingSayer\n"); delete MyThingSayer; - printf("main: Returning\n");; + printf("main: Returning\n"); return 0; } diff --git a/examples/nxflat/tests/hello++/hello++3.cpp b/examples/nxflat/tests/hello++/hello++3.cpp index b115010cf..3741eecb5 100644 --- a/examples/nxflat/tests/hello++/hello++3.cpp +++ b/examples/nxflat/tests/hello++/hello++3.cpp @@ -114,12 +114,12 @@ int main(int argc, char **argv) // Tell MyThingSayer that "Hello, World!" is the string to be said - printf("main: Calling MyThingSayer.Initialize\n");; + printf("main: Calling MyThingSayer.Initialize\n"); MyThingSayer.Initialize("Hello, World!"); // Tell MyThingSayer to say the thing we told it to say - printf("main: Calling MyThingSayer.SayThing\n");; + printf("main: Calling MyThingSayer.SayThing\n"); MyThingSayer.SayThing(); // We are finished, return. We should see the message from the @@ -127,6 +127,6 @@ int main(int argc, char **argv) // message. That is proof that the C++ static destructor logic // is working - printf("main: Returning. MyThingSayer should be destroyed\n");; + printf("main: Returning. MyThingSayer should be destroyed\n"); return 0; } diff --git a/examples/udp/udp-server.c b/examples/udp/udp-server.c index 03c44e184..c9f16d571 100644 --- a/examples/udp/udp-server.c +++ b/examples/udp/udp-server.c @@ -131,7 +131,7 @@ void recv_server(void) #else server.sin_family = AF_INET; server.sin_port = HTONS(PORTNO); - server.sin_addr.s_addr = HTONL(INADDR_ANY);; + server.sin_addr.s_addr = HTONL(INADDR_ANY); addrlen = sizeof(struct sockaddr_in); #endif diff --git a/modbus/ascii/mbascii.c b/modbus/ascii/mbascii.c index f713433e8..5e8390844 100644 --- a/modbus/ascii/mbascii.c +++ b/modbus/ascii/mbascii.c @@ -420,7 +420,7 @@ bool xMBASCIIReceiveFSM(void) /* Reset the input buffers to store the frame. */ - usRcvBufferPos = 0;; + usRcvBufferPos = 0; eBytePos = BYTE_HIGH_NIBBLE; eRcvState = STATE_RX_RCV; } diff --git a/modbus/functions/mbfunccoils.c b/modbus/functions/mbfunccoils.c index 1e2f3a2cd..729e1ddf4 100644 --- a/modbus/functions/mbfunccoils.c +++ b/modbus/functions/mbfunccoils.c @@ -144,7 +144,7 @@ eMBException eMBFuncReadCoils(uint8_t *pucFrame, uint16_t *usLen) * buffer because they are still valid. */ - *usLen += ucNBytes;; + *usLen += ucNBytes; } } else diff --git a/modbus/functions/mbfuncdisc.c b/modbus/functions/mbfuncdisc.c index 00a470fda..058bdd643 100644 --- a/modbus/functions/mbfuncdisc.c +++ b/modbus/functions/mbfuncdisc.c @@ -131,7 +131,7 @@ eMBException eMBFuncReadDiscreteInputs(uint8_t *pucFrame, uint16_t *usLen) * buffer because they are still valid. */ - *usLen += ucNBytes;; + *usLen += ucNBytes; } } else From 01961a11eef6b8700537b5600e05090d3048f239 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 4 Jun 2017 14:39:41 -0600 Subject: [PATCH 12/14] Update ChangeLog in preparation for NuttX-7.21 release. --- ChangeLog.txt | 218 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 216 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 12e815832..97169f820 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -558,7 +558,7 @@ * apps/netutils/discover: Added a runtime configuration for the UDP discover utility. From Max Holtzberg (2013-5-21). * apps/examples/tcpecho: Added a simple single threaded, poll based - TCP echo server based on W. Richard Stevens UNIX Network Programming + TCP echo server based on W. Richard Stevens UNIX Network Programming Book. Contributed by Max Holtzberg (2013-5-22). * apps/examples/slcd: Add an example for testing alphanumeric, segment LCDs (2013-5-24). @@ -1867,4 +1867,218 @@ httpd_sendfile.c but It was not present in Kconfig menu. From Maciej Wójcik (2017-03-05). -7.21 2017-xx-xx Gregory Nutt +7.21 2017-06-06 Gregory Nutt + + * Add c++ platform/bambino-200e with C++ initialization. From Alan + Carvalho de Assis (2017-03-08). + * increase number of supported PWM channels from 4 to 6. From Andreas + Bihlmaier (2017-03-09). + * NSH library: In nsh_argexand(), if CONFIG_NSH_ARGCAT is defined but + CONFIG_NSH_CMDPARMS defined and/or CONFIG_DISABLE_ENVIRON not + defined, then there is a situation that causes an infinite loop in + the parser. Noted by Freddie Chopin (2017-03-09). + * apps/examples/hidkbd: Remove call to arch_usbhost_initialize(). + That is violation of the OS interfacing rules and will no longer be + supported. USB host should be initialized as part of the normal + board bring-up logic as with any other devices and should not involve + illegal calls from applications into the OS (2017-03-09). + * apps/examples/usbterm: Removed because it is not very useful and + because it can be configured to use an illegal call into the OS + (2017-03-09). + * netutils/netlib: Add one wireless IOCTL wrapper. For now, this is + just a test to be sure that the wireless IOCTL definitions are in + place (2017-03-13). + * netutils/nshlib: Add wrapper to get the wireless ESSID (2017-03-13). + * Adds a test program for the XBox One controller driver (xbc_test). + From Brian Webb (2017-03-18). + * built-in libc defect workaround: replace '%6.6u' format with an + equivalent '%06u'. From Tomasz Wozniak (2017-03-21). + * Clicker-STM32: Add platform directory w/ C++ support (2017-03-22). + * examples/ostest: Add a test of robust mutexes (2017-03-26). + * examples/ostest: Robust mutex test needs to call + pthread_mutexattr_setrobust() (2017-03-27). + * Rename CONFIG_MUTEX_TYPES to CONFIG_PTHREAD_MUTEX_TYPES (2017-03-27). + * examples/mm: Fix Makefile. Built-in was not being registered + (2017-03-28). + * nshlib: fix building when CONFIG_NET_USRSOCK enabled with other + link-layer. From Jussi Kivilinna (2017-03-31). + * Add examples/usrsocktest application for USRSOCK testing. From Jussi + Kivilinna (2017-04-03). + * NSH: Fix some warnings about integer/pointer casts of different sizes + (probably only effects 64-bit simulation) (2017-04-03). + * examples/nettest: Trying to adapt to use for testing 6loWPAN + (2017-04-03). + * examples/nettest: If doing loopback, but not using the official + loopback device, then use the server should use the configured client + IP address (2017-04-04). + * Added support for set [{+|-}{e|x|xe|ex}] [ ]. Set the + 'exit on error control' and/or 'print a trace' of commands when + parsing scripts in NSH. The settinngs are in effect from the point + of exection, until they are changed again, or in the case of the init + script, the settings are returned to the default settings when it + exits. Included child scripts will run with the parents settings and + changes made in the child script will effect the parent on return. + Use 'set -e' to enable and 'set +e' to disable (ignore) the exit + condition on commands. The default is -e. Errors cause script to + exit. Use 'set -x' to enable and 'set +x' to disable (silence) + printing a trace of the script commands as they are ececuted. The + default is +x. No printing of a trace of script commands as they are + executed. From David Sidrane (2017-04-05). + * Print expanded variables if -x. From David Sidrane (2017-04-05). + * examples/udpblaster: Several fixes to work with 6loWPAN (2017-04-06). + * examples/udpblaster: Add logic to bind the local UDP socket to a + well-known address (2017-04-06). + * 6loWPAN: Add network IOCTL support to set the node address + (2017-04-06). + * examples/ostest: Add tests for pthread_rwlock. Adding tests to be + used to verify the pthread_rwlock lock works. From Mark Schulte + (2017-04-07). + * Remove CONFIG_PTHREAD_RWLOCK. Rwlock interfaces built + unconditionally (2017-04-07). + * examples/ostest: pthread rwlock additional tests and bugfixes. From + Mark Schulte (2017-04-07). + * netutils: Add a helper function to convert a string to a 6loWPAN node + address (2017-04-08). + * NSH library: Extend ifconfig to support 6loWPAN. Adapt to some + changes in configuration variable usage (2017-04-08). + * NSH set command: Eliminate useless argc check of SCRIPTS are enabled + but ENVIRONMENT is disabled (2017-04-09). + * examples/ostest: additional test for rwlock and one for cancel + cleanup handlers. From Juha Niskanen (2017-04-10). + * wireless/wapi: Quick port of Wapi wireless services. No build + support yet. This also depends on features not supported by NuttX. + This is a work in progress (2017-04-10). + * wireless/wapi: Remove logic that depnds on Linux netlink. Add + (untested) build support (2017-04-10). + * wireless/wapi: Remove functionality that depends on the Linux + procfs: This includes only 1) listing of available interfaces and 2) + listing of all routes (2017-04-10). + * Beginning real design of wapi application based on Wapi sample code + (2017-04-10). + * wireless/wapi: Re-write of wapi tool UI (2017-04-11). + * examples/ostest: clarify when pthread clean-up test mutex need to + remain usable. From Juha Niskanen (2017-04-12). + * examples/hidkbd: Add some missing configuration settings (2017-04-18). + * NSH library: Fix open flags in nsh_codeccmd.c. From Masayuki + Ishikawa (2017-04-19). + * netlib and NSH: Add logic to set the IEEE802.15.4 PAN ID (2017-04-18). + * wireless/ieee802154: Starts framing out iwpan tool, similar in + concept to wapi. From Anthony Merlino (2017-04-20). + * ieee802154: Move non-radio files from libradio to libutils. Add + ieee802154_getpanid() (2017-04-21). + * wireless/ieee802154: Beginning of support for IEEE 802.15.4 MAC + library (2017-04-21). + * wireless/ieee802154/libmac: Finishes all defined MAC IOCTL helpers + (there are a few that are not defined) (2017-04-21). + * netlib: Get and/or set PAN ID of IEEE 802.15.4 radio (2017-04-21). + * wireless/ieee802154: libaudio and libmac need to return the correct + error codes (2017-04-22). + * nshlib: nsh_netcmds.c should include netlib.h even if neither TCP nor + UDP are enabled (2017-04-25). + * apps/wireless/wapi: Correct an error in dependency generation + (2017-04-25). + * examples: random: avoid stack overflows. From Juha Niskanen + (2017-04-26). + * wireless/wapi: Improve error reporting IOCTL failures (2017-04-26). + * I need to look at the registers that are at or around 0xe000ef90. + Using mw and xd, I see that nsh does not support pointers greater + than 0x7fffffff. A quick look at the source shows that the pointers + for those two commands are set with calls to strtol() rather than + strtoul(). Changing the two pointer-setting instances to strtoul() + fixes the problem, at least for my architecture/config. From Ian + McAfee (2017-04-26). + * NSH: Needs to include tftp.h if TFTP not disabled (2017-04-29). + * netutils/dhcpc: Make the network device name a configuration + option. Was hardcoded to eth0 but may, instead, need to be wlan0 + (2017-05-02). + * nshlib/nsh_netinit.c: If IEEE802.11 selected use wlan0 instead of + eth0 for network device name (2017-05-02). + * wireless/wext: Add drivers_wext from the WPA supplicant; Integrate + into NSH. From Simon Piriou (2017-05-02). + * 6loWPAN: Replace some Rime address naming with more consistent + short/exended address terminology (2017-05-04). + * wireless/ieee802154: Removes libradio to coincide with removal of + ioctl with radio. Moves all functionality from libradio to libmac. + From Anthony Merlino (2017-05-05). + * wireless/wapi: wpa_driver_wext_associate() now accepts a + configuration parameter that can be used to specify the wireless + properties. nshlib: NSH now has configuration options to select the + wireless properties. It builds the configuration structure and + passes this to wpa_driver_wext_associate() so that it will set the + network as configured (2017-05-06). + * Add platform files for nucleo-l452re and nucleo-l496zg. From Juha + Niskanen (2017-05-08). + * wireless/ieee802154: Adds rxonidle attribute helpers. From Anthony + Merlino (2017-05-08). + * wireless/ieee802154: Adds sniffer functionality back in to I8SAK + app. From Anthony Merlino (2017-05-08). + * NSH wireless setup: Move call to nsh_associate(). It should be + possible to associate with an AP when DHCPC is disabled (2017-05-09). + * Fix some calls to task_create(): argv[0] is the first parameter, not + the name of the task (2017-05-09). + * wireless/ieee802154: Restructures i8sak app and adds blaster + functionality. From Anthony Merlino (2017-05-09). + * examples/configdata: add stacksize and priority. From Juha Niskanen + (2017-05-10). + * Bitbucket Issue 5: I found an unexpected behavior in apps/ + configuration generation. Adding external symbolic link in apps/ + directory and using Make.defs for Kconfig generation, Kconfig file + has a wrong path in the source argument. It contains original dir + path outside of the source tree instead path to sub-directory in + apps/. The problem is connected with make/system symbolic link path + resolution. Corrected by a patch submitted by Artur Madrzak with + Issue 5 (2017-05-11). + * Bitbucket Issue 5, apps build system: The previous patch wasn't + complete, it was just idea how to resolve issue. Please, find + attached issue5.patch to resolve it. It can be applied on top current + apps/master. From Artur Madrzak (2017-05-12). + * Fix the new can.h header location. From Alan Carvalho de Assis + (2017-05-12). + * Fix libcanard github download link to get it compiling correctly. + From Alan Carvalho de Assis (2017-05-12). + * Fix to use the new canardInit() function. From Alan Carvalho de + Assis (2017-05-12). + * apps/platform: Create gnu/ subdirectory that contains the one and + only GNU C++ initialization function. Remove all other C++ + initialization functions (2017-05-13). + * Move up_cxxinitialize() prototype from nuttx/include/nuttx/arch.h to + apps/include/platform/cxxinitialize.h (2017-05-13). + * apps/examples/nettest: Fix an error in pre-processor expression + (2017-05-13). + * wireless/ieee802154: i8sak adds event handling from MAC char driver. + From Anthony Merlino (2017-05-16). + * apps/examples/mtdpart: Prevent part array overflow. mtdpart examples + create partions and allocate from 1 index not a 0 index to part[] + array. This cause buffer overflow for part array. This change fixes + this problem. From EunBong Song (2017-05-17). + * apps/examples/can: Fix can example app to print data when + CONFIG_EXAMPLE_CAN_READ is defined. From Alan Carvalho de Assis + (2017-05-17). + * apps/: Make more globals static to avoid name clashes. From Juha + Niskanen (2017-05-19). + * Ensure netlib will not be broken when setip will not bring the + network up anymore. From Sebastien Lorquet (2017-05-19). + * DHCPC: Remove hard-coded interface device. Now passed as a parameter + to dhcpc_open(). From Sebastien Lorquet (2017-05-19). + * nshlib: Fix a resource leak in cmd_hexdump(). From Nobutaka + Toyoshima (2017-05-22). + * wapi: add basic wapi_event_stream_extract implementation. From Simon + Piriou (2017-05-21). + * apps/system/dhcpc: Add a command to renew or establish a lease on an + IPv4 address (2017-05-21). + * apps/system/ntpc: Add a command to start or stop the NTPC daemon + (2017-05-21). + * apps/system/dhcpc: Add missing argument of fprintf (2017-05-21). + * apps/nshlib: Add a new option CONFIG_NSH_NETLOCAL that will suppress + some built in operations and will support manual configuration of a + wireless network (2017-05-21). + * apps/system/ramtest: Make stacksize and priority conigurable + (2017-05-22). + * nshlib: Fix a resource leak in cmd_hexdump(). From Masayuki Ishikawa + (2017-05-22). + * The dedicated windows tool at tools/mkkconfig.bat uses $APPSDIR, + which is not a windows shell variable, and is left uninitialized, but + in fact should be the current directory. From Sebastien Lorquet + (2017-05-22). + +7.22 2017-xx-xx Gregory Nutt From f3dc5bea136e39134d3961f27101da423052356b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 5 Jun 2017 15:13:36 -0600 Subject: [PATCH 13/14] Final update before 7.21 release. --- ChangeLog.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 97169f820..89a5ea318 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1867,7 +1867,7 @@ httpd_sendfile.c but It was not present in Kconfig menu. From Maciej Wójcik (2017-03-05). -7.21 2017-06-06 Gregory Nutt +7.21 2017-06-05 Gregory Nutt * Add c++ platform/bambino-200e with C++ initialization. From Alan Carvalho de Assis (2017-03-08). @@ -2002,7 +2002,8 @@ From Anthony Merlino (2017-05-05). * wireless/wapi: wpa_driver_wext_associate() now accepts a configuration parameter that can be used to specify the wireless - properties. nshlib: NSH now has configuration options to select the + properties (2017-05-06). + * nshlib: NSH now has configuration options to select the wireless properties. It builds the configuration structure and passes this to wpa_driver_wext_associate() so that it will set the network as configured (2017-05-06). @@ -2074,8 +2075,6 @@ wireless network (2017-05-21). * apps/system/ramtest: Make stacksize and priority conigurable (2017-05-22). - * nshlib: Fix a resource leak in cmd_hexdump(). From Masayuki Ishikawa - (2017-05-22). * The dedicated windows tool at tools/mkkconfig.bat uses $APPSDIR, which is not a windows shell variable, and is left uninitialized, but in fact should be the current directory. From Sebastien Lorquet From c8ae5f167405a826ed32f3a781db664f2375177e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 14 Jun 2017 12:01:13 -0600 Subject: [PATCH 14/14] platform/mikroe-stm32f4: Update for some coding standard issues. --- platform/mikroe-stm32f4/mikroe_configdata.c | 57 +++++++-------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/platform/mikroe-stm32f4/mikroe_configdata.c b/platform/mikroe-stm32f4/mikroe_configdata.c index cb58ae11b..a6b50cf68 100644 --- a/platform/mikroe-stm32f4/mikroe_configdata.c +++ b/platform/mikroe-stm32f4/mikroe_configdata.c @@ -52,26 +52,6 @@ #ifdef CONFIG_PLATFORM_CONFIGDATA -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Types - ************************************************************************************/ - -/************************************************************************************ - * Private Function Prototypes - ************************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - /************************************************************************************ * Public Functions ************************************************************************************/ @@ -109,12 +89,12 @@ int platform_setconfig(enum config_data_e id, int instance, FAR const uint8_t *configdata, size_t datalen) { #ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_FS - FILE* fd; + FILE *fd; #endif #ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_PART - struct config_data_s config; - int ret; - int fd; + struct config_data_s config; + int ret; + int fd; /* Try to open the /dev/config device file */ @@ -127,10 +107,10 @@ int platform_setconfig(enum config_data_e id, int instance, /* Setup structure for the SETCONFIG ioctl */ - config.id = (enum config_data_e)id; - config.instance = instance; + config.id = (enum config_data_e)id; + config.instance = instance; config.configdata = (FAR uint8_t *) configdata; - config.len = datalen; + config.len = datalen; ret = ioctl(fd, CFGDIOC_SETCONFIG, (unsigned long) &config); close(fd); @@ -144,11 +124,13 @@ int platform_setconfig(enum config_data_e id, int instance, #ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_FS /* Save config data in a file on the filesystem. Try to open - * the file. */ + * the file. + */ if ((fd = fopen(CONFIG_MIKROE_STM32F4_CONFIGDATA_FILENAME, "w+")) == NULL) { /* Error opening the file */ + set_errno(ENOENT); return -1; } @@ -167,7 +149,6 @@ int platform_setconfig(enum config_data_e id, int instance, return OK; #elif defined(CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM) - /* We are reading from a read-only system, so nothing to do. */ return OK; @@ -220,15 +201,17 @@ int platform_getconfig(enum config_data_e id, int instance, FAR uint8_t *configdata, size_t datalen) { #ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_FS - FILE* fd; + FILE *fd; size_t bytes; enum config_data_e saved_id; int saved_instance; #elif defined(CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM) - static const uint8_t touch_cal_data[] = { + static const uint8_t touch_cal_data[] = + { 0x9a, 0x2f, 0x00, 0x00, 0x40, 0xbc, 0x69, 0xfe, 0x70, 0x2e, 0x00, - 0x00, 0xb8, 0x2d, 0xdb, 0xff }; + 0x00, 0xb8, 0x2d, 0xdb, 0xff + }; #endif #ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_PART struct config_data_s config; @@ -256,14 +239,14 @@ int platform_getconfig(enum config_data_e id, int instance, return ret; #else /* CONFIG_MIKROE_STM32F4_CONFIGDATA_PART */ - switch (id) { case CONFIGDATA_TSCALIBRATION: #ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_FS /* Load config data fram a file on the filesystem. Try to open - * the file. */ + * the file. + */ if ((fd = fopen(CONFIG_MIKROE_STM32F4_CONFIGDATA_FILENAME, "r")) == NULL) { @@ -294,12 +277,7 @@ int platform_getconfig(enum config_data_e id, int instance, fclose(fd); return OK; - /* Save config data in a file on the filesystem */ - - return OK; - #elif defined(CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM) - memcpy(configdata, touch_cal_data, datalen); return OK; @@ -318,3 +296,4 @@ int platform_getconfig(enum config_data_e id, int instance, } #endif /* CONFIG_PLATFORM_CONFIGDATA */ +