Openocd

From Crashcourse Wiki

Jump to: navigation, search

Contents

[edit] Overview

Specifically, OpenOCD running on Fedora 20 for the BeagleBoard-xM, and its associated current issue(s), but there should be a little something here for everyone.

[edit] Notes

  • ftdi_sio loadable module

[edit] User's Guide changes

  • "sprung4b" should be "sprugn4b", and check validity of link
  • openocd.berlios.de -> openocd.sourceforge.net
  • Section 8.1, "interface transports" should be a config command
  • gdb_port, telnet_port can be used in R/O mode, but not tcl_port
  • "help exit" doesn't seem to show subcommands

[edit] Links

[edit] General OpenOCD links

[edit] Tin Can Tools links

[edit] elinux.org links

Quite a number of OpenOCD-related pages at http://elinux.org/Main_Page, some of which look old, redundant or dead.

... lots more coming ...

[edit] Installing and running openocd under Fedora 20

Simple. First:

# yum install openocd

Then, sadly, you need to hack a file:

# vi /usr/share/openocd/scripts/target/amdm37x.cfg

and edit line 144 to change cortex_a to cortex_a8:

target create $_TARGETNAME cortex_a8 -chain-position $_CHIPNAME.dap

It's not clear why this is necessary, it just is. I've already asked about this on the openocd-devel mailing list.

Finally, the command:

$ sudo openocd -f interface/flyswatter2.cfg -f board/ti_beagleboard_xm.cfg -c init -c "reset init"

[edit] Building openocd for Fedora 20 for the BeagleBoard-xM

Check out the Git repo:

$ git clone git://git.code.sf.net/p/openocd/code git

Next, rather than build everything else from source, just go with the Fedora packages, which seem sufficient:

# yum install libftdi libftdi-devel libusbx-devel

Then in the openocd source directory:

$ ./bootstrap
$ ./configure --enable-ftdi
$ make
$ sudo make install

which uses the 'newer' interface config file, so that you'd start OpenOCD slightly differently:

# openocd -f interface/ftdi/flyswatter2.cfg -f board/ti_beagleboard_xm.cfg -c init -c "reset init"

The newer interface file is discussed in this post on the OpenOCD user mailing list.

[edit] Running as non-root user

The Fedora libftdi package installs the udev file /etc/udev/rules.d/99-libftdi.rules, which contains the single line:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0664", GROUP="plugdev"

so you should need only be a member of the plugdev group to be able to run openocd as a non-root user. I tried it and it seems to work. Otherwise, you might need to install the openocd.udev file that comes with the source or the package.

[edit] Invoking OpenOCD (Flyswatter2 and BeagleBoard-xM)

From one window:

$ openocd -f interface/ftdi/flyswatter2.cfg -f board/ti_beagleboard_xm.cfg -c init -c "reset init"
Open On-Chip Debugger 0.8.0-dev-00294-gbc256b1 (2014-01-06-10:11)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
adapter speed: 10 kHz
Warn : dm37x.dsp: huge IR length 38
trst_only separate trst_push_pull
Info : clock speed 10 kHz
Info : JTAG tap: dm37x.jrc tap/device found: 0x2b89102f (mfg: 0x017, part: 0xb891, ver: 0x2)
Info : JTAG tap: dm37x.dap enabled
Info : dm37x.cpu: hardware has 6 breakpoints, 2 watchpoints
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x80000042, MEM_AP_TAR 0x54011140
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x80000042, MEM_AP_TAR 0x54011140
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x80000042, MEM_AP_TAR 0x54011140
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x80000042, MEM_AP_TAR 0x54011140
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x80000042, MEM_AP_TAR 0x54011150
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x80000042, MEM_AP_TAR 0x54011150
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x80000042, MEM_AP_TAR 0x540111c0
Error: JTAG-DP STICKY ERROR
Error: MEM_AP_CSW 0x80000042, MEM_AP_TAR 0x540111c0
adapter speed: 10 kHz
Info : JTAG tap: dm37x.jrc tap/device found: 0x2b89102f (mfg: 0x017, part: 0xb891, ver: 0x2)
Info : JTAG tap: dm37x.dap enabled
adapter speed: 1000 kHz
Warn : dm37x.cpu: ran after reset and before halt ...
Info : number of cache level 2
Error: cache l2 present :not supported
Error: mpdir not in multiprocessor format
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x800001d3 pc: 0x40200fa0
MMU: disabled, D-Cache: disabled, I-Cache: enabled

From a second window:

]$ telnet localhost 4444
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> 

Other things to check:

  • /dev/ttyUSB*
  • udevadm monitor

The tcl/interface/ftdi/flyswatter2.cfg file:

#
# TinCanTools Flyswatter2
#
# http://www.tincantools.com/product.php?productid=16153
#

interface ftdi
ftdi_device_desc "Flyswatter2"
ftdi_vid_pid 0x0403 0x6010

ftdi_layout_init 0x0538 0x057b
ftdi_layout_signal LED -ndata 0x0400
ftdi_layout_signal nTRST -data 0x0010
ftdi_layout_signal nSRST -data 0x0020 -noe 0x0100

The tcl/board/ti_beagleboard_xm.cfg file:

# BeagleBoard xM (DM37x)
#  http://beagleboard.org

set CHIPTYPE "dm37x"
source [find target/amdm37x.cfg]

# The TI-14 JTAG connector does not have srst.  CPU reset is handled in
# hardware.
reset_config trst_only

# "amdm37x_dbginit dm37x.cpu" needs to be run after init.

The target file, target/amdm37x.cfg, is fairly lengthy.

[edit] Procedures

See src/target/target.c and src/target/startup.tcl.

  • init_targets
  • init_board

[edit] GDB

  • default port 3333

[edit] Commands (related to BB-xM and FTDI)

[edit] Questions

  • Why are drscan and flush_count separate commands and also subcommands of jtag?

[edit] General

> version
> help [command_name]
> usage [command_name]
> halt [milliseconds]
> exit

[edit] Ports

> telnet_port [port]
> gdb_port [port]
> tcl_port [port]       (config only, why?)

[edit] Targets

> targets [target]
> target count          (DEPRECATED, "usage" might mention that)
> target names
> target types
> target current        (for this, "dm37x.cpu")

Also "target number number" is deprecated, "usage" could mention that as well.

[edit] Interfaces and transports and adapters

> interface_list
> transport list
> transport select
> adapter_name

[edit] Clocking stuff (not sure)

> adapter_khz

[edit] JTAG and scan chain

> jtag names
> scan_chain

[edit] Logging and debugging

> debug_level [number 0-3]
> log_output filename
Personal tools