aboutsummaryrefslogtreecommitdiff
path: root/Documentation/blackfin/kgdb.txt
blob: 84f6a484ae9ae5e2506caf63d8a0d5429f2c0c53 (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
			A Simple Guide to Configure KGDB

			Sonic Zhang <sonic.zhang@analog.com>
				Aug. 24th 2006


This KGDB patch enables the kernel developer to do source level debugging on
the kernel for the Blackfin architecture.  The debugging works over either the
ethernet interface or one of the uarts.  Both software breakpoints and
hardware breakpoints are supported in this version.
http://docs.blackfin.uclinux.org/doku.php?id=kgdb


2 known issues:
1. This bug:
       http://blackfin.uclinux.org/tracker/index.php?func=detail&aid=544&group_id=18&atid=145
   The GDB client for Blackfin uClinux causes incorrect values of local
   variables to be displayed when the user breaks the running of kernel in GDB.
2. Because of a hardware bug in Blackfin 533 v1.0.3:
       05000067 - Watchpoints (Hardware Breakpoints) are not supported
   Hardware breakpoints cannot be set properly.


Debug over Ethernet:
 
1. Compile and install the cross platform version of gdb for blackfin, which
   can be found at $(BINROOT)/bfin-elf-gdb.

2. Apply this patch to the 2.6.x kernel.  Select the menuconfig option under
   "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".
   With this selected, option "Full Symbolic/Source Debugging support" and 
   "Compile the kernel with frame pointers" are also selected.

3. Select option "KGDB: connect over (Ethernet)".  Add "kgdboe=@target-IP/,@host-IP/" to
   the option "Compiled-in Kernel Boot Parameter" under "Kernel hacking".

4. Connect minicom to the serial port and boot the kernel image.

5. Configure the IP "/> ifconfig eth0 target-IP"

6. Start GDB client "bfin-elf-gdb vmlinux".

7. Connect to the target "(gdb) target remote udp:target-IP:6443".

8. Set software breakpoint "(gdb) break sys_open".

9. Continue "(gdb) c".

10. Run ls in the target console "/> ls".

11. Breakpoint hits. "Breakpoint 1: sys_open(..."

12. Display local variables and function paramters.
    (*) This operation gives wrong results, see known issue 1.

13. Single stepping "(gdb) si".

14. Remove breakpoint 1. "(gdb) del 1"

15. Set hardware breakpoint "(gdb) hbreak sys_open".

16. Continue "(gdb) c".

17. Run ls in the target console "/> ls".

18. Hardware breakpoint hits. "Breakpoint 1: sys_open(...".
    (*) This hardware breakpoint will not be hit, see known issue 2.

19. Continue "(gdb) c".

20. Interrupt the target in GDB "Ctrl+C".

21. Detach from the target "(gdb) detach".

22. Exit GDB "(gdb) quit".


Debug over the UART:

1. Compile and install the cross platform version of gdb for blackfin, which
   can be found at $(BINROOT)/bfin-elf-gdb.

2. Apply this patch to the 2.6.x kernel.  Select the menuconfig option under
   "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".
   With this selected, option "Full Symbolic/Source Debugging support" and 
   "Compile the kernel with frame pointers" are also selected.

3. Select option "KGDB: connect over (UART)".  Set "KGDB: UART port number" to be
   a different one from the console.  Don't forget to change the mode of
   blackfin serial driver to PIO.  Otherwise kgdb works incorrectly on UART.
 
4. If you want connect to kgdb when the kernel boots, enable
   "KGDB: Wait for gdb connection early" 

5. Compile kernel.

6. Connect minicom to the serial port of the console and boot the kernel image.

7. Start GDB client "bfin-elf-gdb vmlinux".

8. Set the baud rate in GDB "(gdb) set remotebaud 57600".

9. Connect to the target on the second serial port "(gdb) target remote /dev/ttyS1".

10. Set software breakpoint "(gdb) break sys_open".

11. Continue "(gdb) c". 

12. Run ls in the target console "/> ls". 

13. A breakpoint is hit. "Breakpoint 1: sys_open(..."

14. All other operations are the same as that in KGDB over Ethernet. 


Debug over the same UART as console:

1. Compile and install the cross platform version of gdb for blackfin, which
   can be found at $(BINROOT)/bfin-elf-gdb.

2. Apply this patch to the 2.6.x kernel.  Select the menuconfig option under
   "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".
   With this selected, option "Full Symbolic/Source Debugging support" and 
   "Compile the kernel with frame pointers" are also selected.

3. Select option "KGDB: connect over UART".  Set "KGDB: UART port number" to console.
   Don't forget to change the mode of blackfin serial driver to PIO.
   Otherwise kgdb works incorrectly on UART.
 
4. If you want connect to kgdb when the kernel boots, enable
   "KGDB: Wait for gdb connection early" 

5. Connect minicom to the serial port and boot the kernel image. 

6. (Optional) Ask target to wait for gdb connection by entering Ctrl+A. In minicom, you should enter Ctrl+A+A.

7. Start GDB client "bfin-elf-gdb vmlinux".

8. Set the baud rate in GDB "(gdb) set remotebaud 57600".

9. Connect to the target "(gdb) target remote /dev/ttyS0".

10. Set software breakpoint "(gdb) break sys_open".

11. Continue "(gdb) c". Then enter Ctrl+C twice to stop GDB connection.

12. Run ls in the target console "/> ls". Dummy string can be seen on the console.

13. Then connect the gdb to target again. "(gdb) target remote /dev/ttyS0".
    Now you will find a breakpoint is hit. "Breakpoint 1: sys_open(..."

14. All other operations are the same as that in KGDB over Ethernet.  The only
    difference is that after continue command in GDB, please stop GDB
    connection by 2 "Ctrl+C"s and connect again after breakpoints are hit or
    Ctrl+A is entered.