| <!-- |
| Documentation/_templates/layout.html |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. The |
| ASF licenses this file to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance with the |
| License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| License for the specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| |
| |
| <!DOCTYPE html> |
| <html class="writer-html5" lang="en"> |
| <head> |
| <meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" /> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <title>USB Device Trace — NuttX latest documentation</title> |
| <link rel="stylesheet" type="text/css" href="../_static/pygments.css" /> |
| <link rel="stylesheet" type="text/css" href="../_static/css/theme.css" /> |
| <link rel="stylesheet" type="text/css" href="../_static/copybutton.css" /> |
| <link rel="stylesheet" type="text/css" href="../_static/custom.css" /> |
| |
| |
| <link rel="shortcut icon" href="../_static/favicon.ico"/> |
| <script src="../_static/jquery.js"></script> |
| <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script> |
| <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> |
| <script src="../_static/doctools.js"></script> |
| <script src="../_static/sphinx_highlight.js"></script> |
| <script src="../_static/clipboard.min.js"></script> |
| <script src="../_static/copybutton.js"></script> |
| <script src="../_static/js/theme.js"></script> |
| <link rel="index" title="Index" href="../genindex.html" /> |
| <link rel="search" title="Search" href="../search.html" /> |
| <link rel="next" title="Simulator" href="simulator.html" /> |
| <link rel="prev" title="NFS Client How-To" href="nfs.html" /> |
| </head> |
| |
| <body class="wy-body-for-nav"> |
| <div class="wy-grid-for-nav"> |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search" > |
| |
| <a href="../index.html" class="icon icon-home"> NuttX |
| |
| |
| |
| </a> |
| |
| <!-- this version selector is quite ugly, should be probably replaced by something |
| more modern --> |
| |
| <div class="version-selector"> |
| <select onchange="javascript:location.href = this.value;"> |
| |
| <option value="../../latest" selected="selected">latest</option> |
| |
| <option value="../../10.0.0" >10.0.0</option> |
| |
| <option value="../../10.0.1" >10.0.1</option> |
| |
| <option value="../../10.1.0" >10.1.0</option> |
| |
| <option value="../../10.2.0" >10.2.0</option> |
| |
| <option value="../../10.3.0" >10.3.0</option> |
| |
| <option value="../../11.0.0" >11.0.0</option> |
| |
| <option value="../../12.0.0" >12.0.0</option> |
| |
| <option value="../../12.1.0" >12.1.0</option> |
| |
| <option value="../../12.2.0" >12.2.0</option> |
| |
| <option value="../../12.2.1" >12.2.1</option> |
| |
| <option value="../../12.3.0" >12.3.0</option> |
| |
| <option value="../../12.4.0" >12.4.0</option> |
| |
| <option value="../../12.5.0" >12.5.0</option> |
| |
| <option value="../../12.5.1" >12.5.1</option> |
| |
| <option value="../../12.6.0" >12.6.0</option> |
| |
| <option value="../../12.7.0" >12.7.0</option> |
| |
| <option value="../../12.8.0" >12.8.0</option> |
| |
| <option value="../../12.9.0" >12.9.0</option> |
| |
| <option value="../../12.10.0" >12.10.0</option> |
| |
| <option value="../../12.11.0" >12.11.0</option> |
| |
| </select> |
| </div> |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> |
| <p class="caption" role="heading"><span class="caption-text">Table of Contents</span></p> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../index.html">Home</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/index.html">Introduction</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../quickstart/index.html">Getting Started</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../platforms/index.html">Supported Platforms</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../components/index.html">OS Components</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../applications/index.html">Applications</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../implementation/index.html">Implementation Details</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../reference/index.html">API Reference</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../faq/index.html">FAQ</a></li> |
| <li class="toctree-l1 current"><a class="reference internal" href="index.html">Guides</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="nfs.html">NFS Client How-To</a></li> |
| <li class="toctree-l2 current"><a class="current reference internal" href="#">USB Device Trace</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="simulator.html">Simulator</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="qemugdb.html">How to debug NuttX using QEMU and GDB</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="rndis.html">How to use RNDIS</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="drivers.html">Drivers</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="tasktrace.html">Task Trace</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="cpp_cmake.html">C++ Example using CMake</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="pysimcoder.html">pysimCoder integration with NuttX</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="customboards.html">Custom Boards How-To</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="customapps.html">Custom Apps How-to</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="citests.html">Running CI Test Locally</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="zerolatencyinterrupts.html">High Performance: Zero Latency Interrupts, Maskable nested interrupts</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="kasan.html">The Kernel Address Sanitizer (KASAN)</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="nestedinterrupts.html">Nested Interrupts</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="cortexmhardfaults.html">Analyzing Cortex-M Hardfaults</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="coredump.html">Core Dump</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="coresight.html">Coresight - HW Assisted Tracing on ARM</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="gdbserver.html">gdbserver</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="gdbwithpython.html">GDB with Python</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="ofloader.html">Open Flash Loader</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="testingtcpip.html">Testing TCP/IP Network Stacks</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="automounter.html">Auto-Mounter</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="stm32nullpointer.html">STM32 Null Pointer Detection</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="stm32ccm.html">STM32 CCM Allocator</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="stackrecord.html">Run time stack statistics</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="etcromfs.html">etc romfs</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="thread_local_storage.html">Thread Local Storage</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../logos/index.html">NuttX Logos</a></li> |
| </ul> |
| |
| </div> |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">NuttX</a> |
| </nav> |
| |
| <div class="wy-nav-content"> |
| <div class="rst-content"> |
| <div role="navigation" aria-label="Page navigation"> |
| <ul class="wy-breadcrumbs"> |
| <li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li> |
| <li class="breadcrumb-item"><a href="index.html">Guides</a></li> |
| <li class="breadcrumb-item active">USB Device Trace</li> |
| <li class="wy-breadcrumbs-aside"> |
| <a href="../_sources/guides/usbtrace.rst.txt" rel="nofollow"> View page source</a> |
| </li> |
| </ul> |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <section id="usb-device-trace"> |
| <span id="usbtrace"></span><h1>USB Device Trace<a class="headerlink" href="#usb-device-trace" title="Permalink to this heading"></a></h1> |
| <p><strong>USB Device Tracing Controls</strong>. The NuttX USB device subsystem supports |
| a fairly sophisticated tracing facility. The basic trace cabability is |
| controlled by these NuttX configuration settings:</p> |
| <blockquote> |
| <div><ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV_TRACE</span></code>: Enables USB tracing</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV_TRACE_NRECORDS</span></code>: Number of trace entries to remember</p></li> |
| </ul> |
| </div></blockquote> |
| <p><strong>Trace IDs</strong>. The trace facility works like this: When enabled, USB |
| events that occur in either the USB device driver or in the USB class |
| driver are logged. These events are described in |
| <code class="docutils literal notranslate"><span class="pre">include/nuttx/usb/usbdev_trace.h</span></code>. The logged events are identified |
| by a set of event IDs:</p> |
| <table class="docutils align-default"> |
| <tbody> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_INIT_ID</span></code></p></td> |
| <td><p>Initialization events</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_EP_ID</span></code></p></td> |
| <td><p>Endpoint API calls</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_DEV_ID</span></code></p></td> |
| <td><p>USB device API calls</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_CLASS_ID</span></code></p></td> |
| <td><p>USB class driver API calls</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_CLASSAPI_ID</span></code></p></td> |
| <td><p>Other class driver system API calls</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_CLASSSTATE_ID</span></code></p></td> |
| <td><p>Track class driver state changes</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_INTENTRY_ID</span></code></p></td> |
| <td><p>Interrupt handler entry</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_INTDECODE_ID</span></code></p></td> |
| <td><p>Decoded interrupt event</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_INTEXIT_ID</span></code></p></td> |
| <td><p>Interrupt handler exit</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_OUTREQQUEUED_ID</span></code></p></td> |
| <td><p>Request queued for OUT endpoint</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_INREQQUEUED_ID</span></code></p></td> |
| <td><p>Request queued for IN endpoint</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_READ_ID</span></code></p></td> |
| <td><p>Read (OUT) action</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_WRITE_ID</span></code></p></td> |
| <td><p>Write (IN) action</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_COMPLETE_ID</span></code></p></td> |
| <td><p>Request completed</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_DEVERROR_ID</span></code></p></td> |
| <td><p>USB controller driver error event</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">TRACE_CLSERROR_ID</span></code></p></td> |
| <td><p>USB class driver error event</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p><strong>Logged Events</strong>. Each logged event is 32-bits in size and includes</p> |
| <blockquote> |
| <div><ol class="arabic simple"> |
| <li><p>8-bits of the trace ID (values associated with the above)</p></li> |
| <li><p>8-bits of additional trace ID data, and</p></li> |
| <li><p>16-bits of additional data.</p></li> |
| </ol> |
| </div></blockquote> |
| <p><strong>8-bit Trace Data</strong> The 8-bit trace data depends on the specific event |
| ID. As examples,</p> |
| <blockquote> |
| <div><ul class="simple"> |
| <li><p>For the USB serial and mass storage class, the 8-bit event data is |
| provided in <code class="docutils literal notranslate"><span class="pre">include/nuttx/usb/usbdev_trace.h</span></code>.</p></li> |
| <li><p>For the USB device driver, that 8-bit event data is provided within |
| the USB device driver itself. So, for example, the 8-bit event data |
| for the LPC1768 USB device driver is found in |
| <code class="docutils literal notranslate"><span class="pre">arch/arm/src/lpc17xx_40xx/lpc17_40_usbdev.c</span></code>.</p></li> |
| </ul> |
| </div></blockquote> |
| <p><strong>16-bit Trace Data</strong>. The 16-bit trace data provided additional context |
| data relevant to the specific logged event.</p> |
| <p><strong>Trace Control Interfaces</strong>. Logging of each of these kinds events can |
| be enabled or disabled using the interfaces described in |
| <code class="docutils literal notranslate"><span class="pre">include/nuttx/usb/usbdev_trace.h</span></code>.</p> |
| <p><strong>Enabling USB Device Tracing</strong>. USB device tracing will be configured |
| if <code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV</span></code> and either of the following are set in the NuttX |
| configuration file:</p> |
| <blockquote> |
| <div><ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV_TRACE</span></code>, or</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_DEBUG_FEATURES</span> <span class="pre">and</span> <span class="pre">CONFIG_DEBUG_USB</span></code></p></li> |
| </ul> |
| </div></blockquote> |
| <p><strong>Log Data Sink</strong>. The logged data itself may go to either (1) an |
| internal circular buffer, or (2) may be provided on the console. If |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV_TRACE</span></code> is defined, then the trace data will go to the |
| circular buffer. The size of the circular buffer is determined by |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV_TRACE_NRECORDS</span></code>. Otherwise, the trace data goes to |
| console.</p> |
| <p><strong>Example</strong>. Here is an example of USB trace output using |
| <code class="docutils literal notranslate"><span class="pre">apps/examples/usbserial</span></code> for an LPC1768 platform with the following |
| NuttX configuration settings:</p> |
| <blockquote> |
| <div><ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_DEBUG_FEATURES</span></code>, <code class="docutils literal notranslate"><span class="pre">CONFIG_DEBUG_INFO</span></code>, <code class="docutils literal notranslate"><span class="pre">CONFIG_USB</span></code></p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_EXAMPLES_USBSERIAL_TRACEINIT</span></code>, |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_EXAMPLES_USBSERIAL_TRACECLASS</span></code>, |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS</span></code>, |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER</span></code>, |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS</span></code></p></li> |
| </ul> |
| </div></blockquote> |
| <p>Console Output:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span> ABDE |
| usbserial_main: Registering USB serial driver |
| uart_register: Registering /dev/ttyUSB0 |
| usbserial_main: Successfully registered the serial driver |
| 1 Class API call 1: 0000 |
| 2 Class error: 19:0000 |
| usbserial_main: ERROR: Failed to open /dev/ttyUSB0 for reading: 107 |
| usbserial_main: Not connected. Wait and try again. |
| 3 Interrupt 1 entry: 0039 |
| 4 Interrupt decode 7: 0019 |
| 5 Interrupt decode 32: 0019 |
| 6 Interrupt decode 6: 0019 |
| 7 Class disconnect(): 0000 |
| 8 Device pullup(): 0001 |
| 9 Interrupt 1 exit: 0000 |
| </pre></div> |
| </div> |
| <p>The numbered items are USB USB trace output. You can look in the file |
| <code class="docutils literal notranslate"><span class="pre">drivers/usbdev/usbdev_trprintf.c</span></code> to see examctly how each output |
| line is formatted. Here is how each line should be interpreted:</p> |
| <table class="docutils align-default"> |
| <tbody> |
| <tr class="row-odd"><td><ol class="upperalpha simple" start="14"> |
| <li></li> |
| </ol> |
| </td> |
| <td><p>USB EVENT ID</p></td> |
| <td><p>8-bit EVENT DATA</p></td> |
| <td><p>MEANING</p></td> |
| <td><p>16-bit EVENT DATA</p></td> |
| </tr> |
| <tr class="row-even"><td><p>1</p></td> |
| <td><p>TRACE_CLASSAPI_ID1</p></td> |
| <td><p>1</p></td> |
| <td><p>USBSER_TRACECLASSAPI_SETUP1</p></td> |
| <td><p>0000</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>2</p></td> |
| <td><p>TRACE_CLSERROR_ID1</p></td> |
| <td><p>19</p></td> |
| <td><p>USBSER_TRACEERR_SETUPNOTCONNECTED1</p></td> |
| <td><p>0000</p></td> |
| </tr> |
| <tr class="row-even"><td><p>3</p></td> |
| <td><p>TRACE_INTENTRY_ID1</p></td> |
| <td><p>1</p></td> |
| <td><p>LPC17_40_TRACEINTID_USB2</p></td> |
| <td><p>0039</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>4</p></td> |
| <td><p>TRACE_INTDECODE_ID2</p></td> |
| <td><p>7</p></td> |
| <td><p>LPC17_40_TRACEINTID_DEVSTAT2</p></td> |
| <td><p>0019</p></td> |
| </tr> |
| <tr class="row-even"><td><p>5</p></td> |
| <td><p>TRACE_INTDECODE_ID2</p></td> |
| <td><p>32</p></td> |
| <td><p>LPC17_40_TRACEINTID_SUSPENDCHG2</p></td> |
| <td><p>0019</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>6</p></td> |
| <td><p>TRACE_INTDECODE_ID2</p></td> |
| <td><p>6</p></td> |
| <td><p>LPC17_40_TRACEINTID_DEVRESET2</p></td> |
| <td><p>0019</p></td> |
| </tr> |
| <tr class="row-even"><td><p>7</p></td> |
| <td><p>TRACE_CLASS_ID1</p></td> |
| <td><p>3</p></td> |
| <td><p>(See TRACE_CLASSDISCONNECT1)</p></td> |
| <td><p>0000</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>8</p></td> |
| <td><p>TRACE_DEV_ID1</p></td> |
| <td><p>6</p></td> |
| <td><p>(See TRACE_DEVPULLUP1)</p></td> |
| <td><p>0001</p></td> |
| </tr> |
| <tr class="row-even"><td><p>9</p></td> |
| <td><p>TRACE_INTEXIT_ID1</p></td> |
| <td><p>1</p></td> |
| <td><p>LPC17_40_TRACEINTID_USB2</p></td> |
| <td><p>0000</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p>NOTES:</p> |
| <blockquote> |
| <div><ol class="arabic simple"> |
| <li><p>See include/nuttx/usb/usbdev_trace.h</p></li> |
| <li><p>See arch/arm/src/lpc17xx_40xx/lpc17_40_usbdev.c</p></li> |
| </ol> |
| </div></blockquote> |
| <p>In the above example you can see that:</p> |
| <blockquote> |
| <div><ul> |
| <li><p><strong>1</strong>. The serial class USB setup method was called for the USB |
| serial class. This is the corresponds to the following logic in |
| <code class="docutils literal notranslate"><span class="pre">drivers/usbdev/pl2303.c</span></code>:</p> |
| <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">static</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="nf">pl2303_setup</span><span class="p">(</span><span class="n">FAR</span><span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">uart_dev_s</span><span class="w"> </span><span class="o">*</span><span class="n">dev</span><span class="p">)</span> |
| <span class="p">{</span> |
| <span class="w"> </span><span class="p">...</span> |
| <span class="w"> </span><span class="n">usbtrace</span><span class="p">(</span><span class="n">PL2303_CLASSAPI_SETUP</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span> |
| <span class="w"> </span><span class="p">...</span> |
| </pre></div> |
| </div> |
| </li> |
| <li><p><strong>2</strong>. An error occurred while processing the setup command because |
| no configuration has yet been selected by the host. This corresponds |
| to the following logic in <code class="docutils literal notranslate"><span class="pre">drivers/usbdev/pl2303.c</span></code>:</p> |
| <blockquote> |
| <div><div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">static</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="nf">pl2303_setup</span><span class="p">(</span><span class="n">FAR</span><span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">uart_dev_s</span><span class="w"> </span><span class="o">*</span><span class="n">dev</span><span class="p">)</span> |
| <span class="p">{</span> |
| <span class="w"> </span><span class="p">...</span> |
| <span class="w"> </span><span class="cm">/* Check if we have been configured */</span> |
| |
| <span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">priv</span><span class="o">-></span><span class="n">config</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">PL2303_CONFIGIDNONE</span><span class="p">)</span> |
| <span class="w"> </span><span class="p">{</span> |
| <span class="w"> </span><span class="n">usbtrace</span><span class="p">(</span><span class="n">TRACE_CLSERROR</span><span class="p">(</span><span class="n">USBSER_TRACEERR_SETUPNOTCONNECTED</span><span class="p">),</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span> |
| <span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="o">-</span><span class="n">ENOTCONN</span><span class="p">;</span> |
| <span class="w"> </span><span class="p">}</span> |
| <span class="w"> </span><span class="p">...</span> |
| </pre></div> |
| </div> |
| </div></blockquote> |
| </li> |
| <li><p><strong>3-6</strong>. Here is a USB interrupt that suspends and resets the device.</p></li> |
| <li><p><strong>7-8</strong>. During the interrupt processing the serial class is |
| disconnected</p></li> |
| <li><p><strong>9</strong>. And the interrupt returns</p></li> |
| </ul> |
| </div></blockquote> |
| <p><strong>USB Monitor</strong>. The <em>USB monitor</em> is an application in the |
| <code class="docutils literal notranslate"><span class="pre">apps/system/usbmonitor</span></code> that provides a convenient way to get debug |
| trace output. If tracing is enabled, the USB device will save encoded |
| trace output in in-memory buffer; if the USB monitor is also enabled, |
| that trace buffer will be periodically emptied and dumped to the system |
| logging device (the serial console in most configurations). The |
| following are some of the relevant configuration options:</p> |
| <table class="docutils align-default"> |
| <tbody> |
| <tr class="row-odd"><td><p>Device Drivers -> USB Device Driver Support</p></td> |
| <td><p>.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV_TRACE=y</span></code></p></td> |
| <td><p>Enable USB trace feature</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV_TRACE_NRECORDS=nnnn</span></code></p></td> |
| <td><p>Buffer nnnn records in memory. If you lose trace data,</p></td> |
| </tr> |
| <tr class="row-even"><td><p>.</p></td> |
| <td><p>then you will need to increase the size of this buffer</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>.</p></td> |
| <td><p>(or increase the rate at which the trace buffer is emptied).</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBDEV_TRACE_STRINGS=y</span></code></p></td> |
| <td><p>Optionally, convert trace ID numbers to strings.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>.</p></td> |
| <td><p>This feature may not be supported by all drivers.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <table class="docutils align-default"> |
| <tbody> |
| <tr class="row-odd"><td><p>Application Configuration -> NSH LIbrary</p></td> |
| <td><p>.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_NSH_USBDEV_TRACE=n</span></code></p></td> |
| <td><p>Make sure that any built-in tracing from NSH is disabled.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_NSH_ARCHINIT=y</span></code></p></td> |
| <td><p>Enable this option only if your board-specific logic</p></td> |
| </tr> |
| <tr class="row-even"><td><p>.</p></td> |
| <td><p>has logic to automatically start the USB monitor.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>.</p></td> |
| <td><p>Otherwise the USB monitor can be started or stopped</p></td> |
| </tr> |
| <tr class="row-even"><td><p>.</p></td> |
| <td><p>with the usbmon_start and usbmon_stop commands from the NSH console.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <table class="docutils align-default"> |
| <tbody> |
| <tr class="row-odd"><td><p>Application Configuration -> System NSH Add-Ons</p></td> |
| <td><p>.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR=y</span></code></p></td> |
| <td><p>Enable the USB monitor daemon</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR_STACKSIZE=nnnn</span></code></p></td> |
| <td><p>Sets the USB monitor daemon stack size to nnnn. The default is 2KiB.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR_PRIORITY=50</span></code></p></td> |
| <td><p>Sets the USB monitor daemon priority to nnnn.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>.</p></td> |
| <td><p>This priority should be low so that it does not</p></td> |
| </tr> |
| <tr class="row-even"><td><p>.</p></td> |
| <td><p>interfere with other operations, but not so low that</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>.</p></td> |
| <td><p>you cannot dump the buffered USB data sufficiently</p></td> |
| </tr> |
| <tr class="row-even"><td><p>.</p></td> |
| <td><p>rapidly. The default is 50.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR_INTERVAL=nnnn</span></code></p></td> |
| <td><p>Dump the buffered USB data every nnnn seconds.</p></td> |
| </tr> |
| <tr class="row-even"><td><p>.</p></td> |
| <td><p>If you lose buffered USB trace data, then dropping</p></td> |
| </tr> |
| <tr class="row-odd"><td><p>.</p></td> |
| <td><p>this value will help by increasing the rate at which</p></td> |
| </tr> |
| <tr class="row-even"><td><p>.</p></td> |
| <td><p>the USB trace buffer is emptied.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR_TRACEINIT=y</span></code></p></td> |
| <td><p>Selects which USB event(s) that you want to be traced.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR_TRACECLASS=y</span></code></p></td> |
| <td><p>.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR_TRACETRANSFERS=y</span></code></p></td> |
| <td><p>.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR_TRACECONTROLLER=y</span></code></p></td> |
| <td><p>.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">CONFIG_USBMONITOR_TRACEINTERRUPTS=y</span></code></p></td> |
| <td><p>.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p>NOTE: If USB debug output is also enabled, both outputs will appear on |
| the serial console. However, the debug output will be asynchronous with |
| the trace output and, hence, difficult to interpret.</p> |
| </section> |
| |
| |
| </div> |
| </div> |
| <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> |
| <a href="nfs.html" class="btn btn-neutral float-left" title="NFS Client How-To" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> |
| <a href="simulator.html" class="btn btn-neutral float-right" title="Simulator" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> |
| </div> |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p>© Copyright 2023, The Apache Software Foundation.</p> |
| </div> |
| |
| |
| |
| </footer> |
| </div> |
| </div> |
| </section> |
| </div> |
| <script> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| </body> |
| </html> |