6 Gdb is a great way to debug uClinux/ColdFire. Here is some simple gdb
7 usage instructions from Chris Johns <ccj@acm.org>.
10 -----------------------------------------------------------------------------
12 The driver currently uses the P&E BDM interface. For the driver and gdb
13 patch you can get the archive from:
16 ftp://skatter.usask.ca/pub/eric/BDM-Linux-gdb/gdb-4.17-bdm-990115.tar.gz
17 http://www.calm.hw.ac.uk/davidf/coldfire/gdb-4.17-bdm-990115.tar.gz
19 Unpack with a command like :
21 $ cd somewhere; tar zxf gdb-4.17-bdm-990115.tar.gz
23 Then look at the README file contained in the archive. This has the
24 detailed steps you need to follow. Comments and corrects are welcome.
26 Compile the driver, and library module and install. You will need to run
27 the MAKEDEV script in the `local_scripts' directory as root to create
28 the device nodes in the /dev directory.
30 Compile the test program and run it. The command line argument in the
31 release is not quite correct. Try :
35 If your BDM module is not connected to parallel port 0 you need to use a
36 different number at the end of the device filename. If you get failures
41 On RedHat this should place debug info into `/var/log/messages' and the
42 console. The chk program only raises the driver debug level to 1. It can
43 go higher for more info. High numbers can get quite verbose so watch
44 out. Send me any info or questions if you have problems.
46 The chk test covers most critical areas in the driver.
48 Patch gdb then build and install.
50 The driver is a kernel module and currently only supports 2.0.x kernels.
51 The driver breaks on 2.2.x kernels. I have not received any 2.2.x
52 patches. They are welcome.
54 To test gdb, start it with :
58 Copyright 1998 Free Software Foundation, Inc.
59 GDB is free software, covered by the GNU General Public License, and
61 welcome to change it and/or distribute copies of it under certain
63 Type "show copying" to see the conditions.
64 There is absolutely no warranty for GDB. Type "show warranty" for
66 This GDB was configured as "--host=i686-pc-linux-gnulibc1
67 --target=m68k-bdm-coff".
70 Once you have the gdb prompt, connect to the target with the gdb command
73 (gdb) target bdm /dev/bdmcf0
74 Remote bdm connected to /dev/bdmcf0
76 Again change the last number to be the parallel port you are connected
79 The driver and gdb patch also supports the cpu32 core as found in the
80 68360. You connect using another device, eg /dev/bdmcpu320.
82 Your target will have been reset and halted. You can now look at the
83 ROM. To dump the vector table try :
86 0x0: 0x000071c8 0xffe00400 0xffe00518 0xffe00518
87 0x10: 0xffe00518 0xffe00518 0xffe00518 0xffe00518
88 0x20: 0xffe00518 0xffe00518 0xffe00518 0xffe00518
90 This is from my 5206 eval board. GDB has no stack history at this point
91 so dumping all the registers will fail. You can select a frame then gdb
92 will dump the registers.
102 d2 0xfb9e6ec2 -73503038
103 d3 0xbd85fe43 -1115292093
105 d5 0xbd3931fd -1120325123
106 d6 0xbf3a28d0 -1086707504
108 a0 0x30000000 0x30000000
109 a1 0xffe08391 0xffe08391
110 a2 0x9b1b2fd3 0x9b1b2fd3
111 a3 0x33ef6c49 0x33ef6c49
112 a4 0x7fea5983 0x7fea5983
113 a5 0x2fabcbcf 0x2fabcbcf
117 pc 0xffe0c860 0xffe0c860
120 acr0 0x300f6000 0x300f6000
121 acr1 0x300f6000 0x300f6000
122 rambar 0x20000000 0x20000000
123 mbar 0x10000000 0x10000000
124 csr 0x1000000 0x1000000
133 Notice MBAR is not set. This could be confusing if are expecting to look
134 at devices connected to chip selects. The dbug monitor ROM has not run
135 so no coldfire resources have been setup.
137 The Coldfire has a nice feature for BDM reset debugging. If you do not
138 change the program counter with a command such as:
144 (gdb) set $pc=0xdeaddead
146 The coldfire core will perform the normal stack pointer and reset vector
147 fetch. For the sbc5206 eval board I am connected to, to step the dbug
151 1: x/i $pc 0xffe0c860: moveb %a0@(21),%d0
154 1: x/i $pc 0xffe00404: movel #-2097152,%d0
157 1: x/i $pc 0xffe0040a: moveal %d0,%sp
160 1: x/i $pc 0xffe0040c: movec %sp,%vbr
163 1: x/i $pc 0xffe00410: movel #16777216,%d0
166 1: x/i $pc 0xffe00416: movec %d0,%cacr
169 You might notice GDB repeats the last command entered if you just hit
172 When you run gdb connected to an embedded target like this the `run'
173 command is not used. The `target' command connects you to an existing
174 "process". The run command when used on a native system such as Linux
175 creates the "process" to be debugged. Your embedded target is an
176 existing "process" so no need to use the run command. You just step or
179 Now to running some code you have compiled with the -g option. The
180 driver has an example gdb init script. Look in `gdbScripts/5206.gdb'. I
181 usually copy this script to the directory where the coff file to be
182 debugged sits and rename it to `.gdbinit'. I am working on a boot rom
183 for the sbc5206 eval board. All I added to the end of the file in the
186 dir ../../../kernel/boot/net
187 dir ../../../kernel/boot/net/drivers/clock
188 dir ../../../kernel/boot/net/drivers/net
189 dir ../../../kernel/boot/net/loaders
190 dir ../../../kernel/boot/support
191 dir ../../../arch/m68k/5206/boot
193 target bdm /dev/bdmcf0
201 set print asm-demangle
205 $ m68k-bdm-coff-gdb sbc5206.coff
207 Copyright 1998 Free Software Foundation, Inc.
208 GDB is free software, covered by the GNU General Public License, and
210 welcome to change it and/or distribute copies of it under certain
212 Type "show copying" to see the conditions.
213 There is absolutely no warranty for GDB. Type "show warranty" for
215 This GDB was configured as "--host=i686-pc-linux-gnulibc1
216 --target=m68k-bdm-coff"...
220 0x404 <start+4>: lea 0x0 <V___ISSP>,%sp
221 0x40a <start+10>: movec %sp,%vbr
222 0x40e <start+14>: movel #536870913,%d0
223 0x414 <start+20>: movec %d0,3076
224 0x418 <start+24>: moveal #536871420,%sp
225 0x41e <start+30>: nop
226 0x420 <start+32>: nop
227 0x422 <start+34>: moveal #536870912,%a0
228 0x428 <start+40>: moveq #51,%d0
229 0x42a <start+42>: moveq #0,%d1
230 0x42c <start+44>: moveb %d0,%a0@
231 0x42e <start+46>: moveb %a0@,%d1
232 0x430 <start+48>: cmpl %d1,%d0
233 0x432 <start+50>: bnew 0x518 <_stop_cf>
234 0x436 <start+54>: notl %d0
235 0x438 <start+56>: andil #255,%d0
236 0x43e <start+62>: moveb %d0,%a0@
237 0x440 <start+64>: moveb %a0@,%d1
238 0x442 <start+66>: cmpl %d1,%d0
239 0x444 <start+68>: bnew 0x518 <_stop_cf>
241 Breakpoint 1 at 0x522: file cpuboot.c, line 63.
245 Breakpoint 1, boot_cpu () at cpuboot.c:63
246 63 CF_DISABLE_AND_INVALIDATE_CACHE();
251 61 /* disable and invalidate the instruction cache */
253 63 CF_DISABLE_AND_INVALIDATE_CACHE();
255 65 /* program the system protection register */
257 67 CF_SIM_WRITE_SYPCR(CF5206_BASE,
260 What happens here is the .gdbinit script programs the MBAR, chip selects
261 and enables the DRAM. DRAM is at 0. My linker command file places
262 `.text', '.data', and '.bss' one after each other at address 0. The
263 first part of the text seciton is the vector table. This how-ever is
264 moving away from gdb to the other tools and this mail is long enough at
268 Chris Johns Networks, Plessey Asia Pacfic Pty. Ltd.
269 mailto:ccj@acm.org mailto:cjohns@plessey.com.au
271 ________________________________________________________________________
272 ColdFire Discussion List
273 See: <http://www.WildRice.com/ColdFire/>
275 -----------------------------------------------------------------------------