Debugging the Linux Kernel With JTAG

download Debugging the Linux Kernel With JTAG

of 7

Transcript of Debugging the Linux Kernel With JTAG

  • 7/31/2019 Debugging the Linux Kernel With JTAG

    1/7

  • 7/31/2019 Debugging the Linux Kernel With JTAG

    2/7

    device, I suggest you ask whether it supports Linu

    units (MMU), Linux binary formats, and loadable

    debugger) protocol as well, you can be sure that it

    Cast of characters

    I will use my setup of a FemtoLinux project throug

    Linux kernel on ARM, so it's beneficial to describe

    reduce the Linux system's call latency and overhe

    5.5 monolithic applications to Linux without redesi

    Linux kernel hacking would be nearly impossible

    For development, we use a LPC3250 board by E

    based on NXP CPU with ARM926 core. The hard

    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 f

    JTAG adapter, we use the Flyswatter by Tin Can Tsurprised 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 debugg

    does more than that, but as far as JTAG debuggin

    commands to USB commands, which it sends to t

    OpenOCD implements a remote gdbserver protoc

    of gdbserver, which just happens to debug the Lin

    running under Linux.

    OpenOCD supports ARM7, ARM9, XScale, and C

    using MIPS or PowerPC, you'll have to look for a

    debugger, such as Abatron BDI3000. OpenOCD wadapters, in particular FT2232-based ones.

    FT2232 is a very popular chip manufactured by F

    used in many low-end JTAG adapters, such as Tin

    support, OpenOCD has an extensive list of comm

    interface that include target state command, memo

    commands, JTAG low-level commands, and much

    documentation that explains in detail every comm

    encourage you to read it.

    GDB is in the house

    The last part of the setup puzzle is GDB, or the G

    debugger for UNIX systems, including Linux, and i

    facilities for program tracing, altering, and debuggi

    ugging the Linux kernel with JTAG http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

    7 5/22/2012 2:58 PM

  • 7/31/2019 Debugging the Linux Kernel With JTAG

    3/7

    this article, so I'll cover only what is relevant for JT

    Most commonly GDB is used as a single applicati

    this mode, GDB client, in other words the front en

    PC) and GDB server, the back end, on another (u

    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 sa

    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://sourcewar

    upside is that the GUI is much nicer and easier tobuilt in, you'll probably have to compile it for your

    you to use an external GDB version from your cro

    Configuring OpenOCD

    Assuming you've installed all the software I've me

    you need to take before starting debugging is to c

    may already include configuration files for your JT

    work." Actually, this was almost the case with Flys

    CPUTAPID parameter), but your mileage may vary

    Refer to OpenOCD documentation for a full explan

    basic commands using in my configuration as an

    my configuration file looks like that in Listing 1.

    Click on image

    The first part is the interface configuration, which

    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 lboard is connected to Flyswatter via 20-pin JTAG

    to a Linux PC. Linux is running OpenOCD daemo

    ugging the Linux kernel with JTAG http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

    7 5/22/2012 2:58 PM

  • 7/31/2019 Debugging the Linux Kernel With JTAG

    4/7

  • 7/31/2019 Debugging the Linux Kernel With JTAG

    5/7

    Click on image

    Of course, if you prefer a command line interface,

    to all standard GDB commands, you can send JT

    monitor command. For instance, you can check all

    shown in Listing 2, or you can print information a

    command shown in Listing 3. (For a full list of su

    documentation.)

    Click on image

    Click on image

    The instructions that I've described so far assumelinked 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 usi

    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 b

    cat /proc/modules

    ugging the Linux kernel with JTAG http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

    7 5/22/2012 2:58 PM

  • 7/31/2019 Debugging the Linux Kernel With JTAG

    6/7

    nfs 271912 1 - Live 0xf8716000

    ...

    The offset is printed in the last column. When you

    module's symbol table using the following comma

    add-symbol-file nsf.ko 0xf8716000

    When you are finished, you can continue debuggi

    A good start

    This article is by no means a definitive guide to J

    enough information to get started. As usually the c

    everything I've described here.

    For instance, if you're unwilling to spend the time

    not an issue, Wind River Workbench On-Chip De

    all processors currently used in embedded system

    environment. Needless to say, it supports both Vx

    Another slightly less expensive option is Abatron

    processors and can be used with any client that s

    way as I described in this article. The major differe

    interface and runs a GDB server emulation softwa

    device itself, which is very convenient.

    If you prefer an Eclipse-based integrated environm

    purchase an add-on software product LinuxScope-

    debugger for the Eclipse IDE that has been optimi

    Sasha Sirotkincurrently works on the FemtoLinu

    for embedded ARM, MIPS, and PowerPC system

    site atwww.femtolinux.com. Sasha can be reach

    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/

    8. Abatron BDI3000, www.abatron.ch/products/bdi

    ugging the Linux kernel with JTAG http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...

    7 5/22/2012 2:58 PM

  • 7/31/2019 Debugging the Linux Kernel With JTAG

    7/7

    Subscriptions

    Newsletters

    Editorial Calendar

    Reprints

    RSS Feeds

    Media Kit

    Sitemap

    About Us

    Privacy Policy

    Engineering Careers Center

    Contact Us

    Email: [email protected]

    [email protected]

    More EE Times

    EE Times Asia

    EE Times-China

    EE Times-India

    EE Times Europe

    EE Times Japan

    EE Times Korea

    EE Times Taiwan

    Electronic Supply & ManufacturingChina

    EDN

    Design News

    TechOnline India

    Test & Measurement World

    Design & Reuse

    EE Times Network

    All materials on this sitecopyright 2012 UBM Electronics,A UBM companyAll rights reservedUBMWEB001B

    ugging the Linux kernel with JTAG http://www.eetimes.com/design/embedded/4207333/Debugging-the-Lin...