⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kgdb.html

📁 ADI 公司blackfin系列的用户使用文挡。
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>  <title></title>  <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />  <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />  <link rel="stylesheet" media="print" type="text/css" href="./print.css" />  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="clear"><ul class="toc"><li class="level2"><div class="li"><span class="li"><a href="#debugging_the_kernel_with_kgdb" class="toc">Debugging the Kernel with KGDB</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#patch_the_kernel" class="toc">Patch the kernel</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#configure_the_kernel_for_kgdb" class="toc">Configure The Kernel for KGDB</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#modify_the_kernel_command_line" class="toc">Modify the kernel command line</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#boot_the_kgdb_kernel" class="toc">Boot the KGDB Kernel</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#start_gdb_on_the_host" class="toc">Start GDB on the Host</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#connect_the_debug_host_to_the_target" class="toc">Connect the Debug Host to the Target</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#some_sample_debug_commands" class="toc">Some Sample Debug Commands</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#using_the_serial_uart" class="toc">Using the Serial Uart</a></span></div></li></ul></li></ul></li></ul></div></div><h2><a name="debugging_the_kernel_with_kgdb" id="debugging_the_kernel_with_kgdb">Debugging the Kernel with KGDB</a></h2><div class="level2"><p> One of the features of Blackfin uClinux is the inclusion of KGDB over ethernet.</p><p>This allows the &ldquo;normal&rdquo; operation of the ethernet interface to be taken over by gdb. Selected UDP ports are then used to communicate between gdb operating on a host system and a gdb stub or server working on the target system</p><p>To set the system up you need to do the following </p><ul><li class="level1"><div class="li"> Patch the Kernel for use with KGDB</div></li><li class="level1"><div class="li"> Configure the kernel to build in KGDB</div></li><li class="level1"><div class="li"> Modify the kernel command line</div></li><li class="level1"><div class="li"> Start the Kernel</div></li><li class="level1"><div class="li"> Start GDB on a development host</div></li><li class="level1"><div class="li"> Connect to the target</div></li><li class="level1"><div class="li"> Debug away</div></li></ul></div><!-- SECTION [1-620] --><h3><a name="patch_the_kernel" id="patch_the_kernel">Patch the kernel</a></h3><div class="level3"><p> A patch is available to add KGDB to the kernel.</p><p>Follow these instructions to apply the patch:</p><pre class="code">$ cd uClinux-dist/linux-2.6.x$ patch -p1 &lt; ../bfin_patch/kgdb_patch/kgdb_bfin_linux-2.6.x.patch </pre></div><!-- SECTION [621-859] --><h3><a name="configure_the_kernel_for_kgdb" id="configure_the_kernel_for_kgdb">Configure The Kernel for KGDB</a></h3><div class="level3"><p> Once this patch has been applied, configure the kernel. </p><pre class="code">make linux_menuconfig</pre><p> The KGDB options will be found under the Kernel Hacking section. </p><pre class="code">  Kernel hacking ---&gt;    [*] Kernel debugging    [*] KGBD: kernel debugging with remote gdb      [*] KGDB: Over Ethernet</pre><p> Then exit the Kernel Configuration system and save the selected options.</p></div><!-- SECTION [860-1255] --><h3><a name="modify_the_kernel_command_line" id="modify_the_kernel_command_line">Modify the kernel command line</a></h3><div class="level3"><p> When the kernel boot the command line is passed into the kernel from u-boot in the  &ldquo;bootparam&rdquo; environment variable or the Kernel command line can be compiled in to the kernel if required.</p><p>To trigger KGDBoe the command line is. </p><pre class="code">kgdboe=@target-IP/,@host-IP/</pre><p> For example </p><pre class="code">kgdboe=@192.168.1.200/,@192.168.1.1/</pre><p> This will connect kgdb to a host system at 192.168.1.1 </p><ul><li class="level1"><div class="li"> The default host mac address will be used </div></li><li class="level2"><div class="li"> The target will receive GDB messages on UDP port 6443</div></li><li class="level2"><div class="li"> The target will  send GDB messages on UDP port 6442</div></li></ul></div><!-- SECTION [1256-1841] --><h3><a name="boot_the_kgdb_kernel" id="boot_the_kgdb_kernel">Boot the KGDB Kernel</a></h3><div class="level3"><p> Connect your terminal emulator to the serial port and boot the kernel image. The target system&rsquo;s IP address will need to be configured using &ldquo;ifconfig&rdquo;. </p><pre class="code">/&gt; ifconfig eth0 192.168.1.200</pre></div><!-- SECTION [1842-2061] --><h3><a name="start_gdb_on_the_host" id="start_gdb_on_the_host">Start GDB on the Host</a></h3><div class="level3"><p> A debug session should be started on the host system  using the bfin-elf-gdb tool. Remember this runs on x86 systems but debugs Blackfin code. </p><pre class="code">cd uClinux-dist/linux-2.6.xbfin-elf-gdb vmlinux</pre><p> Or you can run <code>ddd &ndash;debugger bfin-elf-gdb vmlinux</code> if you want to use the ddd debugger.</p></div><!-- SECTION [2062-2386] --><h3><a name="connect_the_debug_host_to_the_target" id="connect_the_debug_host_to_the_target">Connect the Debug Host to the Target</a></h3><div class="level3"><p> Once the Debugger has started you can connect to the target system using the UDP protocol and the special Debug port </p><pre class="code">(gdb) target remote udp:192.168.1.200:6443</pre></div><!-- SECTION [2387-2597] --><h3><a name="some_sample_debug_commands" id="some_sample_debug_commands">Some Sample Debug Commands</a></h3><div class="level3"><p> These commands can be used as an example of a debug session. </p><pre class="code"># Set a break point at a kernel function (sys_open)(gdb) break sys_open</pre><pre class="code"># Use the GDB continue command(gdb) c</pre><p> On the target system use the &ldquo;ls&rdquo; command to trigger a breakpoint at sys_open </p><pre class="code">/&gt; ls</pre><p>  The Breakpoint hits and GDB displays a message </p><pre class="code">&quot;Breakpoint 1: sys_open(...&quot;</pre><pre class="code"># Use the gdb single stepping command (gdb) si</pre><pre class="code"># Use the GDB  remove breakpoint command (gdb) del 1</pre><pre class="code"># Set hardware breakpoint (gdb) hbreak sys_open</pre><pre class="code"># Continue (gdb) c</pre><p> Run &ldquo;ls&rdquo; in the target console  </p><pre class="code">/&gt; ls</pre><p> The GDB Session is terminated using the detach command </p><pre class="code"># Interrupt the target from the GDB host(gdb) Type Ctrl+C</pre><pre class="code"># Detach the GDB host from the target(gdb) detach</pre><pre class="code"># Exit GDB (gdb) quit</pre></div><!-- SECTION [2598-3424] --><h3><a name="using_the_serial_uart" id="using_the_serial_uart">Using the Serial Uart</a></h3><div class="level3"><p> The Serial Uart can also be used to connect a debug host to the target. In this case typing a Ctrl+A over the serial line will cause the kernel to enter a debug mode. The Debug host will then send debug commands over the serial line instead of the ethernet port. This option is useful on systems that have no ethernet interfaces.</p><p> If you want to do source level debugging over UART and share this UART with console go back to the Kernel Configuration (make linux menuconfig)</p><p>Select option &ldquo;KGDB: on Blackfin UART&rdquo;. Set &ldquo;KGDB: UART port number&rdquo;. Don&rsquo;t forget to change the mode of Blackfin serial driver to PIO (not DMA). Or else, kgdb works incorrectly on UART</p><p> Enable &ldquo;KGDB: Wait for gdb connection early&rdquo; if you want connect to kgdb when kernel booting. </p><p>Exit the configuration system save the options and build the kernel.</p><p>Boot the kernel Image as above</p><p>Ask target to wait for gdb connection by entering Ctrl+A.  (In minicom, you should enter Ctrl+A+A )</p><p>Start GDB as for the KGDBoe session Issue the following commands at the gdb prompt </p><pre class="code"># Set the baud rate in GDB (gdb) set remotebaud 57600# connect to the target(gdb) target remote /dev/ttyS0</pre><p> Continue with debugging as before. All other operations are the same as that in KGDB over Ethernet. The only difference is that after issuing the continue command in GDB, stop the GDB connection using two &ldquo;Ctrl+C&rdquo;s  and connect again after breakpoints are hit or Ctrl+A is entered. </p></div><!-- SECTION [3425-] --></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -