/*
* linux/arch/arm/mach-at91rm9200/kgdb-serial.c
*
* Provides low level kgdb serial support hooks for PXA2xx boards
*
* Author: dengdalong
* Copyright: (C) 2002-2005 MontaVista Software Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
//* Define the baud rate divisor register
AT91F_US_SetBaudrate(pUSART, mainClock, baudRate);
//* Write the Timeguard Register
pUSART->US_TTGR = timeguard;
//* Define the USART mode
pUSART->US_MR = mode ;
}
static int kgdb_serial_init(void)
{
// Open PIO for DBGU
AT91_DBGU_CfgPIO();
// Configure DBGU
AT91F_US_Configure (
pUSART, // DBGU base address
at91_master_clock, // 60 MHz
AT91C_US_ASYNC_MODE , // mode Register to be programmed
UART_BAUDRATE , // baudrate to be programmed
0); // timeguard to be programmed
// Enable Transmitter and Receiver
pUSART->US_CR = (AT91C_US_RXEN | AT91C_US_TXEN);
return 0;
}
static void kgdb_serial_putchar(int c)
{
if (!(pUSART->US_CR | AT91C_US_RXEN | AT91C_US_TXEN))
kgdb_serial_init();
while (!(pUSART->US_CSR & AT91C_US_TXRDY)) //wait tx
cpu_relax();
pUSART->US_THR = (c & 0x1FF);
}
static void kgdb_serial_flush(void)
{
if ( (pUSART->US_CR | AT91C_US_RXEN) && (pUSART->US_CR | AT91C_US_TXEN) )
while (!(pUSART->US_CSR & AT91C_US_TXRDY))
cpu_relax();
}
static int kgdb_serial_getchar(void)
{
unsigned char c;
if (!(pUSART->US_CR | AT91C_US_RXEN | AT91C_US_TXEN))
kgdb_serial_init();
while (!(pUSART->US_CSR & AT91C_US_RXRDY))
cpu_relax();
配置完后,我们就按照正常的配置方式配置内核,对于kgdb选项我们要选上:
kernel hacking ---> KGDB: kernel debugging with remote gdb
--->KGDB: Console messages through gdb
--->Method for KGDB communication(KGDB: Use only kernel modules for I/O)
内核配置完毕之后,我们就可以make zImage来生成zImage。然后通过uboot的mkimage来生成uImage. 这边还需要注意的是,在uboot传递给kernel的启动参数必须加上kgdbwait参数。在kgdb的官方文档中介绍的kgdbwait 8250kgdb=0,115200。因为我们不是用8250的串口控制器,所以我们只要传递kgdbwait的这个参数。(本人暂时是这样做的)。我的启动参数如下:
bootargs=root=/dev/ram rw kgdbwait initrd=0x20a00000,4M init=/linux
rc console=ttyS0,115200,mem=16m ip=192.168.2.10
下载内核后,启动内核:
## Booting image at 20007fc0 ...
Image Name: Linux 2.6.15.5
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 928060 Bytes = 906.3 kB
Load Address: 20007fc0
Entry Point: 20008000
Verifying Checksum ... OK
XIP Kernel Image ... OK
Starting kernel ...
Uncompressing Linux.............................................................
..... done, booting the kernel.
这个时候我在host端上开启我的gdb:
[root@dengdalong linux-2.6.15.5]# ./gdbmod-2.4 vmlinux
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/tls/i686/libthread_db.so.1".
(gdb) set remotebaud 115200
(gdb) target remote /dev/ttyS0
Remote debugging using /dev/ttyS0
do_early_param (param=0xc001e195 "kgdbwait", val=0x0) at init/main.c:412
412 {
(gdb) break console_init
Breakpoint 1 at 0xc0016d0c: file drivers/char/tty_io.c, line 2928.
(gdb) c
Continuing.
[New thread 32768]
Program received signal SIGTRAP, Trace/breakpoint trap.
0x2001dc08 in ?? () at proc_fs.h:194
194 remove_proc_entry(name,proc_net);
(gdb) c
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x2001dc08 in ?? () at proc_fs.h:194
194 remove_proc_entry(name,proc_net);
(gdb) list
189 return res;
190 }
191
192 static inline void proc_net_remove(const char *name)
193 {
194 remove_proc_entry(name,proc_net);
195 }
196
197 #else
这边我们可以判断host端的gdb已经和target上的kgdb连接上了。但是我发现内核根本无法启动,一直在0x2001dc08 in ?? () at proc_fs.h:194
194 remove_proc_entry(name,proc_net) 停下来。这边还是个问题。不知道哪位大侠能够帮忙解决一下。我也将继续努力,希望能给大家送上好消息作者: DesignInside 时间: 2007-09-13 13:54
194 remove_proc_entry(name,proc_net) 停下来。
你怎么也是在这里停下来
我们公司前段时间移植操作系统,port上去后,启动一半就停下来
gdb的时候也是在这里停下来,现在也在找原因作者: dengdalong 时间: 2007-09-13 15:25
augustusqing网友提醒了我一下,我在host端上用的gdb是kgdb生成好的gdbmod2.4,这个是针对i386平台的。所以我们应该去下载gdb6.4的版本来编译出arm-linux-gdb来连接target上的kgdb。