diff --git a/configs/mikroe-stm32f4/src/stm32_appinit.c b/configs/mikroe-stm32f4/src/stm32_appinit.c index 9555caa482a..7d43cf72ed2 100644 --- a/configs/mikroe-stm32f4/src/stm32_appinit.c +++ b/configs/mikroe-stm32f4/src/stm32_appinit.c @@ -56,7 +56,7 @@ #endif #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_MIKROE_FLASH_CONFIG_PART @@ -347,7 +347,7 @@ int board_app_initialize(uintptr_t arg) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/olimex-lpc-h3131/src/lpc31_appinit.c b/configs/olimex-lpc-h3131/src/lpc31_appinit.c index 0f5d825da51..0a40bb902c8 100644 --- a/configs/olimex-lpc-h3131/src/lpc31_appinit.c +++ b/configs/olimex-lpc-h3131/src/lpc31_appinit.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include "lpc31.h" @@ -137,7 +137,7 @@ int board_app_initialize(uintptr_t arg) /* Start the USB Monitor */ syslog(LOG_ERR, "ERROR: Failed to start the USB monitor\n"); - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/olimex-stm32-e407/src/stm32_appinit.c b/configs/olimex-stm32-e407/src/stm32_appinit.c index c4a53bb8171..c7715a95b2a 100644 --- a/configs/olimex-stm32-e407/src/stm32_appinit.c +++ b/configs/olimex-stm32-e407/src/stm32_appinit.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_STM32_OTGFS @@ -225,7 +225,7 @@ int board_app_initialize(uintptr_t arg) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/olimex-stm32-h405/src/stm32_appinit.c b/configs/olimex-stm32-h405/src/stm32_appinit.c index 57a5902a97f..ed8b8fe846b 100644 --- a/configs/olimex-stm32-h405/src/stm32_appinit.c +++ b/configs/olimex-stm32-h405/src/stm32_appinit.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_STM32_OTGFS diff --git a/configs/olimex-stm32-h407/src/stm32_appinit.c b/configs/olimex-stm32-h407/src/stm32_appinit.c index ffbf9cecc90..d87ae0670ab 100644 --- a/configs/olimex-stm32-h407/src/stm32_appinit.c +++ b/configs/olimex-stm32-h407/src/stm32_appinit.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_STM32_OTGFS diff --git a/configs/olimex-stm32-h407/src/stm32_bringup.c b/configs/olimex-stm32-h407/src/stm32_bringup.c index 687d7e18721..73e29d5037f 100644 --- a/configs/olimex-stm32-h407/src/stm32_bringup.c +++ b/configs/olimex-stm32-h407/src/stm32_bringup.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_STM32_OTGFS @@ -152,7 +152,7 @@ int stm32_bringup(void) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, diff --git a/configs/olimex-stm32-p207/src/stm32_appinit.c b/configs/olimex-stm32-p207/src/stm32_appinit.c index f59f6454b6d..fa3fce23f29 100644 --- a/configs/olimex-stm32-p207/src/stm32_appinit.c +++ b/configs/olimex-stm32-p207/src/stm32_appinit.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_STM32_OTGFS @@ -172,7 +172,7 @@ int board_app_initialize(uintptr_t arg) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/olimexino-stm32/src/stm32_appinit.c b/configs/olimexino-stm32/src/stm32_appinit.c index 9b01c2f2b0d..c0e50597f7f 100644 --- a/configs/olimexino-stm32/src/stm32_appinit.c +++ b/configs/olimexino-stm32/src/stm32_appinit.c @@ -50,7 +50,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_USBDEV diff --git a/configs/sam4e-ek/src/sam_appinit.c b/configs/sam4e-ek/src/sam_appinit.c index bc8b2b1a8fd..aed2a31361d 100644 --- a/configs/sam4e-ek/src/sam_appinit.c +++ b/configs/sam4e-ek/src/sam_appinit.c @@ -49,7 +49,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include "sam4e-ek.h" @@ -118,7 +118,7 @@ int board_app_initialize(uintptr_t arg) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/sam4s-xplained-pro/src/sam_appinit.c b/configs/sam4s-xplained-pro/src/sam_appinit.c index 8996207425c..7ac7f1587c4 100644 --- a/configs/sam4s-xplained-pro/src/sam_appinit.c +++ b/configs/sam4s-xplained-pro/src/sam_appinit.c @@ -64,7 +64,7 @@ #endif #ifdef CONFIG_USBMONITOR -# include +# include #endif #include "sam4s-xplained-pro.h" @@ -169,7 +169,7 @@ int board_app_initialize(uintptr_t arg) /* Start the USB Monitor */ syslog(LOG_INFO, "Starting USB Monitor\n"); - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d (%d)\n", ret, errno); diff --git a/configs/sama5d3-xplained/src/sam_appinit.c b/configs/sama5d3-xplained/src/sam_appinit.c index 71ee50f95fa..34073c9f177 100644 --- a/configs/sama5d3-xplained/src/sam_appinit.c +++ b/configs/sama5d3-xplained/src/sam_appinit.c @@ -49,7 +49,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include "sama5d3-xplained.h" @@ -155,7 +155,7 @@ int board_app_initialize(uintptr_t arg) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/sama5d3x-ek/src/sam_appinit.c b/configs/sama5d3x-ek/src/sam_appinit.c index 18344746a82..b3fb39f6760 100644 --- a/configs/sama5d3x-ek/src/sam_appinit.c +++ b/configs/sama5d3x-ek/src/sam_appinit.c @@ -49,7 +49,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include "sama5d3x-ek.h" @@ -170,7 +170,7 @@ int board_app_initialize(uintptr_t arg) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Start USB monitor: %d\n", ret); diff --git a/configs/sama5d4-ek/src/sam_bringup.c b/configs/sama5d4-ek/src/sam_bringup.c index d5b78e608c3..831dc06da75 100644 --- a/configs/sama5d4-ek/src/sam_bringup.c +++ b/configs/sama5d4-ek/src/sam_bringup.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include @@ -286,7 +286,7 @@ int sam_bringup(void) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { _err("ERROR: Failed to start the USB monitor: %d\n", ret); diff --git a/configs/same70-xplained/src/sam_bringup.c b/configs/same70-xplained/src/sam_bringup.c index 8c89b0989eb..3ac5d205858 100644 --- a/configs/same70-xplained/src/sam_bringup.c +++ b/configs/same70-xplained/src/sam_bringup.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include @@ -311,7 +311,7 @@ int sam_bringup(void) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { _err("ERROR: Failed to start the USB monitor: %d\n", ret); diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index c984b467631..845e00df9a2 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include @@ -477,7 +477,7 @@ int sam_bringup(void) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { _err("ERROR: Failed to start the USB monitor: %d\n", ret); diff --git a/configs/spark/src/stm32_appinit.c b/configs/spark/src/stm32_appinit.c index 213d15726fc..1b484caa489 100644 --- a/configs/spark/src/stm32_appinit.c +++ b/configs/spark/src/stm32_appinit.c @@ -55,7 +55,7 @@ #endif #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_USBDEV @@ -305,7 +305,7 @@ int board_app_initialize(uintptr_t arg) /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/spark/src/stm32_composite.c b/configs/spark/src/stm32_composite.c index 0e36df9a6a0..2c50a59a1f8 100644 --- a/configs/spark/src/stm32_composite.c +++ b/configs/spark/src/stm32_composite.c @@ -55,7 +55,7 @@ #endif #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifdef CONFIG_USBDEV @@ -269,7 +269,7 @@ static int stm32_composite_initialize(void) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { ferr("ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/stm32f3discovery/src/stm32_appinit.c b/configs/stm32f3discovery/src/stm32_appinit.c index a865d6fd9c7..c95837c9c52 100644 --- a/configs/stm32f3discovery/src/stm32_appinit.c +++ b/configs/stm32f3discovery/src/stm32_appinit.c @@ -47,7 +47,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include "stm32.h" @@ -120,7 +120,7 @@ int board_app_initialize(uintptr_t arg) /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/stm32f429i-disco/src/stm32_appinit.c b/configs/stm32f429i-disco/src/stm32_appinit.c index ad2f7826fe4..415884fa5bf 100644 --- a/configs/stm32f429i-disco/src/stm32_appinit.c +++ b/configs/stm32f429i-disco/src/stm32_appinit.c @@ -56,7 +56,7 @@ #endif #ifdef CONFIG_USBMONITOR -# include +# include #endif #ifndef CONFIG_STM32F429I_DISCO_FLASH_MINOR @@ -371,7 +371,7 @@ int board_app_initialize(uintptr_t arg) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/stm32f4discovery/src/stm32_bringup.c b/configs/stm32f4discovery/src/stm32_bringup.c index d924dc8e1ea..a6aec33f857 100644 --- a/configs/stm32f4discovery/src/stm32_bringup.c +++ b/configs/stm32f4discovery/src/stm32_bringup.c @@ -46,7 +46,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include @@ -151,7 +151,7 @@ int stm32_bringup(void) #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); if (ret != OK) { uerr("ERROR: Failed to start USB monitor: %d\n", ret); diff --git a/configs/sure-pic32mx/src/pic32mx_appinit.c b/configs/sure-pic32mx/src/pic32mx_appinit.c index 22425adac4b..ae36428317f 100644 --- a/configs/sure-pic32mx/src/pic32mx_appinit.c +++ b/configs/sure-pic32mx/src/pic32mx_appinit.c @@ -52,7 +52,7 @@ #include #ifdef CONFIG_USBMONITOR -# include +# include #endif #include "pic32mx.h" @@ -415,7 +415,7 @@ int board_app_initialize(uintptr_t arg) { /* Start the USB Monitor */ - ret = usbmonitor_start(0, NULL); + ret = usbmonitor_start(); } #endif diff --git a/drivers/Kconfig b/drivers/Kconfig index 26f9f36a6fd..bc506ee1e00 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -515,10 +515,14 @@ if USBHOST source drivers/usbhost/Kconfig endif # USBHOST +config HAVE_USBTRACE + bool + default n + menuconfig USBMONITOR bool "USB Monitor" default n - depends on (USBDEV && USBDEV_TRACE) || (USBHOST && USBHOST_TRACE) + depends on HAVE_USBTRACE ---help--- If USB device tracing (USBDEV_TRACE) AND/OR USB host tracing (USBHOST_TRACE) are enabled then this option will select the USB @@ -527,7 +531,7 @@ menuconfig USBMONITOR if USBMONITOR source drivers/usbmonitor/Kconfig -endif +endif # USBMONITOR menuconfig DRIVERS_WIRELESS bool "Wireless Device Support" diff --git a/drivers/Makefile b/drivers/Makefile index 224cd78f6e5..ff0a00b5b5a 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -73,6 +73,7 @@ include syslog$(DELIM)Make.defs include timers$(DELIM)Make.defs include usbdev$(DELIM)Make.defs include usbhost$(DELIM)Make.defs +include usbmonitor$(DELIM)Make.defs include video$(DELIM)Make.defs include wireless$(DELIM)Make.defs diff --git a/drivers/usbdev/Kconfig b/drivers/usbdev/Kconfig index efcf0def0bd..f68b2be67f3 100644 --- a/drivers/usbdev/Kconfig +++ b/drivers/usbdev/Kconfig @@ -91,6 +91,7 @@ config ARCH_USBDEV_STALLQUEUE menuconfig USBDEV_TRACE bool "Enable USB tracing for debug" default n + select HAVE_USBTRACE ---help--- Enables USB tracing for debug diff --git a/drivers/usbhost/Kconfig b/drivers/usbhost/Kconfig index 4e9c024c615..e8768896901 100644 --- a/drivers/usbhost/Kconfig +++ b/drivers/usbhost/Kconfig @@ -508,6 +508,7 @@ endif # USBHOST_RTL8187 config USBHOST_TRACE bool "Enable USB HCD tracing for debug" default n + select HAVE_USBTRACE ---help--- Enables USB tracing for debug. Only supported for the HCD and, further, no supported by all HCD implementations. diff --git a/drivers/usbmonitor/usbmonitor.c b/drivers/usbmonitor/usbmonitor.c index d0339f4e3e5..22e34ed5e49 100644 --- a/drivers/usbmonitor/usbmonitor.c +++ b/drivers/usbmonitor/usbmonitor.c @@ -188,7 +188,21 @@ static int usbmonitor_daemon(int argc, char **argv) * Public Functions ****************************************************************************/ -int usbmonitor_start(int argc, char **argv) +/**************************************************************************** + * Name: usbmonitor_start + * + * Start the USB monitor kernal daemon. + * + * Input Parameters: + * None + * + * Returned values: + * Zero (OK) is returned on success; a negated errno value is return on + * any failure. + * + ****************************************************************************/ + +int usbmonitor_start(void) { /* Has the monitor already started? */ @@ -237,7 +251,21 @@ int usbmonitor_start(int argc, char **argv) return 0; } -int usbmonitor_stop(int argc, char **argv) +/**************************************************************************** + * Name: usbmonitor_stop + * + * Stop the USB monitor kernel daemon. + * + * Input Parameters: + * None + * + * Returned values: + * Zero (OK) is returned on success; a negated errno value is return on + * any failure. + * + ****************************************************************************/ + +int usbmonitor_stop(void) { /* Has the monitor already started? */ diff --git a/include/nuttx/usb/usbmonitor.h b/include/nuttx/usb/usbmonitor.h new file mode 100644 index 00000000000..d5be243e054 --- /dev/null +++ b/include/nuttx/usb/usbmonitor.h @@ -0,0 +1,90 @@ +/**************************************************************************** + * include/nuttx/usb/usbmonitor.h + * + * Copyright (C) 2013, 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. + * + ****************************************************************************/ + +#ifndef __INCLUDE_NUTTX_USB_USBMONITOR_H +#define __INCLUDE_NUTTX_USB_USBMONITOR_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifdef CONFIG_USBMONITOR + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: usbmonitor_start and usbmonitor_stop + * + * Start and stop the USB monitor kernel deamon. + * + * Input Parameters: + * None + * + * Returned values: + * Zero (OK) is returned on success; a negated errno value is return on + * any failure. + * + ****************************************************************************/ + +int usbmonitor_start(void); +int usbmonitor_stop(void); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_USBMONITOR */ +#endif /* __INCLUDE_NUTTX_USB_USBMONITOR_H */