-
Notifications
You must be signed in to change notification settings - Fork 7
/
OpenOCD.mw
123 lines (69 loc) · 5.3 KB
/
OpenOCD.mw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
= About =
OpenOCD is a program that we can use to talk to our debug interface on our hardware via JTAG, over a variety of cables, in a realtively flexible manner. We can script up things in TCL to control the system, or we can run a GDB RSP server and do things from GDB.
This page contains information about the OpenRISC 1000 architecture port.
== Features ==
The proxy supports designs using either the[http://opencores.org/project,dbg_interface SoC Debug (Mohor) Interface] or [http://opencores.org/project,adv_debug_sys adv_debug_sys] to do the following:
* Memory access for program download, data inspection
* CPU register read and write
* CPU stall control
* CPU single stepping
* CPU software breakpoints
* All of the above via GDB
Support for other debug interface hardware can be added relatively easily.
= Downloading =
The OpenOCD code with basic OpenRISC 1000 support is found on the github openrisc organization.
git clone git://github.com/openrisc/openOCD.git
= Hardware requirements =
For the basic requirements of compiling and running OpenOCD see its [http://openocd.berlios.de/doc/html/index.html User Guide].
The required hardware depends on whether the FPGA's integrated JTAG TAP is being used. For the ''Mohor'' debug interface, a [http://openocd.berlios.de/doc/html/Debug-Adapter-Hardware.html OpenOCD-supported debug cable] will be required to interface with the FPGA design.
The ''Mohor'' support in OpenOCD has been tested with the [http://opencores.org/shop,item,3 ORSoC USB debug cable] against an [[ORPSoC]] system, but there's no reason why any other [http://openocd.berlios.de/doc/html/Debug-Adapter-Hardware.html OpenOCD-supported cable] wouldn't work.
The ''adv_debug_sys'' is capable of using the in-built JTAG TAP circuits in the FPGA, and thus doesn't necessarily require additional hardware. However, it can also be configured to use a separate TAP.
You must understand the design you're debugging to know which is right for you.
= Building =
== Bootstrap ==
The source from the git repository needs to be setup '''once''', and once only, before it can be configured. This is done with a provided bootstrap script, run as just:
./bootstrap
'''Note''': It may prompt you to install a few tools such as '''libtool''' and '''autoconf'''. Install these if they are not on your system. eg. on a Ubuntu system:
sudo apt-get install libtool autoconf
== Configure and compile ==
Make a build directory in <tt>openocd</tt> directory and configure depending on which debug interface you have in your FPGA.
mkdir build
cd build
=== adv_debug_sys ===
The following configures OpenOCD to work with the ''adv_debug_sys'' on an Altera FPGA. (This is as per instructions on [http://www.elec4fun.fr/2011-03-30-10-16-30/2012-08-22-20-50-31/or1k-on-de1-openocd elec4fun.fr]):
../configure --enable-usb_blaster_libftdi --enable-adv_debug_sys --enable-altera_vjtag --enable-maintainer-mode
=== Mohor debug unit ===
The following configures the proxy to be built to interface with the Mohor unit over an FTDI-based cable (such as the [http://opencores.org/shop,item,3 ORSoC USB debug cable]):
../configure --enable-ft2232_libftdi --enable-maintainer-mode
make
=== FTDI driver ===
'''Note''': You may be required to install the FTDI driver (if running make and it cannot find the <tt>ftdi.h</tt>, then this is the problem). Under Ubuntu this is done with:
sudo apt-get install libftdi-dev
= Running =
The following is an example of using the ''Mohor'' debug unit.
See [http://www.elec4fun.fr/2011-03-30-10-16-30/2012-08-22-20-50-31/or1k-on-de1-openocd this guide] for details on running OpenOCD against the ''adv_debug_sys''.
== Setup ==
OpenOCD uses TCL script fragments to configure different parts of the debug ''chain'' (transport, interface, protocol, hardware). The following TCL source was used during development to bring the system up. Place it in a file in the build directory (bld-openocd - presumably where you are running the following commands from.) Assume it's called or1k-dev.tcl for now:
source [find ../tcl/target/or1k.cfg]
proc or1k_test_init {} {
}
gdb_port 50001
init
#echo "Halting processor"
halt
foreach name [target names] {
set y [$name cget -endian]
set z [$name cget -type]
puts [format "Chip is %s, Endian: %s, type: %s" \
$name $y $z]
}
This tells OpenOCD to use the OpenRISC 1000 target configuration information which should be included with the project's source.
== Connecting to the board ==
Using something like the following to a) tell OpenOCD which cable to use to connect, and b) which TCL command file to then run some commands from. From the build directory run:
sudo ./src/openocd -f ../tcl/interface/orsoc-jtag.cfg -f or1k-dev.tcl
OpenOCD should establish communication with the target and stall it and wait for GDB to connect.
Add the switch ''--debug 3'' to the command line to see lots of debug output.
Note - I had to run with ''sudo'' but that's because my permissions weren't set correctly on the USB debug cable. This is not a good thing to do, and it's advisable that correct permissions on the USB debug cable are set to allow users to access it.
= Issues =
* Lack of usage documentation. OpenOCD is quite powerful and at the moment we're using it solely as a GDB proxy.
* Resetting the target is not done properly yet in the ''mohor'' port.