You are on page 1of 7

Debugging the Linux kernel with JTAG

http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

EE Times |

EDN |

DataSheets.com |

Design News |

EBN |

Test & Measurement World |

Events

UBM Electronics

EE Times Home > Design >Embedded

Design Article
Like 17 1 Share Tweet 27

Debugging the Linux kernel with JTAG


Alexander Sirotkin 8/29/2010 1:31 PM EDT

As with many Linux-related topics, the issue of using debuggers to troubleshoot the Linux kernel is not only technical--it's political. Linux is being mostly developed on the x86 platform, which does not have JTAG debugging capabilities, and software-only kernel debuggers are complex and unreliable. Because of this and other reasons, Linus Torvalds objected for a long time to inclusion of the KGDB (Linux kernel debugger) patch in the main Linux tree until Ingo Molnar managed to get a rather slimmed down KGDB variant into the 2 that most developers would agree with me, that at is a must-have tool for many tasks, BSP (board su most obvious example. Fortunately, compared with the world of x86, embe challenges but also a good tool to help us tackle th reliable, provides some nice features that are not a from any controversy that is always associated with original KGDB. I assume that the topic of JTAG debugging is not n systems developer, you have probably used somet the past. I will go very briefly over general JTAG de peculiarities of Linux kernel debugging using JTAG JTAG is your friend JTAG (Joint Test Action Group) was initially develo manufacture, however today it's more commonly u adaptor, sometimes referred to as in-circuit emulat modules inside the target CPU. It allows, among other things, to halt the CPU, insp through the code, and define breakpoints. In additi debugger that supports it. Some JTAG adapter ven open source packages. Even though most JTAG debuggers nowadays sup

1 of 7

5/22/2012 2:58 PM

Debugging the Linux kernel with JTAG

http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

device, I suggest you ask whether it supports Linu units (MMU), Linux binary formats, and loadable m debugger) protocol as well, you can be sure that it Cast of characters I will use my setup of a FemtoLinux project through Linux kernel on ARM, so it's beneficial to describe reduce the Linux system's call latency and overhea 5.5 monolithic applications to Linux without redesig Linux kernel hacking would be nearly impossible w For development, we use a LPC3250 board by Em based on NXP CPU with ARM926 core. The hardw particular interest in the scope of this article, but w thought out and specifically designed for develope combined with USB-to-serial bridge clearly shows Naturally, the board has a 20-pin JTAG interface fo JTAG adapter, we use the Flyswatter by Tin Can T surprised me very positively--before I found it, I ha functional JTAG debugger for less than $100. I guess that one of the reasons Tin Can Tool were they didn't invest in the debugging software at all, packages OpenOCD and GDB, which leads us to tools for JTAG debugging. Software tools for JTAG In the scope of this article, OpenOCD--the on-chip software middleware running between the debugge does more than that, but as far as JTAG debuggin commands to USB commands, which it sends to th OpenOCD implements a remote gdbserver protoco of gdbserver, which just happens to debug the Lin running under Linux. OpenOCD supports ARM7, ARM9, XScale, and Co using MIPS or PowerPC, you'll have to look for a d debugger, such as Abatron BDI3000. OpenOCD w adapters, in particular FT2232-based ones. FT2232 is a very popular chip manufactured by Fu used in many low-end JTAG adapters, such as Tin support, OpenOCD has an extensive list of comma interface that include target state command, memo commands, JTAG low-level commands, and much documentation that explains in detail every comma encourage you to read it. GDB is in the house The last part of the setup puzzle is GDB, or the GN debugger for UNIX systems, including Linux, and i facilities for program tracing, altering, and debuggi

2 of 7

5/22/2012 2:58 PM

Debugging the Linux kernel with JTAG

http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

this article, so I'll cover only what is relevant for JT Most commonly GDB is used as a single applicatio this mode, GDB client, in other words the front end PC) and GDB server, the back end, on another (us is used to control the application, and GDB client i using GDB's remote TCP-based protocol. This configuration is what you would normally use In the JTAG debugging case, the OpenOCD daem gdbserver, while the GDB client will remain the sam One important drawback of GDB is a lack of graph Display Debugger (DDD), a GUI wrapper for GDB. it has a very slow response time (by modern stand Fortunately, there is a better alternative--Insight. U of GDB with integrated GUI. (See http://sourceware upside is that the GUI is much nicer and easier to built in, you'll probably have to compile it for your t you to use an external GDB version from your cros Configuring OpenOCD Assuming you've installed all the software I've men you need to take before starting debugging is to co may already include configuration files for your JTA work." Actually, this was almost the case with Flysw CPUTAPID parameter), but your mileage may vary Refer to OpenOCD documentation for a full explan basic commands using in my configuration as an e my configuration file looks like that in Listing 1.

Click on image

The first part is the interface configuration, which d The "interface" command identifies the driver that ft2232_vid_pid commands specify vendor Id and pro The rest are the target board configuration comma JTAG TAP in the chain. You will need at least one the "target create" commands. Here is what an actual JTAG debugging session lo board is connected to Flyswatter via 20-pin JTAG c to a Linux PC. Linux is running OpenOCD daemon

3 of 7

5/22/2012 2:58 PM

Debugging the Linux kernel with JTAG

http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

Click on image

Debug session: 1. Power up the JTAG adaptor. 2. Power up the board. 3. Mount the usbfs (if it is not mounted already): s 4. Run the OpenOCD daemon: sudo bin/openocd 5. Run the Insight (or any other GDB compatible) d vmlinux 6. Set the target settings (post 3333 is the default configuration file):
Target: Remote/TCP Hostname: localhost Port:3333

7. Connect to the target. You will need an uncompressed kernel image vmli symbols, in other words, CONFIG_DEBUG and CONFIG_DEB enabled. If you connected successfully, you can now use th Linux kernel. You can single step in both assembly assembly/C mode for low-level debugging), set bre and generally debug the kernel as you normally wo Figure 2 shows main Insight windows.

4 of 7

5/22/2012 2:58 PM

Debugging the Linux kernel with JTAG

http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

Click on image

Of course, if you prefer a command line interface, to all standard GDB commands, you can send JTA monitor command. For instance, you can check all shown in Listing 2, or you can print information ab command shown in Listing 3. (For a full list of sup documentation.)

Click on image

Click on image

The instructions that I've described so far assume linked kernel image. This is true most of the time-initialization debugging, and this code is of course Sometimes, however, you may wish to debug a dri problem here is that after you load the module usin GDB/Insight is not aware of this module's symbols the symbols names are and to where they've been You can find the base address of each module by can see that on my system, the nfs module has be

cat /proc/modules

5 of 7

5/22/2012 2:58 PM

Debugging the Linux kernel with JTAG

http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

nfs 271912 1 - Live 0xf8716000 ...

The offset is printed in the last column. When you module's symbol table using the following comman

add-symbol-file nsf.ko 0xf8716000

When you are finished, you can continue debuggin A good start This article is by no means a definitive guide to JT enough information to get started. As usually the c everything I've described here. For instance, if you're unwilling to spend the time a not an issue, Wind River Workbench On-Chip Deb all processors currently used in embedded system environment. Needless to say, it supports both VxW Another slightly less expensive option is Abatron B processors and can be used with any client that su way as I described in this article. The major differe interface and runs a GDB server emulation softwar device itself, which is very convenient. If you prefer an Eclipse-based integrated environm purchase an add-on software product LinuxScopedebugger for the Eclipse IDE that has been optimiz Sasha Sirotkin currently works on the FemtoLinu for embedded ARM, MIPS, and PowerPC systems site at www.femtolinux.com. Sasha can be reache Resources: 1. FemtoLinux, www.femtolinux.com 2. EmbeddedArtists, www.embeddedartists.com 3. Tin Can Tools, www.tincantools.com 4. OpenOCD, http://openocd.berlios.de/web/ 5. Insight, http://sourceware.org/insight/ 6. LinuxScope-JTD, www.ultsol.com/mfgs_comp_li 7. Wind River OCD, www.windriver.com/products/O 8. Abatron BDI3000, www.abatron.ch/products/bdi-

6 of 7

5/22/2012 2:58 PM

Debugging the Linux kernel with JTAG

http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

More EE Times
Subscriptions Newsletters Editorial Calendar Reprints RSS Feeds Media Kit Sitemap About Us Privacy Policy Engineering Careers Center Contact Us Email: feedback@eetimes.com support@eetimes.com

EE Times Network
EE Times Asia EE Times-China EE Times-India EE Times Europe EE Times Japan EE Times Korea EE Times Taiwan Electronic Supply & Manufacturing China EDN Design News TechOnline India Test & Measurement World Design & Reuse
All materials on this site copyright 2012 UBM Electronics, A UBM company All rights reserved UBMWEB001B

7 of 7

5/22/2012 2:58 PM

You might also like