diff --git a/configs/stm32f4discovery/src/up_nsh.c b/configs/stm32f4discovery/src/up_nsh.c index b395d660d25..4edf9329173 100644 --- a/configs/stm32f4discovery/src/up_nsh.c +++ b/configs/stm32f4discovery/src/up_nsh.c @@ -79,7 +79,7 @@ # undef HAVE_USBMONITOR #endif -/* Can't support USB device is USB device is not enabled */ +/* Can't support USB device monitor if USB device is not enabled */ #ifndef CONFIG_USBDEV # undef HAVE_USBDEV diff --git a/configs/sure-pic32mx/README.txt b/configs/sure-pic32mx/README.txt index 599acb720a9..7592538ff5e 100644 --- a/configs/sure-pic32mx/README.txt +++ b/configs/sure-pic32mx/README.txt @@ -30,6 +30,11 @@ DB-DP11212 PIC32 General Purpose Demo Board - Three tactile switches - Four user LEDs +NOTE: I see that Sure Electronics shows both of these boards at end-of-Life +(EOL). So I assume that these boards will no longer be generally available. +This work should still be useful, however, for other PIC32MX4-based boards +(2012-5-27). + Contents ======== @@ -880,7 +885,40 @@ Where is one of the following: CONFIG_UART2_RXBUFSIZE=64 CONFIG_UART2_TXBUFSIZE=64 - 5. If you want to try this configuration on the DB-DP11212 PIC32 General + NOTE: Using the SYSLOG to get debug output has limitations. Among + those are that you cannot get debug output from interrupt handlers. + So, in particularly, debug output is not a useful way to debug the + USB device controller driver. Instead, use the USB monitor with + USB debug off and USB trance on (see below). + + 5. Enabling USB monitor SYSLOG output. If tracing is enabled, the USB + device will save encoded trace output in in-memory buffer; if the + USB monitor is enabled, that trace buffer will be periodically + emptied and dumped to the system logging device (UART2 in this + configuraion): + + Device Drivers -> "USB Device Driver Support: + CONFIG_USBDEV_TRACE=y : Enable USB trace feature + CONFIG_USBDEV_TRACE_NRECORDS=256 : Buffer 128 records in memory + + Application Configuration -> NSH LIbrary: + CONFIG_NSH_USBDEV_TRACE=n : No builtin tracing from NSH + CONFIG_NSH_ARCHINIT=y : Automatically start the USB monitor + + Application Configuration -> System NSH Add-Ons: + CONFIG_SYSTEM_USBMONITOR=y : Enable the USB monitor daemon + CONFIG_SYSTEM_USBMONITOR_STACKSIZE=2048 : USB monitor daemon stack size + CONFIG_SYSTEM_USBMONITOR_PRIORITY=50 : USB monitor daemon priority + CONFIG_SYSTEM_USBMONITOR_INTERVAL=1 : Dump trace data every second + CONFIG_SYSTEM_USBMONITOR_TRACEINIT=y : Enable TRACE output + CONFIG_SYSTEM_USBMONITOR_TRACECLASS=y + CONFIG_SYSTEM_USBMONITOR_TRACETRANSFERS=y + CONFIG_SYSTEM_USBMONITOR_TRACECONTROLLER=y + CONFIG_SYSTEM_USBMONITOR_TRACEINTERRUPTS=y + + NOTE: USB debug output should not be enabled in this case. + + 6. If you want to try this configuration on the DB-DP11212 PIC32 General Purpose Demo Board", here are the changes that you should make: Board Configuration: @@ -892,29 +930,3 @@ Where is one of the following: Device Drivers -> System Logging Device Options: CONFIG_SYSLOG=n : Disable SYSLOG output - - 6. Enabling USB monitor SYSLOG output. If tracing is enabled, the USB - device will save encoded trace output in in-memory buffer; if the - USB monitor is enabled, that trace buffer will be periodically - emptied and dumped to the system loggin device (UART2 in this - configuraion): - - - Device Drivers -> "USB Device Driver Support: - CONFIG_USBDEV_TRACE=y : Enable USB trace feature - CONFIG_USBDEV_TRACE_NRECORDS=128 : Buffer 128 records in memory - - Application Configuration -> NSH LIbrary: - CONFIG_NSH_USBDEV_TRACE=n : No builtin tracing from NSH - CONFIG_NSH_ARCHINIT=y : Automatically start the USB monitor - - Application Configuration -> System NSH Add-Ons: - CONFIG_SYSTEM_USBMONITOR=y : Enable the USB monitor daemon - CONFIG_SYSTEM_USBMONITOR_STACKSIZE=2048 : USB monitor daemon stack size - CONFIG_SYSTEM_USBMONITOR_PRIORITY=50 : USB monitor daemon priority - CONFIG_SYSTEM_USBMONITOR_INTERVAL=2 : Dump trace data every 2 seconds - CONFIG_SYSTEM_USBMONITOR_TRACEINIT=y : Enable TRACE output - CONFIG_SYSTEM_USBMONITOR_TRACECLASS=y - CONFIG_SYSTEM_USBMONITOR_TRACETRANSFERS=y - CONFIG_SYSTEM_USBMONITOR_TRACECONTROLLER=y - CONFIG_SYSTEM_USBMONITOR_TRACEINTERRUPTS=y diff --git a/configs/sure-pic32mx/src/pic32mx_nsh.c b/configs/sure-pic32mx/src/pic32mx_nsh.c index 9aef56313a2..1145ff6d586 100644 --- a/configs/sure-pic32mx/src/pic32mx_nsh.c +++ b/configs/sure-pic32mx/src/pic32mx_nsh.c @@ -49,6 +49,10 @@ #include #include +#ifdef CONFIG_SYSTEM_USBMONITOR +# include +#endif + #include "pic32mx-internal.h" #include "sure-pic32mx.h" @@ -60,24 +64,25 @@ /* PORT and SLOT number probably depend on the board configuration */ -#define NSH_HAVEMMCSD 1 -#define NSH_HAVEUSBHOST 1 +#define NSH_HAVE_MMCSD 1 +#define NSH_HAVE_USBHOST 1 +#define NSH_HAVE_USBMONITOR 1 /* Can't support MMC/SD if SPI2 is not enabled */ #ifndef CONFIG_PIC32MX_SPI2 -# undef NSH_HAVEMMCSD +# undef NSH_HAVE_MMCSD #endif /* Can't support MMC/SD features if mountpoints are disabled */ #if defined(CONFIG_DISABLE_MOUNTPOINT) -# undef NSH_HAVEMMCSD +# undef NSH_HAVE_MMCSD #endif /* MMC/SD configuration */ -#ifdef NSH_HAVEMMCSD +#ifdef NSH_HAVE_MMCSD # if !defined(CONFIG_NSH_MMCSDSPIPORTNO) || CONFIG_NSH_MMCSDSPIPORTNO != 2 # warning "The Sure PIC32MX MMC/SD is on SPI2" # undef CONFIG_NSH_MMCSDSPIPORTNO @@ -110,10 +115,10 @@ #endif #if !defined(CONFIG_USBHOST) || !defined(CONFIG_PIC32MX_USBHOST) -# undef NSH_HAVEUSBHOST +# undef NSH_HAVE_USBHOST #endif -#ifdef NSH_HAVEUSBHOST +#ifdef NSH_HAVE_USBHOST # ifndef CONFIG_USBHOST_DEFPRIO # define CONFIG_USBHOST_DEFPRIO 50 # endif @@ -122,6 +127,20 @@ # endif #endif +/* USB Monitor */ + +/* Can't support USB device monitor if USB device is not enabled */ + +#ifndef CONFIG_USBDEV +# undef NSH_HAVE_USBMONITOR +#endif + +/* Check if we should enable the USB monitor before starting NSH */ + +#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_SYSTEM_USBMONITOR) +# undef NSH_HAVE_USBMONITOR +#endif + /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS @@ -142,7 +161,7 @@ * Private Data ****************************************************************************/ -#ifdef NSH_HAVEUSBHOST +#ifdef NSH_HAVE_USBHOST static struct usbhost_driver_s *g_drvr; #endif @@ -158,7 +177,7 @@ static struct usbhost_driver_s *g_drvr; * ****************************************************************************/ -#ifdef NSH_HAVEUSBHOST +#ifdef NSH_HAVE_USBHOST static int nsh_waiter(int argc, char *argv[]) { bool connected = false; @@ -199,7 +218,7 @@ static int nsh_waiter(int argc, char *argv[]) * ****************************************************************************/ -#ifdef NSH_HAVEMMCSD +#ifdef NSH_HAVE_MMCSD static int nsh_sdinitialize(void) { FAR struct spi_dev_s *spi; @@ -261,7 +280,7 @@ errout: * ****************************************************************************/ -#ifdef NSH_HAVEUSBHOST +#ifdef NSH_HAVE_USBHOST static int nsh_usbhostinitialize(void) { int pid; @@ -368,5 +387,14 @@ int nsh_archinitialize(void) ret = nsh_usbdevinitialize(); } +#ifdef NSH_HAVE_USBMONITOR + if (ret == OK) + { + /* Start the USB Monitor */ + + ret = usbmonitor_start(0, NULL); + } +#endif + return ret; }