Using OpenOCD JTAG in Android Kernel Debugging – Android Builder Summit 2012

Mike Anderson, CTO and Chief Scientist for The PTR Group, gives a tutorial about Linux kernel debugging in Android with OpenOCD JTAG at the Android Builder Summit in February 2012.

Abstract:

Owing to the use of the Linux kernel, Android device drivers can be debugged using many of the same techniques as Linux. Still, much of the user-space interface code typically found in Linux is missing in Android. This complicates the debugging of kernel driver code. This presentation will demonstrate the use of the open on-chip debug (OpenOCD) software and an inexpensive JTAG to debug Android kernel code. The target audience for this presentation are platform developers looking to debug their kernel code such as device drivers. This presentation is targeted at intermediate-level developers with some understanding of kernel code development.

You can also download the presentation slides on linuxfoundation.org website.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK Pi 4C Plus

12 Replies to “Using OpenOCD JTAG in Android Kernel Debugging – Android Builder Summit 2012”

  1. Just a newbie question guys.
    Not actually about openocd but something similar.
    I’m running android from adeneo release 4.2 on iMX53qsb and im using ubuntu image from freescale on a windows 7 machine.
    When i issue a gdbserver command on the target it always says ‘[1] segmentation fault’ even just a simple/plain ‘gdbserver’
    I’m using the jtagkey2p from Amontec and jlink from Segger but gdbserver still spits the same error.
    Any help would be appreciated guys, Thank you so much.

    1. If you just run ‘gdbserver’, it should just display the usage. I suppose gdbserver is corrupted, you can try to rebuild or re-install it.

  2. @ jose
    I’m not sure. But I tried to run ‘gdbserver’ in an emulator (qemu-system-arm) and if I don’t give any parameters the program would just print gdbserver usage. So if it’s not corrupted (or not for your target), I’m not sure what could cause the segfault. gdbserver is part of gdb code, so you could even build it yourself. If you don’t connect the JTAG, but just run gdbserver, will it crash ?

    As other people mentioned on imxcommunity forum, if you debug at the application level, you could simply Ethernet instead of the jtag. I’ve actually never used jtag, only ethernet with gdb server (my boards did not support jtag).

    I have a “getting started with gdbserver” post if you are interested: http://www.cnx-software.com/2012/01/31/debugging-embedded-linux-with-gdbserver-and-insight-gdb-gui/

  3. @ cnxsoft
    Whoever you are, thank you so much for the link and for the advice.
    But would it be enough if i use this in kernel hacking/debugging and device driver development?

    By the way do you also have a tutorial link about the emulator you’re using?
    I’ve been trying to use QEMU so i can start working while waiting for the hardware but i can’t make it to work i actually don’t know how to use it and what options i should give.

  4. @ jose
    That’s right you can’t use Ethernet for kernel / device driver debugger. Actually, I just use printk for that…
    So if want to debug the kernel you’d probably have to use JTAG.

    For qemu, you can have a look at
    http://www.cnx-software.com/2011/10/18/raspberry-pi-emulator-in-ubuntu-with-qemu/
    or
    http://www.cnx-software.com/2011/09/26/beagleboard-emulator-in-ubuntu-with-qemu/

    btw, if you don’t use an emulator and don’t have hardware, where did you run gdbserver ? You are supposed to run gdbserver in the target board.

  5. Thank you again ‘cnxsoft’.
    Yah i just thought about that haha… I was thinking i can develop drivers using QEMU but it can’t simulate the GPIOs for the iMX platform right? Or is there a platform option that i can issue on QEMU so it can like simulate the platform’s pads or pins?
    Sorry I’m assuming too much, this whole thing is so alien to me. I haven’t used any full-blown devkit, I’ve only used PIC MCUs and a simulator to test the output with the IDE to debug.
    Could you advice me on what proper setup i should have without the hardware to dev. drivers? Or i couldn’t until i have the target with the JTAG?

  6. @ jose
    I don’t think you can develop GPIO drivers in the emulator.
    You can just develop your code and make sure it compiles before you get the hardware.

    There are advanced virtualization solutions such as Simics (http://www.windriver.com/products/simics/) that may do what you are looking for, but this is probably quite expensive.

    Here’s also a summary of a webinar by Wind River to speed-up embedded development: http://www.cnx-software.com/2011/11/17/technologies-and-techniques-to-accelerate-embedded-development/

  7. I’m trying OpenOCD-0.5.0 now and I have the jtagkey2p from Amontec.
    I did this:
    1. $ ./configure –enable-ft2232_libftdi
    2. make
    3. make install
    4. sudo openocd -f ./tcl/interface/jtagkey2p.cfg -f ./tcl/target/imx53.cfg
    5. I get this error

    Error: The specified debug interface was not found (ft2232)
    The following debug interfaces are available:
    Runtime Error: ./tcl/interface/jtagkey2p.cfg:7:
    in procedure ‘script’
    at file “embedded:startup.tcl”, line 58
    in procedure ‘interface’ called at file “./tcl/interface/jtagkey2p.cfg”, line 7

    Now this is the inside of jtagkey2p.cfg
    ——– jtagkey2p.cfg ————————–
    1. #
    2. # Amontec JTAGkey2P
    3. #
    4. # http://www.amontec.com/jtagkey2p.shtml
    5. #
    6
    7. interface ft2232
    8. ft2232_device_desc “Amontec JTAGkey-2P”
    9. ft2232_layout jtagkey
    10. ft2232_vid_pid 0x0403 0xCFF8
    ———————————————–

    Any comments guys?
    Thanks in advance.

  8. @ jose
    I don’t have this hardware, so your question is a bit too specific.

    If Amontec/Adeneo can’t provide support, you can try to ask linaro toolchain group https://wiki.linaro.org/WorkingGroups/ToolChain. They work on https://blueprints.launchpad.net/linaro/+spec/tr-toolchain-openocd and Freescale is one of their member. You’d better use their Freescale i.MX53 Ubuntu (or Android) Image (https://wiki.linaro.org/Boards/MX53QuickStart) to get a better chance of getting an answer.

Leave a Reply

Your email address will not be published. Required fields are marked *

Khadas VIM4 SBC
Khadas VIM4 SBC