OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or_debug_proxy/] [README] - Blame information for rev 1781

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1779 julius
===============================================================================
2
-- OpenRISC Debug Proxy --
3
===============================================================================
4
 
5
===============================================================================
6
-- Description --
7
===============================================================================
8
A console application that implements a GDB stub and various ways to
9
communicate with an OpenRISC processor system. This done by initally making a
10
connection to a target system before handling a connection from a GDB client
11
and relaying debug commands. Connections to the target can be made in many
12
ways, however debugging FPGA or ASIC targets will be through use of the ORSoC
13
USB debug cable.
14
===============================================================================
15
-- Versions --
16
===============================================================================
17
0.1.0 090201 jb@orsoc.se
18
0.1.1 090304 jb@orsoc.se
19
0.1.2 090511 jb@orsoc.se
20
 
21
===============================================================================
22
-- Installation --
23
===============================================================================
24
 
25
The OR debug proxy application runs on multiple platforms only requiring
26
slightly different driver configurations on each. Currently, Cygwin Windows,
27
several Linux distos and Mac OS X (10.4 and above) are supported. All require
28
installation of some form of the FTDI Chip FTD2XX driver. Instructions for
29
each platform follow.
30
 
31
-------------------------------------------------------------------------------
32
-- Installation on Cygwin Windows --
33
-------------------------------------------------------------------------------
34
 
35
-- ORSoC OpenRISC USB debug cable driver installation --
36
 
37
  As per the installation instructions included in FTDI Chip's D2XX Windows
38
  driver.  http://www.ftdichip.com/Drivers/D2XX.htm
39
 
40
-- Compilation of the OpenRISC Debug Proxy application --
41
 
42
   While in the same directory which this file is located in, run a simple
43
   "make" command.
44
 
45
       user@cygwin-host ~/or_debug_proxy
46
       $ make
47
 
48
   Run the resulting executable (or_debug_proxy.exe) for usage details.
49
 
50
-------------------------------------------------------------------------------
51
-- Installation on Linux
52
-------------------------------------------------------------------------------
53
 
54
-- ORSoC OpenRISC USB debug cable driver installation --
55
 
56
Before we begin:
57
 
58
It is required that the Linux distribution have a version 2.4 kernel, or
59
above. This is due to the USB driver libraries by FTDI Chip used to interface
60
with the USB debug device.
61
 
62
The ORSoC USB debugger cable uses a FTDI dual UART/FIFO chip.
63
 
64
An aside: These USB to serial devices typically trigger the loading of another
65
FTDI driver when they're attached to the system. This is the ftdi_sio driver
66
and now comes standard in newer kernels. This is of use to us, as one of the
67
two serial devices will remain is a standard uart under /dev/ttyUSBx. However,
68
to enable a high-speed JTAG interface with our hardware we require newer,
69
specialised drivers from FTDI called the D2XX drivers.
70
 
71
The Linux driver can be obtained from FTDI Chip's website,
72
http://www.ftdichip.com, and is found under the links to "Drivers" and then
73
"D2XX". At the time of writing, the latest version was libftd2xx 0.4.16 and
74
could be downloaded directly off their site from
75
http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16.tar.gz
76
 
77
Statically linked driver:
78
 
79
The simplest way to enable these drivers is to link the application
80
statically - that is, have a copy of the driver along with the debugging
81
application. This is much simpler than the following driver installation
82
instructions. Typically in the FTDI drivers there is also a directory called
83
static_lib/ and this contains a driver that can be statically linked against
84
when compiling. To compile the OpenRISC debug proxy like this, copy the file in
85
that static_lib/ path into the lib/ directory under the or_debug_proxy/
86
build directory, and do:
87
 
88
      user@host:~/or_debug_proxy$ make or_debug_proxy_static
89
 
90
This will result in the executable being statically linked to the driver file
91
in the the lib/ folder.
92
 
93
Dynamically linked driver install directions:
94
 
95
Uncompress the driver package (tar xzvf libftd2xx0.4.16.tar.gz) and read the
96
file "readme.dat" located inside, but don't complete their way of installing
97
yet. Their installation method should be modified slightly to allow easier use
98
of the USB device by users. Read the following before performing the install
99
as per the instructions in "readme.dat", and ammend their installation process
100
as you go.
101
 
102
* In step 4, create an additional symbolic link, however this time with only a
103
  trailing zero, like so:
104
 
105
  user@host:/usr/local/lib$ ln -s libftd2xx.so.x.x.xx libftd2xx.so.0
106
 
107
* Again, in step 6, create an additional symbolic link with only a trailing
108
  zero:
109
 
110
  user@host:/usr/lib$ ln -s /usr/local/lib/libftd2xx.so.x.x.xx libftd2xx.so.0
111
 
112
* In step 7 (the following may vary depending on your distribution, however in
113
  the most recent Ubuntu our suggested modification was required) instead of
114
  the line provided in "readme.dat", use the following in your /etc/fstab file
115
  (note the difference is a change from "usbdevfs" to "usbfs")
116
 
117
     none /proc/bus/usb usbfs defaults,devmode=0666 0 0
118
 
119
* The last step (mount -a) outlined in "readme.dat" can then be performed.
120
 
121
-- Setting USB device permissions --
122
 
123
Depending on the Linux distribution and how recent it is, the method for
124
defining the permissions of the USB device when it's loaded by the kernel can
125
vary.
126
 
127
* Recent udev systems (most 2.6 kernel systems)
128
 
129
There can be variations in the way udev organises its files for setting up
130
rules and permissions of devices attached to the system, but the following
131
should cover most systems.
132
 
133
Do a listing of the udev rules directory
134
 
135
        user@host:~$ ls /etc/udev/rules.d/
136
 
137
There should be a file somewhere, with the word "permissions" in the name. On
138
some systems it could be called "40-permissions.rules", on others possibly
139
"020_permissions.rules". Locate the permissions file in /etc/udev/rules.d/
140
and, as the super user (root), open the file to edit. The author prefers nano.
141
 
142
      user@host:/etc/udev/rules.d$ sudo nano 40-permissions.rules
143
      [sudo] password for user:
144
 
145
Of course, editing as super user (sudo'ing) will require the ability to sudo.
146
 
147
The following can differ from system to system. In this case, a recent version
148
of Ubuntu, the file "40-permissions.rules" was present and will be edited.
149
 
150
In this particular permissions file there are different sections, some with
151
labels.
152
 
153
Search for the lines with LABEL="usb_serial_start" and
154
LABEL="usb_serial_end". In BETWEEN these two LABEL lines, insert two new lines
155
containing the following:
156
 
157
  # Permissions for ORSoC USB debugger FT2232 device
158
  ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0666", GROUP="tty"
159
 
160
If these LABEL="" lines cannot be found (for instance, different distros have
161
their udev setup differently) insert the above line anywhere in the file. This
162
is not a definite way of enabling these permissions, and udev exists in many
163
forms and configurations, so if this does not work, please contact the author
164
regarding the issue.
165
 
166
* Fedora 9
167
 
168
As an example of a slightly different system, Fedora 9 does not have a
169
xx-permissions.rules file. The solution is to create a new file, but in this
170
case choose the name "51-permissions.rules". It can have just the rule listed
171
above:
172
 
173
  # Permissions for ORSoC USB debugger FT2232 device
174
  ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0666", GROUP="tty"
175
 
176
The reason for the filename change is that the udev rules files are read in
177
lexical order (i.e. the order they would appear in a dictionary). With Fedora
178
9 the old FTDI driver is included as standard, and there is default rule in
179
50-udev-default.rules, which would override anything in 40-permissions.rules
180
(since it would be read first). By using the name 51-permissions.rules, our
181
rule will override anything set in 50-udev-default.rules.
182
 
183
If you find problems with permissions, then check that no later rules files
184
are overriding settings.
185
 
186
The devices whose permissions are set are /dev/ttyUSB0 /dev/ttyUSB1, the
187
/dev/usbdevnnn for the USB slot (nnn) being used, and the files in
188
/dev/bus/usb/nnn/xxx. They should all be in group tty and have permission
189
rw-rw-rw.
190
 
191
* Older systems, (early udev, devfs)
192
 
193
None of these systems were tested, however it should be easy enough to locate
194
the device by the vendor ID and product ID on the USB bus. See the Udev
195
instructions above for these values.
196
 
197
* Reloading the ftdi_sio driver
198
 
199
If it is desired that the D2XX drivers be unloaded and the original ftdi_sio one
200
reactivated (recreating the two /dev/ttyUSB devices), it is as simple as
201
removing and replacing the USB dongle from the system. However, it can also be
202
done at the prompt by first running as root "modprobe -r ftdi_sio", and then
203
"modprobe ftdi_sio vendor=0x0403 product=0x6010", which totally removes and
204
then reloads the device.
205
 
206
-- Compilation of the OpenRISC Debug Proxy application --
207
 
208
   While in the same directory which this file is located in, run a simple
209
   "make" command.
210
 
211
       user@host:~/or_debug_proxy$ make
212
 
213
   The proxy application can then be run with the desired options, or for
214
   usage details, run the program with no options specified.
215
 
216
       user@host:~/or_debug_proxy$ ./or_debug_proxy
217
 
218
       Invalid or insufficient arguments
219
 
220
       OpenRISC GDB proxy server usage: or_debug_proxy -server_type port
221
 
222
       server_type:
223
            -r Start a server using RSP, connection to hadware target via
224
               USB
225
            -j Start a server using legacy OR remote JTAG protocol, to
226
               hardware target via USB
227
            -v Start a server using RSP, connection to RTL sim. VPI server
228
               target via sockets
229
 
230
        port_number:
231
            Any free port within the usable range of 0 - 65535
232
 
233
        Example:
234
            Start a GDB server on port 5555, using RSP, connecting to
235
            hardware target via USB
236
            or_debug_proxy -r 5555
237
 
238
 
239
* Platforms tested, and known to be working, on:
240
  Ubuntu 8.04
241
  Debian
242
 
243
-------------------------------------------------------------------------------
244
-- Installation on Mac OS X --
245
-------------------------------------------------------------------------------
246
 
247
-- ORSoC OpenRISC USB debug cable driver installation --
248
 
249
  As per the installation instructions included in FTDI Chip's D2XX Mac OS X
250
  driver.  http://www.ftdichip.com/Drivers/D2XX.htm
251
 
252
-- Compilation of the OpenRISC Debug Proxy application --
253
 
254
   As per the Linux instructions.
255
 
256
 
257
* Note: Tested on an Intel Mac, running OS X version 10.4
258
 
259
 
260
 
261
===============================================================================
262
-- Usage notes --
263
===============================================================================
264
 
265
When the program initialises it sets up some form of communication with an
266
OpenRISC processor (developed and tested with a OR1k design similar to the
267
ORPSoC design found in the OR1k project archive on OpenCores), either via a
268
USB debug cable or via sockets interface to an RTL simulation. After this, it
269
waits for a connection from GDB, and then the debugging session can begin.
270
 
271
The proxy has been written to be robust, for example it will hopefully handle
272
disruptions like processor crashes, hardware resets, and connection dropouts
273
gracefully enough to not require a complete restart of the proxy and GDB.
274
 
275
Some basic mechanics of the proxy are as follows:
276
 
277
* When the program is "continued" from GDB, the proxy will poll the previous
278
  program counter (PPC), checking it against the internal list of software
279
  breakpoints, at second intervals to see if a software breakpoint has been
280
  reached.
281
 
282
* The one second polling also applies to "interrupt" (^C signals) from GDB,
283
  which will cause the processor to be stalled, wherever it is, and control
284
  returned to GDB (the proxy will await further commands from GDB.) It is
285
  optional to implement this awareness of the interrupt signal from GDB, but
286
  the developers have found this functionality extremely useful and thought
287
  others might too.
288
 
289
* Troubleshooting tip: If the proxy prints out the following line(s):
290
                  RSP step with signal 'S04' received
291
  when attempting to continue, or single step, a program from GDB, it is
292
  necessary to restart both the proxy and GDB before being continuing.
293
  This bug is perhaps caused by changing the file GDB is debugging during the
294
  same session.
295
 
296
TODO List:
297
     * Explicit char and short reading and writing ability:
298
       Currently only full word writing and reading is supported by the proxy.
299
       It would be great if individual words and chars could be read also. It
300
       is possible to receive such requests from GDB, so there's no reason why
301
       they shouldn't be supported. It should be simple enough to implement.
302
     * Correct organisation of non-word aligned reading
303
       There's some problems when reading a word from a non-word aligned
304
       boundary. This should be possible, for instance in GDB, doing something
305
       like "x/4 0x101" should read the four bytes starting at address 0x101
306
       and should display them LSB first. However this doesn't appear to
307
       function as intended.
308
     * USB<->JTAG Driver TODO: Increase speed of the proxy
309
       It appears that the current transfer rate of around 20k/s is due to
310
       pauses in the driver. This was deteremined by profiling the proxy and
311
       noticing that, over a 4-odd megabyte transfer from GDB, taking about 4
312
       minutes, the proxy only executed for 2.5 seconds, and the three most
313
       used functions, accounting for 50% of execution were functions in the
314
       driver. This indicates that either better use of, or better
315
       implementation of, the driver could dramatically increase speed.
316
     * USB<->JTAG Driver TODO:
317
       Get the latest version of the MPSSE function code (from
318
       http://ftdichip.com/Projects/MPSSE/FTCJTAG/FTCJTAG_Source.zip at last
319
       check) and update our Linux compatible version with the ones here. This
320
       might provide improved stability or performance, but from the list of
321
       improvements made to the files from our version it doesn't appear like
322
       it would result in significant improvement in the proxy app.
323
     * Better README
324
       It would be nice to provide more important documentation of nuances of
325
       the proxy operation

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.