summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-26 18:05:26 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-26 18:05:26 +0000
commit1caf0a84f85f55d2d34066797cd46ecea8c7627e (patch)
tree79d45d0fafaa9a0386e6c52ebcef2fc2d09233d4 /apps
parent43a2d9869b3d779403c65fa99a8ba820af57ffa9 (diff)
downloadnuttx-1caf0a84f85f55d2d34066797cd46ecea8c7627e.tar.gz
nuttx-1caf0a84f85f55d2d34066797cd46ecea8c7627e.tar.bz2
nuttx-1caf0a84f85f55d2d34066797cd46ecea8c7627e.zip
Add support for the USB trace cability in NSH when a USB console is used
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4774 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps')
-rwxr-xr-xapps/ChangeLog.txt2
-rw-r--r--apps/examples/usbserial/main.c2
-rw-r--r--apps/nshlib/README.txt21
-rw-r--r--apps/nshlib/nsh.h53
-rw-r--r--apps/nshlib/nsh_consolemain.c4
-rw-r--r--apps/nshlib/nsh_usbdev.c35
6 files changed, 102 insertions, 15 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index acdd387af..9f5d7f71e 100755
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -237,3 +237,5 @@
* apps/nshlib/nsh_usbdev.c: User now has to press ENTER 3 times before
USB console will start. Otherwise, the USB console starts before there
is anyone at the other end to listen.
+ * apps/nshilib/nsh_usbdev.c and nsh_consolemain.c: Add support for the USB
+ capability when a USB console is used.
diff --git a/apps/examples/usbserial/main.c b/apps/examples/usbserial/main.c
index eea905c98..4e59c1ece 100644
--- a/apps/examples/usbserial/main.c
+++ b/apps/examples/usbserial/main.c
@@ -71,6 +71,7 @@
# define COUNTER_NEEDED 1
# endif
#endif
+
#ifdef CONFIG_EXAMPLES_USBSERIAL_TRACEINIT
# define TRACE_INIT_BITS (TRACE_INIT_BIT)
#else
@@ -106,7 +107,6 @@
#define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\
TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS)
-
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lib_lowprintf(__VA_ARGS__)
diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt
index 42e831ddc..4f2a27239 100644
--- a/apps/nshlib/README.txt
+++ b/apps/nshlib/README.txt
@@ -935,13 +935,20 @@ NSH-Specific Configuration Settings
CONFIG_NSH_UBSDEV_MINOR
The minor device number of the USB device. Default: 0
- If USB tracing is enabled, then NSH will initialize USB
- tracing as requested by the following:
-
- CONFIG_NSH_UBSDEV_TRACEINIT
- Bit set with each bit enabling a trace option (see
- include/nuttx/usb/usbdev_trace.h). Default: Only USB errors
- are traced.
+ If USB tracing is enabled (CONFIG_USBDEV_TRACE), then NSH will
+ initialize USB tracing as requested by the following. Default:
+ Only USB errors are traced.
+
+ CONFIG_NSH_USBDEV_TRACEINIT
+ Show initialization events
+ CONFIG_NSH_USBDEV_TRACECLASS
+ Show class driver events
+ CONFIG_NSH_USBDEV_TRACETRANSFERS
+ Show data transfer events
+ CONFIG_NSH_USBDEV_TRACECONTROLLER
+ Show controller events
+ CONFIG_NSH_USBDEV_TRACEINTERRUPTS
+ Show interrupt-related events.
* CONFIG_NSH_CONDEV
If CONFIG_NSH_CONSOLE is set to 'y', then CONFIG_NSH_CONDEV
diff --git a/apps/nshlib/nsh.h b/apps/nshlib/nsh.h
index babdedd91..e31fa20f1 100644
--- a/apps/nshlib/nsh.h
+++ b/apps/nshlib/nsh.h
@@ -109,17 +109,50 @@
# define CONFIG_NSH_UBSDEV_MINOR 0
# endif
-/* USB trace settings */
-
-# ifndef CONFIG_NSH_UBSDEV_TRACEINIT
-# define CONFIG_NSH_UBSDEV_TRACEINIT (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
-# endif
-
/* The default console device is always /dev/console */
# ifndef CONFIG_NSH_USBCONDEV
# define CONFIG_NSH_USBCONDEV "/dev/console"
# endif
+
+/* USB trace settings */
+
+#ifdef CONFIG_NSH_USBDEV_TRACEINIT
+# define TRACE_INIT_BITS (TRACE_INIT_BIT)
+#else
+# define TRACE_INIT_BITS (0)
+#endif
+
+#define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
+
+#ifdef CONFIG_NSH_USBDEV_TRACECLASS
+# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|TRACE_CLASSSTATE_BIT)
+#else
+# define TRACE_CLASS_BITS (0)
+#endif
+
+#ifdef CONFIG_NSH_USBDEV_TRACETRANSFERS
+# define TRACE_TRANSFER_BITS (TRACE_OUTREQQUEUED_BIT|TRACE_INREQQUEUED_BIT|TRACE_READ_BIT|\
+ TRACE_WRITE_BIT|TRACE_COMPLETE_BIT)
+#else
+# define TRACE_TRANSFER_BITS (0)
+#endif
+
+#ifdef CONFIG_NSH_USBDEV_TRACECONTROLLER
+# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT)
+#else
+# define TRACE_CONTROLLER_BITS (0)
+#endif
+
+#ifdef CONFIG_NSH_USBDEV_TRACEINTERRUPTS
+# define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|TRACE_INTEXIT_BIT)
+#else
+# define TRACE_INTERRUPT_BITS (0)
+#endif
+
+#define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\
+ TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS)
+
#endif
/* If Telnet is selected for the NSH console, then we must configure
@@ -400,6 +433,14 @@ void nsh_freefullpath(char *relpath);
void nsh_dumpbuffer(FAR struct nsh_vtbl_s *vtbl, const char *msg,
const uint8_t *buffer, ssize_t nbytes);
+/* USB debug support */
+
+#if defined(CONFIG_USBDEV_TRACE) && defined(HAVE_USB_CONSOLE)
+void nsh_usbtrace(void);
+#else
+# define nsh_usbtrace()
+#endif
+
/* Shell command handlers */
#ifndef CONFIG_NSH_DISABLE_ECHO
diff --git a/apps/nshlib/nsh_consolemain.c b/apps/nshlib/nsh_consolemain.c
index a6e28c051..baf2e74b4 100644
--- a/apps/nshlib/nsh_consolemain.c
+++ b/apps/nshlib/nsh_consolemain.c
@@ -124,6 +124,10 @@ int nsh_consolemain(int argc, char *argv[])
for (;;)
{
+ /* For the case of debugging the USB console... dump collected USB trace data */
+
+ nsh_usbtrace();
+
/* Display the prompt string */
fputs(g_nshprompt, pstate->cn_outstream);
diff --git a/apps/nshlib/nsh_usbdev.c b/apps/nshlib/nsh_usbdev.c
index 40e35d5f4..3d123532a 100644
--- a/apps/nshlib/nsh_usbdev.c
+++ b/apps/nshlib/nsh_usbdev.c
@@ -44,6 +44,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
+#include <debug.h>
#ifdef CONFIG_CDCACM
# include <nuttx/usb/cdcacm.h>
@@ -61,6 +62,12 @@
* Definitions
****************************************************************************/
+#if defined(CONFIG_DEBUG) || defined(CONFIG_NSH_USBCONSOLE)
+# define trmessage lib_lowprintf
+#else
+# define trmessage printf
+#endif
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -82,6 +89,18 @@
****************************************************************************/
/****************************************************************************
+ * Name: nsh_tracecallback
+ ****************************************************************************/
+
+#ifdef CONFIG_USBDEV_TRACE
+static int nsh_tracecallback(struct usbtrace_s *trace, void *arg)
+{
+ usbtrace_trprintf((trprintf_t)trmessage, trace->event, trace->value);
+ return 0;
+}
+#endif
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -100,7 +119,9 @@ int nsh_usbconsole(void)
/* Initialize any USB tracing options that were requested */
- usbtrace_enable(CONFIG_NSH_UBSDEV_TRACEINIT);
+#ifdef CONFIG_USBDEV_TRACE
+ usbtrace_enable(TRACE_BITSET);
+#endif
/* Don't start the NSH console until the console device is ready. Chances
* are, we get here with no functional console. The USB console will not
@@ -207,4 +228,16 @@ int nsh_usbconsole(void)
}
#endif /* HAVE_USB_CONSOLE */
+
+/****************************************************************************
+ * Name: nsh_usbtrace
+ ****************************************************************************/
+
+#if defined(CONFIG_USBDEV_TRACE) && defined(HAVE_USB_CONSOLE)
+void nsh_usbtrace(void)
+{
+ (void)usbtrace_enumerate(nsh_tracecallback, NULL);
+}
+#endif
+
#endif /* CONFIG_USBDEV */