You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gi...@apache.org on 2020/11/25 00:42:15 UTC

[incubator-nuttx-website] branch asf-site updated: Publishing web: 5eb8540a7fe060c5e451b36dfb23656a6f18e3e7 docs: 324d3a89edc3ad310229e0243bd5d56e568c207a

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-website.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 9a6327e  Publishing web: 5eb8540a7fe060c5e451b36dfb23656a6f18e3e7 docs: 324d3a89edc3ad310229e0243bd5d56e568c207a
9a6327e is described below

commit 9a6327e1a6161765576eaaf2f3cb653e59032ea9
Author: Xiang <xi...@xiaomi.com>
AuthorDate: Wed Nov 25 00:41:49 2020 +0000

    Publishing web: 5eb8540a7fe060c5e451b36dfb23656a6f18e3e7 docs: 324d3a89edc3ad310229e0243bd5d56e568c207a
---
 .../latest/_sources/quickstart/debugging.rst.txt   | 245 +++++++++++++-------
 content/docs/latest/index.html                     |   2 +-
 content/docs/latest/objects.inv                    | Bin 22048 -> 22038 bytes
 content/docs/latest/quickstart/debugging.html      | 254 +++++++++++++--------
 content/docs/latest/searchindex.js                 |   2 +-
 content/feed.xml                                   |   4 +-
 6 files changed, 331 insertions(+), 176 deletions(-)

diff --git a/content/docs/latest/_sources/quickstart/debugging.rst.txt b/content/docs/latest/_sources/quickstart/debugging.rst.txt
index 299326b..cc3489e 100644
--- a/content/docs/latest/_sources/quickstart/debugging.rst.txt
+++ b/content/docs/latest/_sources/quickstart/debugging.rst.txt
@@ -1,6 +1,7 @@
 .. include:: /substitutions.rst
 .. _debugging:
 
+=========
 Debugging
 =========
 
@@ -9,7 +10,7 @@ to use debugging techniques to understand how the system works. Two tools that a
 debugging using the GNU Debugger (gdb).
 
 Debug Logging
--------------
+=============
 
 NuttX has a powerful system logging facility (syslog) with ``info``, ``warn``, and ``error`` levels. You can enable
 debugging for your build for the subsystem or feature by using the ``menuconfig`` system.
@@ -17,15 +18,15 @@ debugging for your build for the subsystem or feature by using the ``menuconfig`
 The debug options are available under :menuselection:`Build Setup --> Debug Options`. You will most likely have to enable the
 following options:
 
-* ``Enable Debug Features`` — selecting this will turn on subsystem-level debugging options, they will become visible
+* :menuselection:`Enable Debug Features` — selecting this will turn on subsystem-level debugging options, they will become visible
   on the page below. You can then select the ones you want.
-* ``Enable Error Output`` — this will only log errors.
-* ``Enable Warnings Output`` — this will log warnings and errors.
-* ``Enable Informational Debug Output`` — this will produce informational output, warnings, and errors.
+* :menuselection:`Enable Error Output` — this will only log errors.
+* :menuselection:`Enable Warnings Output` — this will log warnings and errors.
+* :menuselection:`Enable Informational Debug Output` — this will produce informational output, warnings, and errors.
 
 You can then select from the subsystems that are available, Network, Scheduler, USB, etc. Note that you will need to
 separately enable the subsystem elsewhere in the ``menuconfig`` system. To see the ``CONFIG`` define that is set,
-use the arrow keys to highlight the subsystem (for instance, ``Network Debug Features``) and type '?'. This will show
+use the arrow keys to highlight the subsystem (for instance, :menuselection:`Network Debug Features`) and type :kbd:`?`. This will show
 you that the C macro that is set is called ``CONFIG_DEBUG_NET``. ``debug.h`` defines the ``netinfo()`` logging
 function that will log output if this macro is set. You can search the source code for ``netinfo`` to see how it is
 used.
@@ -51,7 +52,7 @@ There are also subsystems that enable USB trace debugging, and you can log to me
 faster than what the console can output.
 
 Debugging with ``openocd`` and ``gdb``
---------------------------------------
+======================================
 
 To debug our Nucleo board using its embedded SWD debug adapter,
 start ``openocd`` with the following command:
@@ -73,107 +74,195 @@ Inside ``gdb`` console, connect to the ``gdb`` server with:
 
   (gdb) target extended-remote :3333
 
-You can now use standard ``gdb`` commands.
-
-Debugging with an external JTAG adapter
----------------------------------------
-
-.. todo::
-  Explain this with openocd. It gives the impression that JTAG requires
-  a specific tool. Also, some of the example commands apply to both cases.
-  This repeats some of the above.
-
-If your board does not have an embedded programmer and uses
-`JTAG <https://en.wikipedia.org/wiki/JTAG>`_ connector instead,
-things are a bit different. This guide assumes you have a JTAG hardware debugger like a
-`Segger J-Link <https://www.segger.com/products/debug-probes/j-link/>`_.
-JTAG is a set of standards that let you
-attach a hardware device to your embedded board, and then remotely control the CPU.
-You can load code, start, stop, step through the program, and examine variables and memory.
+You can now use standard ``gdb`` commands. For example, to
+reset the board:
 
-#. Attach the Debugger Cables
-
-#. Start the Debugger
+.. code-block::
 
-   Refer to your JTAG debugger's documentation for information on how to start a GDB Server process that gdb can
-   communicate with to load code and start, stop, and step the embedded board's CPU. Your command line may be
-   different from this one.
+  (gdb) mon reset
 
-    .. code-block:: console
+To halt the board:
 
-       $ JLinkGDBServer -device ATSAMA5D27 -if JTAG -speed 1000 -JTAGConf -1,-1
+.. code-block::
 
-#. Launch the GNU Debugger
+  (gdb) mon halt
+  
+To set a breakpoint:
 
-   In another terminal window, launch the GDB. In the case of this guide, this came with the
-   ARM Embedded GNU Toolchain we downloaded in the Install step.
+.. code-block::
 
-    .. code-block:: console
+  (gdb) breakpoint nsh_main
 
-       $ cd nuttx/
-       $ gdb-multiarch nuttx/nuttx
+and to finally start nuttx:
 
-#. Set gdb to talk with the J-Link
+.. code-block::
 
-    ::
+  (gdb) continue
+  Continuing.
 
-       (gdb) target extended-remote :2331
+  Breakpoint 1, nsh_main (argc=1, argv=0x200ddfac) at nsh_main.c:208
+  208	  sched_getparam(0, &param);
+  (gdb) continue
+  Continuing.
+  
+.. tip::
 
-#. Reset the board
+  You can abbreviate ``gdb`` commands: ``info b`` is a shortcut for
+  ``information breakpoints``; ``c`` works the same as ``continue``, etc.
 
-    ::
+NuttX aware debugging
+---------------------
 
-       (gdb) mon reset
+Since NuttX is actually an RTOS, it is useful to have ``gdb`` be aware of the different
+tasks/threads that are running. There are two ways to do this: via ``openocd``
+itself or via ``gdb``. Note that in both cases, you need to enable debug symbols
+(``CONFIG_DEBUG_SYMBOLS``).
 
-#. You may need to switch to the serial console to hit a key to stop the board from booting from its boot monitor
-   (U-Boot, in the case of the SAMA5 boards from Microchip).
+With openocd
+~~~~~~~~~~~~
 
-#. Halt the board
+``openocd`` supports various RTOS directly, including NuttX. It works by reading
+into internal NuttX symbols which define the active tasks and their properties.
+As a result, the ``gdb`` server will directly be aware of each task as a different
+`thread`. The downside of this approach is that it depends on how you build NuttX
+as there are some options hardcoded into
+opencd. By default, it assumes:
 
-    ::
+  * ``CONFIG_DISABLE_MQUEUE=y``
+  * ``CONFIG_PAGING=n``
+  
+If you need these options to be set differently, you will have to edit ``./src/rtos/nuttx_header.h`` from ``openocd``, 
+change the corresponding settings and then rebuild it.
 
-       (gdb) mon halt
+Finally, to enable NuttX integration, you need to supply an additional ``openocd`` argument:
 
-#. Load nuttx
+.. code-block:: console
 
-    ::
+  $ openocd -f interface/st-link-v2.cfg -f target/stm32f1x.cfg -c '$_TARGETNAME configure -rtos nuttx'
+  
+Since ``openocd`` also needs to know the memory layout of certain datastructures, you need to have ``gdb``
+run the following commands once the ``nuttx`` binary is loaded:
 
-       (gdb) load nuttx
-       `/home/adamf/src/nuttx-sama5d36-xplained/nuttx/nuttx' has changed; re-reading symbols.
-       Loading section .text, size 0x9eae4 lma 0x20008000
-       Loading section .ARM.exidx, size 0x8 lma 0x200a6ae4
-       Loading section .data, size 0x125c lma 0x200a6aec
-       Start address 0x20008040, load size 654664
-       Transfer rate: 75 KB/sec, 15587 bytes/write.
-       (gdb)
+.. code-block::
 
-#. Set a breakpoint
+  eval "monitor nuttx.pid_offset %d", &((struct tcb_s *)(0))->pid
+  eval "monitor nuttx.xcpreg_offset %d", &((struct tcb_s *)(0))->xcp.regs
+  eval "monitor nuttx.state_offset %d", &((struct tcb_s *)(0))->task_state
+  eval "monitor nuttx.name_offset %d", &((struct tcb_s *)(0))->name
+  eval "monitor nuttx.name_size %d", sizeof(((struct tcb_s *)(0))->name)
+  
+One way to do this is to define a gdb `hook` function that will be called when running ``file`` command:
 
-    ::
+.. code-block::
 
-       (gdb) breakpoint nsh_main
+  define hookpost-file
+    eval "monitor nuttx.pid_offset %d", &((struct tcb_s *)(0))->pid
+    eval "monitor nuttx.xcpreg_offset %d", &((struct tcb_s *)(0))->xcp.regs
+    eval "monitor nuttx.state_offset %d", &((struct tcb_s *)(0))->task_state
+    eval "monitor nuttx.name_offset %d", &((struct tcb_s *)(0))->name
+    eval "monitor nuttx.name_size %d", sizeof(((struct tcb_s *)(0))->name)
+  end
+  
+You will see that ``openocd`` has received the memory offsets in its output:
 
-#. Start nuttx
+.. code-block::
 
-    ::
+  Open On-Chip Debugger 0.10.0+dev-01514-ga8edbd020-dirty (2020-11-20-14:23)
+  Licensed under GNU GPL v2
+  For bug reports, read
+	  http://openocd.org/doc/doxygen/bugs.html
+  Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
+  Info : target type name = cortex_m
+  Info : Listening on port 6666 for tcl connections
+  Info : Listening on port 4444 for telnet connections
+  15:41:23: Debugging starts
+  Info : CMSIS-DAP: SWD  Supported
+  Info : CMSIS-DAP: FW Version = 1.10
+  Info : CMSIS-DAP: Interface Initialised (SWD)
+  Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
+  Info : CMSIS-DAP: Interface ready
+  Info : clock speed 1000 kHz
+  Info : SWD DPIDR 0x2ba01477
+  Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
+  Info : starting gdb server for nrf52.cpu on 3333
+  Info : Listening on port 3333 for gdb connections
+  Info : accepting 'gdb' connection on tcp/3333
+  Error: No symbols for NuttX
+  Info : nRF52832-QFAA(build code: B0) 512kB Flash, 64kB RAM
+  undefined debug reason 8 - target needs reset
+  Warn : Prefer GDB command "target extended-remote 3333" instead of "target remote 3333"
+  Info : pid_offset: 12
+  Info : xcpreg_offset: 132
+  Info : state_offset: 26
+  Info : name_offset: 208
+  Info : name_size: 32
+  target halted due to debug-request, current mode: Thread 
+  xPSR: 0x01000000 pc: 0x000000dc msp: 0x20000cf0
+  target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x000000dc msp: 0x20000cf0
+  
+.. note:: You will probably see the ``Error: No symbols for NuttX`` error appear once at startup. This is OK
+  unless you see it every time you step the debugger. In this case, it would mean you did not enable debug symbols.
+
+Now, You can now inspect threads:
 
-       (gdb) continue
-       Continuing.
+.. code-block::
 
-       Breakpoint 1, nsh_main (argc=1, argv=0x200ddfac) at nsh_main.c:208
-       208	  sched_getparam(0, &param);
-       (gdb) continue
-       Continuing.
+  (gdb) info threads
+    Id   Target Id         Frame 
+  * 1    Remote target     nx_start_application () at init/nx_bringup.c:261  
+  (gdb) info registers
+  r0             0x0                 0
+  r1             0x2f                47
+  r2             0x0                 0
+  r3             0x0                 0
+  r4             0x0                 0
+  r5             0x0                 0
+  r6             0x0                 0
+  r7             0x20000ca0          536874144
+  r8             0x0                 0
+  r9             0x0                 0
+  r10            0x0                 0
+  r11            0x0                 0
+  r12            0x9                 9
+  sp             0x20000c98          0x20000c98
+  lr             0x19c5              6597
+  pc             0x1996              0x1996 <nx_start_application+10>
+  xPSR           0x41000000          1090519040
+  fpscr          0x0                 0
+  msp            0x20000c98          0x20000c98
+  psp            0x0                 0x0 <_vectors>
+  primask        0x0                 0
+  basepri        0xe0                -32
+  faultmask      0x0                 0
+  control        0x0                 0
+
+With gdb
+~~~~~~~~
+
+You can also do NuttX aware debugging using ``gdb`` scripting support.
+The benefit is that it works also for the sim build where ``openocd`` is
+not applicable. For this to work, you will need to enable PROC filesystem support
+which will expose required task information (``CONFIG_FS_PROCFS=y``). 
+
+To use this approach, you can load the ``nuttx/tools/nuttx-gdbinit`` file. An
+easy way to do this is to create a symbolic link:
 
-Debugging Shortcuts
--------------------
+.. code-block:: console
 
-Note that you can abbreviate ``gdb`` commands, ``info b`` is a shortcut for
-``information breakpoints``; ``c`` works the same as ``continue``, etc.
+  $ cd $HOME
+  $ ln -s nuttx/tools/nuttx-gdbinit .gdbinit
+  
+This way whenever gdb is started it will run the appropriate commands. To inspect
+the threads you can now use the following ``gdb`` command:
 
-See this article for more info:
-`Debugging a Apache NuttX target with GDB and OpenOCD <https://micro-ros.github.io/docs/tutorials/advanced/nuttx/debugging/>`_.
+.. code-block::
 
-----
+  (gdb) info_nxthreads
+  target examined 
+  _target_arch.name=armv7e-m
+  $_target_has_fpu : 0 
+  $_target_has_smp : 0 
+  saved current_tcb (pid=0) 
+  * 0 Thread 0x20000308  (Name: Idle Task, State: Running, Priority: 0) 0xdc in __start()
+    1 Thread 0x20001480  (Name: init, State: Waiting,Semaphore, Priority: 100) 0x7e08 in arm_switchcontext()
 
-Next up is :ref:`organization`.
diff --git a/content/docs/latest/index.html b/content/docs/latest/index.html
index 6e2229b..3ab8388 100644
--- a/content/docs/latest/index.html
+++ b/content/docs/latest/index.html
@@ -206,7 +206,7 @@ by following these <a class="reference internal" href="contributing/documentatio
 <div class="section" id="nuttx-documentation">
 <h1>NuttX Documentation<a class="headerlink" href="#nuttx-documentation" title="Permalink to this headline">¶</a></h1>
 <p>NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOS’s (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()).</p>
-<p>Last Updated: 24 November 20 at 00:39</p>
+<p>Last Updated: 25 November 20 at 00:40</p>
 <div class="toctree-wrapper compound">
 <p class="caption"><span class="caption-text">Table of Contents</span></p>
 <ul class="current">
diff --git a/content/docs/latest/objects.inv b/content/docs/latest/objects.inv
index 3c66b4a..849e44a 100644
Binary files a/content/docs/latest/objects.inv and b/content/docs/latest/objects.inv differ
diff --git a/content/docs/latest/quickstart/debugging.html b/content/docs/latest/quickstart/debugging.html
index eb6a7da..0d390c3 100644
--- a/content/docs/latest/quickstart/debugging.html
+++ b/content/docs/latest/quickstart/debugging.html
@@ -127,9 +127,10 @@
 <li class="toctree-l2"><a class="reference internal" href="configuring.html">Configuring</a></li>
 <li class="toctree-l2 current"><a class="current reference internal" href="#">Debugging</a><ul>
 <li class="toctree-l3"><a class="reference internal" href="#debug-logging">Debug Logging</a></li>
-<li class="toctree-l3"><a class="reference internal" href="#debugging-with-openocd-and-gdb">Debugging with <code class="docutils literal notranslate"><span class="pre">openocd</span></code> and <code class="docutils literal notranslate"><span class="pre">gdb</span></code></a></li>
-<li class="toctree-l3"><a class="reference internal" href="#debugging-with-an-external-jtag-adapter">Debugging with an external JTAG adapter</a></li>
-<li class="toctree-l3"><a class="reference internal" href="#debugging-shortcuts">Debugging Shortcuts</a></li>
+<li class="toctree-l3"><a class="reference internal" href="#debugging-with-openocd-and-gdb">Debugging with <code class="docutils literal notranslate"><span class="pre">openocd</span></code> and <code class="docutils literal notranslate"><span class="pre">gdb</span></code></a><ul>
+<li class="toctree-l4"><a class="reference internal" href="#nuttx-aware-debugging">NuttX aware debugging</a></li>
+</ul>
+</li>
 </ul>
 </li>
 <li class="toctree-l2"><a class="reference internal" href="organization.html">Directory Structure</a></li>
@@ -222,15 +223,15 @@ debugging for your build for the subsystem or feature by using the <code class="
 <p>The debug options are available under <span class="menuselection">Build Setup ‣ Debug Options</span>. You will most likely have to enable the
 following options:</p>
 <ul class="simple">
-<li><p><code class="docutils literal notranslate"><span class="pre">Enable</span> <span class="pre">Debug</span> <span class="pre">Features</span></code> — selecting this will turn on subsystem-level debugging options, they will become visible
+<li><p><span class="menuselection">Enable Debug Features</span> — selecting this will turn on subsystem-level debugging options, they will become visible
 on the page below. You can then select the ones you want.</p></li>
-<li><p><code class="docutils literal notranslate"><span class="pre">Enable</span> <span class="pre">Error</span> <span class="pre">Output</span></code> — this will only log errors.</p></li>
-<li><p><code class="docutils literal notranslate"><span class="pre">Enable</span> <span class="pre">Warnings</span> <span class="pre">Output</span></code> — this will log warnings and errors.</p></li>
-<li><p><code class="docutils literal notranslate"><span class="pre">Enable</span> <span class="pre">Informational</span> <span class="pre">Debug</span> <span class="pre">Output</span></code> — this will produce informational output, warnings, and errors.</p></li>
+<li><p><span class="menuselection">Enable Error Output</span> — this will only log errors.</p></li>
+<li><p><span class="menuselection">Enable Warnings Output</span> — this will log warnings and errors.</p></li>
+<li><p><span class="menuselection">Enable Informational Debug Output</span> — this will produce informational output, warnings, and errors.</p></li>
 </ul>
 <p>You can then select from the subsystems that are available, Network, Scheduler, USB, etc. Note that you will need to
 separately enable the subsystem elsewhere in the <code class="docutils literal notranslate"><span class="pre">menuconfig</span></code> system. To see the <code class="docutils literal notranslate"><span class="pre">CONFIG</span></code> define that is set,
-use the arrow keys to highlight the subsystem (for instance, <code class="docutils literal notranslate"><span class="pre">Network</span> <span class="pre">Debug</span> <span class="pre">Features</span></code>) and type ‘?’. This will show
+use the arrow keys to highlight the subsystem (for instance, <span class="menuselection">Network Debug Features</span>) and type <kbd class="kbd docutils literal notranslate">?</kbd>. This will show
 you that the C macro that is set is called <code class="docutils literal notranslate"><span class="pre">CONFIG_DEBUG_NET</span></code>. <code class="docutils literal notranslate"><span class="pre">debug.h</span></code> defines the <code class="docutils literal notranslate"><span class="pre">netinfo()</span></code> logging
 function that will log output if this macro is set. You can search the source code for <code class="docutils literal notranslate"><span class="pre">netinfo</span></code> to see how it is
 used.</p>
@@ -263,112 +264,177 @@ start <code class="docutils literal notranslate"><span class="pre">openocd</span
 <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) target extended-remote :3333
 </pre></div>
 </div>
-<p>You can now use standard <code class="docutils literal notranslate"><span class="pre">gdb</span></code> commands.</p>
+<p>You can now use standard <code class="docutils literal notranslate"><span class="pre">gdb</span></code> commands. For example, to
+reset the board:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) mon reset
+</pre></div>
 </div>
-<div class="section" id="debugging-with-an-external-jtag-adapter">
-<h2>Debugging with an external JTAG adapter<a class="headerlink" href="#debugging-with-an-external-jtag-adapter" title="Permalink to this headline">¶</a></h2>
-<div class="admonition-todo admonition" id="id2">
-<p class="admonition-title">Todo</p>
-<p>Explain this with openocd. It gives the impression that JTAG requires
-a specific tool. Also, some of the example commands apply to both cases.
-This repeats some of the above.</p>
+<p>To halt the board:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) mon halt
+</pre></div>
 </div>
-<p>If your board does not have an embedded programmer and uses
-<a class="reference external" href="https://en.wikipedia.org/wiki/JTAG">JTAG</a> connector instead,
-things are a bit different. This guide assumes you have a JTAG hardware debugger like a
-<a class="reference external" href="https://www.segger.com/products/debug-probes/j-link/">Segger J-Link</a>.
-JTAG is a set of standards that let you
-attach a hardware device to your embedded board, and then remotely control the CPU.
-You can load code, start, stop, step through the program, and examine variables and memory.</p>
-<ol class="arabic">
-<li><p>Attach the Debugger Cables</p></li>
-<li><p>Start the Debugger</p>
-<p>Refer to your JTAG debugger’s documentation for information on how to start a GDB Server process that gdb can
-communicate with to load code and start, stop, and step the embedded board’s CPU. Your command line may be
-different from this one.</p>
-<blockquote>
-<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> JLinkGDBServer -device ATSAMA5D27 -if JTAG -speed <span class="m">1000</span> -JTAGConf -1,-1
+<p>To set a breakpoint:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) breakpoint nsh_main
 </pre></div>
 </div>
-</div></blockquote>
-</li>
-<li><p>Launch the GNU Debugger</p>
-<p>In another terminal window, launch the GDB. In the case of this guide, this came with the
-ARM Embedded GNU Toolchain we downloaded in the Install step.</p>
-<blockquote>
-<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> <span class="nb">cd</span> nuttx/
-<span class="gp">$</span> gdb-multiarch nuttx/nuttx
+<p>and to finally start nuttx:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) continue
+Continuing.
+
+Breakpoint 1, nsh_main (argc=1, argv=0x200ddfac) at nsh_main.c:208
+208     sched_getparam(0, &amp;param);
+(gdb) continue
+Continuing.
 </pre></div>
 </div>
-</div></blockquote>
-</li>
-<li><p>Set gdb to talk with the J-Link</p>
+<div class="admonition tip">
+<p class="admonition-title">Tip</p>
+<p>You can abbreviate <code class="docutils literal notranslate"><span class="pre">gdb</span></code> commands: <code class="docutils literal notranslate"><span class="pre">info</span> <span class="pre">b</span></code> is a shortcut for
+<code class="docutils literal notranslate"><span class="pre">information</span> <span class="pre">breakpoints</span></code>; <code class="docutils literal notranslate"><span class="pre">c</span></code> works the same as <code class="docutils literal notranslate"><span class="pre">continue</span></code>, etc.</p>
+</div>
+<div class="section" id="nuttx-aware-debugging">
+<h3>NuttX aware debugging<a class="headerlink" href="#nuttx-aware-debugging" title="Permalink to this headline">¶</a></h3>
+<p>Since NuttX is actually an RTOS, it is useful to have <code class="docutils literal notranslate"><span class="pre">gdb</span></code> be aware of the different
+tasks/threads that are running. There are two ways to do this: via <code class="docutils literal notranslate"><span class="pre">openocd</span></code>
+itself or via <code class="docutils literal notranslate"><span class="pre">gdb</span></code>. Note that in both cases, you need to enable debug symbols
+(<code class="docutils literal notranslate"><span class="pre">CONFIG_DEBUG_SYMBOLS</span></code>).</p>
+<div class="section" id="with-openocd">
+<h4>With openocd<a class="headerlink" href="#with-openocd" title="Permalink to this headline">¶</a></h4>
+<p><code class="docutils literal notranslate"><span class="pre">openocd</span></code> supports various RTOS directly, including NuttX. It works by reading
+into internal NuttX symbols which define the active tasks and their properties.
+As a result, the <code class="docutils literal notranslate"><span class="pre">gdb</span></code> server will directly be aware of each task as a different
+<cite>thread</cite>. The downside of this approach is that it depends on how you build NuttX
+as there are some options hardcoded into
+opencd. By default, it assumes:</p>
 <blockquote>
-<div><div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) target extended-remote :2331
+<div><ul class="simple">
+<li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_DISABLE_MQUEUE=y</span></code></p></li>
+<li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_PAGING=n</span></code></p></li>
+</ul>
+</div></blockquote>
+<p>If you need these options to be set differently, you will have to edit <code class="docutils literal notranslate"><span class="pre">./src/rtos/nuttx_header.h</span></code> from <code class="docutils literal notranslate"><span class="pre">openocd</span></code>,
+change the corresponding settings and then rebuild it.</p>
+<p>Finally, to enable NuttX integration, you need to supply an additional <code class="docutils literal notranslate"><span class="pre">openocd</span></code> argument:</p>
+<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> openocd -f interface/st-link-v2.cfg -f target/stm32f1x.cfg -c <span class="s1">&#39;$_TARGETNAME configure -rtos nuttx&#39;</span>
 </pre></div>
 </div>
-</div></blockquote>
-</li>
-<li><p>Reset the board</p>
-<blockquote>
-<div><div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) mon reset
+<p>Since <code class="docutils literal notranslate"><span class="pre">openocd</span></code> also needs to know the memory layout of certain datastructures, you need to have <code class="docutils literal notranslate"><span class="pre">gdb</span></code>
+run the following commands once the <code class="docutils literal notranslate"><span class="pre">nuttx</span></code> binary is loaded:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>eval &quot;monitor nuttx.pid_offset %d&quot;, &amp;((struct tcb_s *)(0))-&gt;pid
+eval &quot;monitor nuttx.xcpreg_offset %d&quot;, &amp;((struct tcb_s *)(0))-&gt;xcp.regs
+eval &quot;monitor nuttx.state_offset %d&quot;, &amp;((struct tcb_s *)(0))-&gt;task_state
+eval &quot;monitor nuttx.name_offset %d&quot;, &amp;((struct tcb_s *)(0))-&gt;name
+eval &quot;monitor nuttx.name_size %d&quot;, sizeof(((struct tcb_s *)(0))-&gt;name)
 </pre></div>
 </div>
-</div></blockquote>
-</li>
-<li><p>You may need to switch to the serial console to hit a key to stop the board from booting from its boot monitor
-(U-Boot, in the case of the SAMA5 boards from Microchip).</p></li>
-<li><p>Halt the board</p>
-<blockquote>
-<div><div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) mon halt
+<p>One way to do this is to define a gdb <cite>hook</cite> function that will be called when running <code class="docutils literal notranslate"><span class="pre">file</span></code> command:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>define hookpost-file
+  eval &quot;monitor nuttx.pid_offset %d&quot;, &amp;((struct tcb_s *)(0))-&gt;pid
+  eval &quot;monitor nuttx.xcpreg_offset %d&quot;, &amp;((struct tcb_s *)(0))-&gt;xcp.regs
+  eval &quot;monitor nuttx.state_offset %d&quot;, &amp;((struct tcb_s *)(0))-&gt;task_state
+  eval &quot;monitor nuttx.name_offset %d&quot;, &amp;((struct tcb_s *)(0))-&gt;name
+  eval &quot;monitor nuttx.name_size %d&quot;, sizeof(((struct tcb_s *)(0))-&gt;name)
+end
 </pre></div>
 </div>
-</div></blockquote>
-</li>
-<li><p>Load nuttx</p>
-<blockquote>
-<div><div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) load nuttx
-`/home/adamf/src/nuttx-sama5d36-xplained/nuttx/nuttx&#39; has changed; re-reading symbols.
-Loading section .text, size 0x9eae4 lma 0x20008000
-Loading section .ARM.exidx, size 0x8 lma 0x200a6ae4
-Loading section .data, size 0x125c lma 0x200a6aec
-Start address 0x20008040, load size 654664
-Transfer rate: 75 KB/sec, 15587 bytes/write.
-(gdb)
+<p>You will see that <code class="docutils literal notranslate"><span class="pre">openocd</span></code> has received the memory offsets in its output:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Open On-Chip Debugger 0.10.0+dev-01514-ga8edbd020-dirty (2020-11-20-14:23)
+Licensed under GNU GPL v2
+For bug reports, read
+        http://openocd.org/doc/doxygen/bugs.html
+Info : auto-selecting first available session transport &quot;swd&quot;. To override use &#39;transport select &lt;transport&gt;&#39;.
+Info : target type name = cortex_m
+Info : Listening on port 6666 for tcl connections
+Info : Listening on port 4444 for telnet connections
+15:41:23: Debugging starts
+Info : CMSIS-DAP: SWD  Supported
+Info : CMSIS-DAP: FW Version = 1.10
+Info : CMSIS-DAP: Interface Initialised (SWD)
+Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
+Info : CMSIS-DAP: Interface ready
+Info : clock speed 1000 kHz
+Info : SWD DPIDR 0x2ba01477
+Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
+Info : starting gdb server for nrf52.cpu on 3333
+Info : Listening on port 3333 for gdb connections
+Info : accepting &#39;gdb&#39; connection on tcp/3333
+Error: No symbols for NuttX
+Info : nRF52832-QFAA(build code: B0) 512kB Flash, 64kB RAM
+undefined debug reason 8 - target needs reset
+Warn : Prefer GDB command &quot;target extended-remote 3333&quot; instead of &quot;target remote 3333&quot;
+Info : pid_offset: 12
+Info : xcpreg_offset: 132
+Info : state_offset: 26
+Info : name_offset: 208
+Info : name_size: 32
+target halted due to debug-request, current mode: Thread
+xPSR: 0x01000000 pc: 0x000000dc msp: 0x20000cf0
+target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x000000dc msp: 0x20000cf0
 </pre></div>
 </div>
-</div></blockquote>
-</li>
-<li><p>Set a breakpoint</p>
-<blockquote>
-<div><div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) breakpoint nsh_main
+<div class="admonition note">
+<p class="admonition-title">Note</p>
+<p>You will probably see the <code class="docutils literal notranslate"><span class="pre">Error:</span> <span class="pre">No</span> <span class="pre">symbols</span> <span class="pre">for</span> <span class="pre">NuttX</span></code> error appear once at startup. This is OK
+unless you see it every time you step the debugger. In this case, it would mean you did not enable debug symbols.</p>
+</div>
+<p>Now, You can now inspect threads:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) info threads
+  Id   Target Id         Frame
+* 1    Remote target     nx_start_application () at init/nx_bringup.c:261
+(gdb) info registers
+r0             0x0                 0
+r1             0x2f                47
+r2             0x0                 0
+r3             0x0                 0
+r4             0x0                 0
+r5             0x0                 0
+r6             0x0                 0
+r7             0x20000ca0          536874144
+r8             0x0                 0
+r9             0x0                 0
+r10            0x0                 0
+r11            0x0                 0
+r12            0x9                 9
+sp             0x20000c98          0x20000c98
+lr             0x19c5              6597
+pc             0x1996              0x1996 &lt;nx_start_application+10&gt;
+xPSR           0x41000000          1090519040
+fpscr          0x0                 0
+msp            0x20000c98          0x20000c98
+psp            0x0                 0x0 &lt;_vectors&gt;
+primask        0x0                 0
+basepri        0xe0                -32
+faultmask      0x0                 0
+control        0x0                 0
 </pre></div>
 </div>
-</div></blockquote>
-</li>
-<li><p>Start nuttx</p>
-<blockquote>
-<div><div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) continue
-Continuing.
-
-Breakpoint 1, nsh_main (argc=1, argv=0x200ddfac) at nsh_main.c:208
-208        sched_getparam(0, &amp;param);
-(gdb) continue
-Continuing.
+</div>
+<div class="section" id="with-gdb">
+<h4>With gdb<a class="headerlink" href="#with-gdb" title="Permalink to this headline">¶</a></h4>
+<p>You can also do NuttX aware debugging using <code class="docutils literal notranslate"><span class="pre">gdb</span></code> scripting support.
+The benefit is that it works also for the sim build where <code class="docutils literal notranslate"><span class="pre">openocd</span></code> is
+not applicable. For this to work, you will need to enable PROC filesystem support
+which will expose required task information (<code class="docutils literal notranslate"><span class="pre">CONFIG_FS_PROCFS=y</span></code>).</p>
+<p>To use this approach, you can load the <code class="docutils literal notranslate"><span class="pre">nuttx/tools/nuttx-gdbinit</span></code> file. An
+easy way to do this is to create a symbolic link:</p>
+<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> <span class="nb">cd</span> <span class="nv">$HOME</span>
+<span class="gp">$</span> ln -s nuttx/tools/nuttx-gdbinit .gdbinit
 </pre></div>
 </div>
-</div></blockquote>
-</li>
-</ol>
+<p>This way whenever gdb is started it will run the appropriate commands. To inspect
+the threads you can now use the following <code class="docutils literal notranslate"><span class="pre">gdb</span></code> command:</p>
+<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>(gdb) info_nxthreads
+target examined
+_target_arch.name=armv7e-m
+$_target_has_fpu : 0
+$_target_has_smp : 0
+saved current_tcb (pid=0)
+* 0 Thread 0x20000308  (Name: Idle Task, State: Running, Priority: 0) 0xdc in __start()
+  1 Thread 0x20001480  (Name: init, State: Waiting,Semaphore, Priority: 100) 0x7e08 in arm_switchcontext()
+</pre></div>
+</div>
+</div>
 </div>
-<div class="section" id="debugging-shortcuts">
-<h2>Debugging Shortcuts<a class="headerlink" href="#debugging-shortcuts" title="Permalink to this headline">¶</a></h2>
-<p>Note that you can abbreviate <code class="docutils literal notranslate"><span class="pre">gdb</span></code> commands, <code class="docutils literal notranslate"><span class="pre">info</span> <span class="pre">b</span></code> is a shortcut for
-<code class="docutils literal notranslate"><span class="pre">information</span> <span class="pre">breakpoints</span></code>; <code class="docutils literal notranslate"><span class="pre">c</span></code> works the same as <code class="docutils literal notranslate"><span class="pre">continue</span></code>, etc.</p>
-<p>See this article for more info:
-<a class="reference external" href="https://micro-ros.github.io/docs/tutorials/advanced/nuttx/debugging/">Debugging a Apache NuttX target with GDB and OpenOCD</a>.</p>
-<hr class="docutils" />
-<p>Next up is <a class="reference internal" href="organization.html#organization"><span class="std std-ref">Directory Structure</span></a>.</p>
 </div>
 </div>
 
diff --git a/content/docs/latest/searchindex.js b/content/docs/latest/searchindex.js
index ca72a10..c6e8f29 100644
--- a/content/docs/latest/searchindex.js
+++ b/content/docs/latest/searchindex.js
@@ -1 +1 @@
-Search.setIndex({docnames:["applications/index","applications/nsh/builtin","applications/nsh/commands","applications/nsh/config","applications/nsh/customizing","applications/nsh/index","applications/nsh/installation","applications/nsh/login","applications/nsh/nsh","boards/index","components/binfmt","components/drivers/block/index","components/drivers/character/analog","components/drivers/character/can","components/drivers/character/index","components/drivers/character/keypad","components [...]
\ No newline at end of file
+Search.setIndex({docnames:["applications/index","applications/nsh/builtin","applications/nsh/commands","applications/nsh/config","applications/nsh/customizing","applications/nsh/index","applications/nsh/installation","applications/nsh/login","applications/nsh/nsh","boards/index","components/binfmt","components/drivers/block/index","components/drivers/character/analog","components/drivers/character/can","components/drivers/character/index","components/drivers/character/keypad","components [...]
\ No newline at end of file
diff --git a/content/feed.xml b/content/feed.xml
index c28924b..6e084f7 100644
--- a/content/feed.xml
+++ b/content/feed.xml
@@ -5,8 +5,8 @@
     <description></description>
     <link>/</link>
     <atom:link href="/feed.xml" rel="self" type="application/rss+xml"/>
-    <pubDate>Tue, 24 Nov 2020 00:42:07 +0000</pubDate>
-    <lastBuildDate>Tue, 24 Nov 2020 00:42:07 +0000</lastBuildDate>
+    <pubDate>Wed, 25 Nov 2020 00:41:48 +0000</pubDate>
+    <lastBuildDate>Wed, 25 Nov 2020 00:41:48 +0000</lastBuildDate>
     <generator>Jekyll v3.8.5</generator>
     
       <item>