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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [README.gdb] - Blame information for rev 98

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

Line No. Rev Author Line
1 19 jeremybenn
 
2
                        ========== WARNING ==========
3
 
4
This file is now obsolete. It is retained as a historical record of early
5
versions of Or1ksim and GDB for OpenRISC 1000. Consult the GDB 6.8
6
documentation for up to date advice on using GDB with Or1ksim.
7
 
8
                     ========== End of WARNING ==========
9
 
10
 
11
Originally by Chris Ziomkowski 
12
Some Additions by Heiko Panther 
13
 
14
Brief introduction to using GDB based debugging with or1ksim
15
 
16
GDB uses the JTAG proxy server included in or1ksim to communicate
17
directly with the simulator. Only 1 connection is allowed to the
18
proxy server at a time. Attempting a second connection will terminate
19
the previous connection. This is very useful when the gdb or1k
20
process terminates abnormally (such as when you are debugging the
21
debugger.) In this case it is impossible to notify the JTAG server
22
that the socket has shut down, and therefore it will assume that a
23
new connection implies the termination of the previous process.
24
 
25
The or1ksim will start the JTAG proxy server on the port specified
26
for service "jtag". If such a service is not specified, the server
27
will choose a random port number. This behavior can be overridden by
28
specifying the port number to the simulator using the -srv option.
29
As an example, "sim -srv 9999" starts up the simulator with the
30
JTAG proxy server on port 9999. This behavior is useful for those
31
people who do not have root access and can not add services to
32
the config files (such as university students operating in a shared
33
environment.)
34
 
35
As the JTAG proxy server runs only if there is data available for
36
reading, there is very little resource usage consumed by this
37
capability. However, in certain instances where gdb is not being
38
utilized, it is possible to disable the JTAG proxy server
39
entirely.  This will recover the few cycles necessary for the
40
poll() system call. (Tests indicate this has a negligible to
41
non existant impact on speed, however your mileage may vary.)
42
This behavior can be achieved by starting the simulator with
43
the command "sim -nosrv."
44
 
45
At startup, the simulator will execute random commands, just as
46
a real chip would do performing in this environment if the memory
47
was not initialized. If it is desired to simulate a ROM or FLASH
48
environment, these can be approximated by using the -loadmem option
49
to the simulator. For example, to simulate a 32k flash at location
50
0x8000, the command "sim -loadmem@0x8000 " could be
51
used, where  represents the name of the initialization
52
file. If the optional '@0x8000' flag is left off of the loadmem
53
statement, then the load will occur at location 0. Several loadmem
54
flags can appear on the command line to simulate different
55
memory blocks.
56
 
57
It is also possible to initialize all RAM to a predefined value,
58
which is usually 0x00000000 or 0xFFFFFFFF. This would be equivalent
59
to what is normally observed in a real world environment. However,
60
specific sequences are possible in case this is necessary. Alternatively,
61
random values can be assigned to memory, to check the behavior of a
62
process under different conditions. All of these options can be
63
handled by the "-initmem" option of the simulator. The following
64
command would startup the simulator with all memory initialized to
65
"1":
66
 
67
sim -initmem 0xFFFFFFFF
68
 
69
while this command would generate random values:
70
 
71
sim -initmem random
72
 
73
Once the simulator is started, it will print out something like
74
the following:
75
 
76
> bash-2.03$ sim
77
> JTAG Proxy server started on port 42240
78
> Machine initialization...
79
> Data cache tag: physical
80
> Insn cache tag: physical
81
> BPB simulation on.
82
> BTIC simulation on.
83
> Clock cycle: 4 ns
84
> RAM: 0x0 to 0x7aa80 (490 KB)
85
>
86
> simdebug off, interactive prompt off
87
> Building automata... done, num uncovered: 0/216.
88
> Parsing operands data... done.
89
> Resetting 4 UART(s).
90
> UART0 has problems with RX file stream.
91
> Resetting Tick Timer.
92
> Resetting Power Management.
93
> Resetting PIC.
94
> Exception 0x100 (Reset): Iqueue[0].insn_addr: 0x0  Eff ADDR: 0x0
95
>  pc: 0x0  pcnext: 0x4
96
>
97
 
98
Note that because we did not specify a server port, a random
99
port (42240) was selected for us (The "jtag" service does not
100
exist on this machine). We will need this value to create the
101
connection URL for the target command. It is now possible to
102
debug a program with gdb as follows:
103
 
104
> bash-2.03$ gdb
105
> GNU gdb 5.0
106
> Copyright 2000 Free Software Foundation, Inc.
107
> GDB is free software, covered by the GNU General Public License, and you are
108
> welcome to change it and/or distribute copies of it under certain conditions.
109
> Type "show copying" to see the conditions.
110
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
111
> This GDB was configured as "--host=sparc-sun-solaris2.7 --target=or32-rtems".
112
> (or1k) file "dhry.or32"
113
> Reading symbols from dhry.or32...done.
114
> (or1k) target jtag jtag://localhost:42240
115
> Remote or1k debugging using jtag://localhost:42240
116
> 0x0 in ?? ()
117
> (or1k) load dhry.or32
118
> Loading section .text, size 0x14fc lma 0x100
119
> Loading section .data, size 0x2804 lma 0x15fc
120
> Start address 0x100 , load size 15616
121
> Transfer rate: 124928 bits/sec, 488 bytes/write.
122
> (or1k) b main
123
> Breakpoint 1 at 0x51c: file dhry.c, line 176.
124
> (or1k) run
125
> Starting program: /usr3/home/chris/opencores/or1k/gdb-build/gdb/dhry.or32
126
>
127
> Breakpoint 1, main () at dhry.c:176
128
> 176       Next_Ptr_Glob = (Rec_Pointer) &x;
129
> (or1k)
130
 
131
The simulator window will have printed out the following, showing that
132
a breakpoint exception was asserted.
133
 
134
> Exception 0xd00 (Break): Iqueue[0].insn_addr: 0x51c  Eff ADDR: 0x0
135
> pc: 0x51c  pcnext: 0x520
136
 
137
Note that when the "run" command is given, the simulator will start
138
by jumping to the reset vector at location 0x100. You must start off
139
by placing a small bootloader at this location. A simple environment
140
capable of running C programs can be established by placing the
141
following code in a file called "start.s" and linking it to your
142
executable. As an example, the following will work. The file start.s
143
was derived from the output of a file start.c compiled by gcc:
144
 
145
or32-rtems-gcc -g -c -o start.o start.s
146
or32-rtems-gcc -g -c -DOR1K -o dhry.o dhry.c
147
or32-rtems-ld -Ttext 0x0 -o dhry.or32 start.o dhry.o
148
 
149
---------------------- CUT HERE -------------------------
150
 
151
# file start.s
152
.file   "start.s"
153
 
154
# This is the general purpose start routine. It
155
# sets up the stack register, and jumps to the
156
# _main program location. It should be linked at
157
# the start of all programs.
158
 
159
.text
160
        .align  4
161
        .org    0x100                   # The reset routine goes at 0x100
162
.proc _rst
163
        .def    _rst
164
        .val    _rst
165
        .scl    2
166
        .type   041
167
        .endef
168
        .global _rst
169
_rst:
170
        .def    .bf
171
        .val    .
172
        .scl    101
173
        .endef
174
        l.addi          r1,r0,0x7f00    # Set STACK to value 0x7f00
175
        l.addi          r2,r1,0x0       # FRAME and STACK are the same
176
        l.mfspr         r3,r0,17        # Get SR value
177
        l.ori           r3,r3,2         # Set exception enable bit
178
        l.jal           _main           # Jump to main routine
179
        l.mtspr         r0,r3,17        # Enable exceptions (DELAY SLOT)
180
 
181
.endproc _rst
182
        .def    _rst
183
        .val    .
184
        .scl    -1
185
        .endef
186
 
187
        .org    0xFFC
188
        l.nop                           # Guarantee the exception vector space
189
                                        # does not have general purpose code
190
 
191
# C code starts at 0x1000
192
 
193
---------------------- CUT HERE -------------------------
194
 
195
 
196
Setting registers
197
 
198
"info spr" commands give info about special purpose registers, "spr" commands set them.
199
"info spr" - display the SPR groups
200
"info spr " - display SPRs in 
201
"info spr " - display value in 
202
"spr  " - set  to 
203
 
204
Breaking for exceptions
205
 
206
You have to set a bit in the Debug Stop Register "dsr" for each exception you want
207
to stop on. Use "spr dsr ".
208
 
209
 
210
                        ========== WARNING ==========
211
 
212
This file is now obsolete. It is retained as a historical record of early
213
versions of Or1ksim and GDB for OpenRISC 1000. Consult the GDB 6.8
214
documentation for up to date advice on using GDB with Or1ksim.
215
 
216
                     ========== End of WARNING ==========

powered by: WebSVN 2.1.0

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