Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5ac0129 authored by Sonic Zhang's avatar Sonic Zhang Committed by Bryan Wu
Browse files

Blackfin arch: add supporting for kgdb

parent 5d2e3213
Loading
Loading
Loading
Loading

Documentation/blackfin/kgdb.txt

deleted100644 → 0
+0 −155
Original line number Diff line number Diff line
			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.
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@ menu "Kernel hacking"

source "lib/Kconfig.debug"

config HAVE_ARCH_KGDB
       def_bool y

config DEBUG_MMRS
	bool "Generate Blackfin MMR tree"
	select DEBUG_FS
+13 −8
Original line number Diff line number Diff line
@@ -124,9 +124,16 @@ enum regnames {
/* Number of bytes of registers.  */
#define NUMREGBYTES BFIN_NUM_REGS*4

#define BREAKPOINT() asm("   EXCPT 2;");
static inline void arch_kgdb_breakpoint(void)
{
	asm("   EXCPT 2;");
}
#define BREAK_INSTR_SIZE	2
#define HW_BREAKPOINT_NUM		6
#define CACHE_FLUSH_IS_SAFE	1
#define HW_INST_WATCHPOINT_NUM	6
#define HW_WATCHPOINT_NUM	8
#define TYPE_INST_WATCHPOINT	0
#define TYPE_DATA_WATCHPOINT	1

/* Instruction watchpoint address control register bits mask */
#define WPPWR		0x1
@@ -163,10 +170,11 @@ enum regnames {
#define WPDAEN1		0x8
#define WPDCNTEN0	0x10
#define WPDCNTEN1	0x20

#define WPDSRC0		0xc0
#define WPDACC0		0x300
#define WPDACC0_OFFSET	8
#define WPDSRC1		0xc00
#define WPDACC1		0x3000
#define WPDACC1_OFFSET	12

/* Watchpoint status register bits mask */
#define STATIA0		0x1
@@ -178,7 +186,4 @@ enum regnames {
#define STATDA0		0x40
#define STATDA1		0x80

extern void kgdb_print(const char *fmt, ...);
extern void init_kgdb_uart(void);

#endif
Loading