forked from Archive/PX4-Autopilot
Add support for the USB trace cability in NSH when a USB console is used
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4774 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
parent
7b37a5a7ba
commit
516a0a7adb
|
@ -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.
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -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:
|
||||
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_UBSDEV_TRACEINIT
|
||||
Bit set with each bit enabling a trace option (see
|
||||
include/nuttx/usb/usbdev_trace.h). 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
****************************************************************************/
|
||||
|
@ -81,6 +88,18 @@
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
||||
|
|
|
@ -2218,13 +2218,28 @@ nsh>
|
|||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
If USB tracing is enabled, then NSH will initialize USB tracing as requested by the following:
|
||||
If USB tracing is enabled (<code>CONFIG_USBDEV_TRACE</code>), then NSH will initialize USB tracing as requested by the following.
|
||||
Default: Only USB errors are traced.
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<code>CONFIG_NSH_UBSDEV_TRACEINIT</code>.
|
||||
Bit set with each bit enabling a trace option (see <code>include/nuttx/usb/usbdev_trace.h</code>).
|
||||
Default: Only USB errors are traced.
|
||||
<code>CONFIG_NSH_USBDEV_TRACEINIT</code>.
|
||||
Show initialization events
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NSH_USBDEV_TRACECLASS</code>.
|
||||
Show class driver events
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NSH_USBDEV_TRACETRANSFERS</code>.
|
||||
Show data transfer events
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NSH_USBDEV_TRACECONTROLLER</code>.
|
||||
Show controller events
|
||||
<li>
|
||||
<code>CONFIG_NSH_USBDEV_TRACEINTERRUPTS</code>.
|
||||
Show interrupt-related events.
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
|
|
|
@ -1018,7 +1018,7 @@ Where <subdir> is one of the following:
|
|||
However, that configuration does not work. It fails early probably because
|
||||
of some dependency on /dev/console before the USB connection is established.
|
||||
|
||||
But there is a work around for this that does work fine (but has some side
|
||||
But there is a work around for this that works better (but has some side
|
||||
effects). The following configuration will also create a NSH USB console
|
||||
but this version will will use /dev/console. Instead, it will use the
|
||||
normal /dev/ttyACM0 USB serial device for the console:
|
||||
|
@ -1033,16 +1033,20 @@ Where <subdir> is one of the following:
|
|||
|
||||
CONFIG_NSH_USBCONDEV="/dev/ttyACM0"
|
||||
|
||||
NOTE 1: When you first start the USB console, you have hit ENTER a few
|
||||
times before NSH starts. The logic does this to prevent sending USB data
|
||||
before there is anything on the host side listening for USB serial input.
|
||||
|
||||
Now the side effects:
|
||||
|
||||
NOTE 1. When any other device other than /dev/console is used for a user
|
||||
NOTE 2. When any other device other than /dev/console is used for a user
|
||||
interface, linefeeds (\n) will not be expanded to carriage return /
|
||||
linefeeds (\r\n). You will need to set your terminal program to account
|
||||
for this.
|
||||
|
||||
NOTE 2: /dev/console still exists and still refers to the serial port. So
|
||||
NOTE 3: /dev/console still exists and still refers to the serial port. So
|
||||
you can still use certain kinds of debug output (see include/debug.h, all
|
||||
of the interfaces based on lib_lowprintf will work in this configraration).
|
||||
of the interfaces based on lib_lowprintf will work in this configuration).
|
||||
|
||||
nxlines:
|
||||
------
|
||||
|
|
|
@ -1222,8 +1222,16 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3
|
|||
# readable/write-able USB driver such as: CONFIG_NSH_USBCONDEV="/dev/ttyACM0".
|
||||
# CONFIG_NSH_UBSDEV_MINOR - The minor device number of the USB device.
|
||||
# Default: 0
|
||||
# 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.
|
||||
# CONFIG_NSH_USBDEV_TRACEINIT - Is using a USB console and CONFIG_USB_TRACE
|
||||
# is defined, this will show initialization events
|
||||
# CONFIG_NSH_USBDEV_TRACECLASS - Is using a USB console and CONFIG_USB_TRACE
|
||||
# is defined, this will show class driver events
|
||||
# CONFIG_NSH_USBDEV_TRACETRANSFERS - Is using a USB console and CONFIG_USB_TRACE
|
||||
# is defined, this will show data transfer events
|
||||
# CONFIG_NSH_USBDEV_TRACECONTROLLER - Is using a USB console and CONFIG_USB_TRACE
|
||||
# is defined, this will show controller events
|
||||
# CONFIG_NSH_USBDEV_TRACEINTERRUPTS - Is using a USB console and CONFIG_USB_TRACE
|
||||
# is defined, this will show interrupt-related events.
|
||||
# CONFIG_NSH_CONDEV - If CONFIG_NSH_CONSOLE is set to 'y', then CONFIG_NSH_CONDEV
|
||||
# may also be set to select the serial device used to support the NSH console.
|
||||
# This should be set to the quoted name of a readable/write-able character
|
||||
|
@ -1265,7 +1273,11 @@ CONFIG_NSH_TELNET=n
|
|||
CONFIG_NSH_USBCONSOLE=n
|
||||
CONFIG_NSH_USBCONDEV="/dev/ttyACM0"
|
||||
CONFIG_NSH_UBSDEV_MINOR=0
|
||||
#CONFIG_NSH_UBSDEV_TRACEINIT
|
||||
CONFIG_NSH_USBDEV_TRACEINIT=n
|
||||
CONFIG_NSH_USBDEV_TRACECLASS=n
|
||||
CONFIG_NSH_USBDEV_TRACETRANSFERS=n
|
||||
CONFIG_NSH_USBDEV_TRACECONTROLLER=n
|
||||
CONFIG_NSH_USBDEV_TRACEINTERRUPTS=n
|
||||
#CONFIG_NSH_CONDEV
|
||||
CONFIG_NSH_ARCHINIT=n
|
||||
CONFIG_NSH_IOBUFFER_SIZE=512
|
||||
|
|
Loading…
Reference in New Issue