gdb-ocd: On-Chip Debugger Based on GDB

Brief description

This project patched GDB for debugging embedded ARM system via JTAG debug interface. The embedded and extended Python interpreter make OS-aware debug session possible, and also provide flexible NOR/NAND flash utility.

Description in detail

Almost modern processors are integrated with hardware logics that provide debug capability including breakpoint, watchpoint, read/write register/memory. These hardware logics always can be accessed via JTAG interface.

On the other end, the GNU Debugger, usually called just GDB, is the standard debugger for the GNU software system. It is not only available with graphical frontends(Insight from RedHat), but also can interact with Eclipse IDE.GDB usually debugs a running or new process on the local system. But it is also possible to debug program running on another host.

The goal of this project was to embody a new GDB target backend that interfaces with the JTAG interface to debug embedded ARM system.To offer OS-aware support for popular OS, a extended Python interpreter will be embedded in gdb-ocd.

Implementation

The used hardware interface is known as wiggler interface. A line driver IC (74244) connects the parallel port with the jtag interface. The circuit can easily be build on a breadboard. There are also PCB layouts available.

The software is written in C. There are modules for:

Supported ARM cores: Some new commands are implemented to handle configuration of JTAG interface, MMU and cache of arm920t and arm926ejs.

Future plan

To offer OS-aware support for popular OS, a extended Python interpreter will be embedded in release 0.2.

Currently, only some expensive commercial ICEs can debug ARM11 and Cortex-A8 cores. gdb-ocd is planned to support ARM11 and Cortex-A8 cores in future release, thus provide a cheap and reliable debug solution for small budget projects.

The speed of wiggler interface is slow, and it consume a lot of host CPU resource. Design of an advanced USB/Ethernet JTAG adapter is on schedule. In this design, ARM(ARM7TDMI or Cortex-M3) will communicate with gdb-ocd via USB/Ethernet, decompress and parse jtag protocol. FPGA will be responsible for JTAG IO timing.

Download

Version 0.1 has been released on October, 8th and is now available in the Downloads section.

Installation guide

Firstly,download the official release 6.8 of GDB from either Project GNU's FTP server, or Red Hat's sources site:

http://ftp.gnu.org/gnu/gdb (mirrors)
ftp://sourceware.org/pub/gdb/releases/ (mirrors).

On Windows XP platform

Requisite software packages:

Under Msys shell
  $tar -jxvf gdb-6.8.tar.bz2
  $cd gdb-6.8
  $patch -p1 < ../gdb-6.8_ocd-0.1.patch
  $cd ..
  $mkdir gdb-6.8-build
  $cd gdb-6.8-build
  $../gdb-6.8/configure --prefix=/mingw --enable-ocd --with-expat --with-stabs --enable-targets=arm-none-linux --program-transform-name=s,^gdb,gdb-ocd, --build=i686-pc-mingw32 --host=i686-pc-mingw32 --target=arm-none-elf
  $make
  $make install
Put driver file "giveio.sys" in "C:\WINDOWS\system32\drivers" directory.

On Linux platform

Under bash

  #tar -jxvf gdb-6.8.tar.bz2
  #cd gdb-6.8
  #patch -p1 < ../gdb-6.8_ocd-0.1.patch
  #cd ..
  #mkdir gdb-6.8-build
  #cd gdb-6.8-build
  #../gdb-6.8/configure --prefix=/usr/local --enable-ocd --with-expat --with-stabs --enable-targets=arm-none-linux --program-transform-name=s,^gdb,gdb-ocd, --build=i686-pc-linux --host=i686-pc-linux --target=arm-none-elf
  $make
  $make install

Overview of added GDB commands

jtag config jtag_adapter_name reset_type ntrst_hold ntrst_delay nsrst_hold nsrst_delay trst_with_tms ignore_bad_idcode

Summary:
    Setting JTAG parameters.

Options:
    jtag_adapter_name: name of JTAG adapter driver
        parport             parallel port driver

    reset_type: specify reset logic type of target board's JTAG interface.
        trst_and_srst       target board has both TRST and SRST, and two signals are seperate.
        trst_srst_linked    target board has both TRST and SRST, and two signals are linked together.
        trst                target board has only TRST.
        srst                target board has only SRST.
        none                target board has no reset signal.

    ntrst_hold(ms): specify the minimal assertion duration of TRST.

    ntrst_delay(ms): specify the delay duration after TRST disasserted. During this period, no JTAG operations are performed.

    nsrst_hold(ms): specify the minimal assertion duration of SRST.

    nsrst_delay(ms): specify the delay duration after SRST disasserted. During this period, no JTAG operations are performed.

    trst_with_tms: perform JTAG TAP reset through TMS transitions.

    ignore_bad_idcode: ignore bad JTAG idcode when detecting and verifying JTAG scan chain.

jtag parport cable_type port_addr delay

Summary:
    Configure JTAG parallel port driver

Options:
    cable_type: parallel port cable type
         wiggler:           Wiggler from Macraigor Systems
         wiggler2:          Wiggler with led indicator
         
    port_addr: IO address of parallel port(default: 0x378)
    
    delay: delay between IO operations of parallel port.

jtag detect

Summary:
    Autodetect JTAG scan chain, print idcodes of all found devices.

jtag add ir_len ir_expected ir_expected_mask

Summary:
    Add a device to JTAG scan chain.

Options:
    ir_len: length of JTAG instruction register.
    
    ir_expected: the value of instruction register after Capture-IR state.

    ir_expected_mask: the mask of ir_expected.

jtag delete

Summary:
    Clear the configuration of JTAG scan chain.

jtag verify

Summary:
    Verify the configuration of JTAG scan chain.

target jtag-ocd scan_chain_pos machine_type startup_mode [run_duration] [init_script]

Summary:
    Debug ARM core via JTAG interface.

Options:
    scan_chain_pos: The position of ARM core in JTAG scan chain, numbered from 0.

    machine_type: the ARM core type
        arm7tdmi:           ARM7TDMI and ARM7TDMI-S
        arm9tdmi:           ARM9TDMI
        arm920t:            ARM920T
        arm926ejs:          ARM926EJS

    startup_mode: specify the startup mode of gdb-ocd
        attach:             attach to ARM core, user can press Ctrl-C to interrupt.
        run:                reset ARM core and let it run, user can press Ctrl-C to interrupt.
        stop:               reset ARM core and then halt it.
        init:               reset ARM core, halt it, and then execute initialization script.
        timer:              reset ARM core, let it run for a period, and then halt it.
        timer_init:         reset ARM core, lent it run for a period, halt it, and then execute initialization script.

    run_duration(optional): specify the run period in ms unit, only effective for "timer" and "timer_init" startup mode.

    init_script(optional): specify the file path of initialization script consisted of GDB commands, only effective for "init" and "timer_init" startup mode.

info mmu

Summary:
    Print current status of MMU subsystem(effective when ARM core is ARM920T or ARM926EJS)

set mmu-bypass value

Summary:
    Set whether or not bypass MMU access control(effective when ARM core is ARM920T or ARM926EJS)

Option:
    value: specify whether or not bypass MMU access control
         1:                 bypass MMU access control
         0:                 not bypass MMU access control

mmu turn on|off

Summary:
    Turn on/off MMU subsystem(effective when ARM core is ARM920T or ARM926EJS)

mmu v2p virtual_addr

Summmary:
    Translate virtual address into physical address(effective when ARM core is ARM920T or ARM926EJS)

Option:
    virtual_addr: virtual address

info cache

Summary:
    Print current status of Cache subsystem(effective when ARM core is ARM920T or ARM926EJS)

cache turn on|off

Summary:
    Turn on/off Cache subsystem(effective when ARM core is ARM920T or ARM926EJS)

cache invalidate cache_type [address]

Summary:
    Invalidate cache entries(effective when ARM core is ARM920T or ARM926EJS)

Options:
    cache_type: instruction or data cache
        icache:             instuction cache
        dcache:             data cache

    address(optional): the cache line corresponding to this address will be invalidate, if not specified, the whole cache will be invaliated.

Example

C:\MinGW\bin>gdb-ocd.exe
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-mingw32 --target=arm-none-elf".
(gdb) set prompt (gdb-ocd)
(gdb-ocd)jtag config parport trst_and_srst 10 10 10 10 n n
(gdb-ocd)jtag parport wiggler 0x378 1
(gdb-ocd)jtag add 4 1 0xf
(gdb-ocd)target jtag-ocd 0 arm926ejs attach

© 2008 Tan Bin
SourceForge.net Logo Support This Project