Archive

Posts Tagged ‘Kernel’

GT-P6800 Kernel Building Error missing terminating ” character

March 16th, 2012 No comments

从三星的https://opensource.samsung.com下载了GT-6800的源码,自己编译了一下,结果Kernel出了个奇怪的错误: ‘error: missing terminating ” character’ 和 ‘error: expected expression before ‘)’ token’, 在网上搜了一圈找到一个解决方法,是因为系统使用的是中文,如果设在为英文环境就好了。

具体错误信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
border@b0rder:/bvcom/P6800/GT-P6800_CHN_HC_Opensource/GT-P6800_CHN_Kernel$ make c210_p8_rev01_defconfig
border@b0rder:/bvcom/P6800/GT-P6800_CHN_HC_Opensource/GT-P6800_CHN_Kernel$ make
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: “include/generated/mach-types.h”是最新的。
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      drivers/media/video/samsung/mali/common/mali_kernel_core.o
arm-none-linux-gnueabi-gcc: ": No such file or directory
<command-line>:0: warning: missing terminating " character
drivers/media/video/samsung/mali/common/mali_kernel_core.c: In function 'mali_kernel_constructor':
drivers/media/video/samsung/mali/common/mali_kernel_core.c:172: error: missing terminating " character
drivers/media/video/samsung/mali/common/mali_kernel_core.c:172: error: expected expression before ')' token
make[5]: *** [drivers/media/video/samsung/mali/common/mali_kernel_core.o] 错误 1
make[4]: *** [drivers/media/video/samsung/mali] 错误 2
make[3]: *** [drivers/media/video/samsung] 错误 2
make[2]: *** [drivers/media/video] 错误 2
make[1]: *** [drivers/media] 错误 2
make: *** [drivers] 错误 2

查看一下 drivers/media/video/samsung/mali/common/mali_kernel_core.c 的代码和宏:

1
2
3
4
5
6
    err  = initialize_subsystems();
    if (_MALI_OSK_ERR_OK != err) goto error3;
 
    MALI_PRINT(("Mali device driver %s loaded\n", SVN_REV_STRING));   // 172 line
 
    MALI_SUCCESS;

宏:

1
2
3
4
#define MALI_PRINT(args) do{ \
	MALI_PRINTF(("Mali: ")); \
	MALI_PRINTF(args); \
	} while (0)

看代码没有什么问题, 参考了这里的解决方法: http://bbs.chinaunix.net/thread-2317413-1-1.html

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
border@b0rder:/bvcom/P6800/GT-P6800_CHN_HC_Opensource/GT-P6800_CHN_Kernel$ locale
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:en
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
 
border@b0rder:/bvcom/P6800/GT-P6800_CHN_HC_Opensource/GT-P6800_CHN_Kernel$ export LANG=en_US.UTF-8
border@b0rder:/bvcom/P6800/GT-P6800_CHN_HC_Opensource/GT-P6800_CHN_Kernel$ export LANGUAGE=en_US:en
 
border@b0rder:/bvcom/P6800/GT-P6800_CHN_HC_Opensource/GT-P6800_CHN_Kernel$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C

重新设置了locale,就可以正常编译通过了,真是奇怪。

参考: http://bbs.chinaunix.net/thread-2317413-1-1.html

–EOF–

Linux LCD驱动移植笔记

March 12th, 2012 No comments

由于项目的需要移植了一个Citizen的0.46英寸的LCD, 很久没有移植LCD驱动了,简单记录一下,避免时间长了忘记怎么改.
主要修改了一下几个文件:
.config | 5 +-
arch/arm/mach-s5pv210/mach-smdkc110.c | 150 ++++++++++-
drivers/video/samsung/Kconfig | 9 ++-
drivers/video/samsung/Makefile | 1 +
drivers/video/samsung/s3cfb.c | 10 ++
drivers/video/samsung/s3cfb_flocs600.c | 46 ++++++++++

1. .config
在make menuconfig里面选中我们移植好的flocs600选项

2. mach-smdkc110.c
主要定义LCD的分辨率,LCD初始化信息以及GPIO管脚的配置,lcd电源,背光等想设置信息。

3. Kconfig, Makefile
在make menuconfig中增加flocs600选项

4. s3cfb.c
WIN0 在uboot中使用了,但是为了保持uboot的logo显示,所以uboot不关闭win0但是 如果不关闭win0,会导致播放视频和camera preview花屏。

5. s3cfb_flocs600.c
lcd实际的驱动

大概就改这些东西,由于板子还没有回来,没有实际测试,估计在实际调整的时候需要再配置timing.

详细patch如下:

From 49e15e380f2b9c779ad7cad2bd7544ef506aa17f Mon Sep 17 00:00:00 2001
From: Bian Jiang
Date: Mon, 12 Mar 2012 18:26:32 +0800
Subject: [PATCH] LCD: Porting Citizen FL0904 0.46" SVGA flocs600
 
---
 .config                                |    5 +-
 arch/arm/mach-s5pv210/mach-smdkc110.c  |  150 +++++++++++++++++++++++++++++++-
 drivers/video/samsung/Kconfig          |    9 ++-
 drivers/video/samsung/Makefile         |    1 +
 drivers/video/samsung/s3cfb.c          |   10 ++
 drivers/video/samsung/s3cfb_flocs600.c |   46 ++++++++++
 6 files changed, 217 insertions(+), 4 deletions(-)
 create mode 100644 drivers/video/samsung/s3cfb_flocs600.c
 
diff --git a/.config b/.config
index 29d2580..d75abfc 100644
--- a/.config
+++ b/.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.35.7
-# Thu Mar  8 16:22:49 2012
+# Mon Mar 12 18:14:42 2012
 #
 CONFIG_ARM=y
 CONFIG_HAVE_PWM=y
@@ -1608,7 +1608,8 @@ CONFIG_FB_S3C_LCD_INIT=y
 CONFIG_FB_S3C_DEFAULT_WINDOW=2
 CONFIG_FB_S3C_NR_BUFFERS=4
 # CONFIG_FB_S3C_VIRTUAL is not set
-CONFIG_FB_S3C_LTE480WV=y
+CONFIG_FB_S3C_FLOCS600=y
+# CONFIG_FB_S3C_LTE480WV is not set
 # CONFIG_FB_S3C_HT101HD1 is not set
 # CONFIG_FB_S3C_TL2796 is not set
 # CONFIG_FB_S3C_LVDS is not set
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c b/arch/arm/mach-s5pv210/mach-smdkc110.c
index deb377a..40273c9 100644
--- a/arch/arm/mach-s5pv210/mach-smdkc110.c
+++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
@@ -164,7 +164,9 @@ static struct s3c2410_uartcfg smdkc110_uartcfgs[] __initdata = {
 };
 
 #define S5PV210_LCD_WIDTH 800
-#define S5PV210_LCD_HEIGHT 480
+//#define S5PV210_LCD_HEIGHT 480
+/* Change For Citizen SVGA-Flocs FL0904 By: Bian Jiang 2012.3.12 */
+#define S5PV210_LCD_HEIGHT 600
 
 //#define  S5PV210_VIDEO_SAMSUNG_MEMSIZE_FIMC0 (6144 * SZ_1K)
 #define  S5PV210_VIDEO_SAMSUNG_MEMSIZE_FIMC0 (24576 * SZ_1K)
@@ -837,6 +839,147 @@ static struct s3c_platform_fb lte480wv_fb_data __initdata = {
 };
 #endif
 
+#ifdef CONFIG_FB_S3C_FLOCS600
+/* Citizen FL0904 0.46" flocs600 Add By: Bian Jiang 2012.3.12 */
+static struct s3cfb_lcd flocs600 = {
+	.width = S5PV210_LCD_WIDTH,
+	.height = S5PV210_LCD_HEIGHT,
+	.bpp = 32,
+	.freq = 60,
+
+	.timing = {
+		.h_fp = 8,
+		.h_bp = 13,
+		.h_sw = 3,
+		.v_fp = 5,
+		.v_fpe = 1,
+		.v_bp = 7,
+		.v_bpe = 1,
+		.v_sw = 1,
+	},
+	.polarity = {
+		.rise_vclk = 0,
+		.inv_hsync = 1,
+		.inv_vsync = 1,
+		.inv_vden = 0,
+	},
+};
+
+static void flocs600_cfg_gpio(struct platform_device *pdev)
+{
+	int i;
+
+	for (i = 0; i &lt; 8; i++) {
+		s3c_gpio_cfgpin(S5PV210_GPF0(i), S3C_GPIO_SFN(2));
+		s3c_gpio_setpull(S5PV210_GPF0(i), S3C_GPIO_PULL_NONE);
+	}
+
+	for (i = 0; i &lt; 8; i++) {
+		s3c_gpio_cfgpin(S5PV210_GPF1(i), S3C_GPIO_SFN(2));
+		s3c_gpio_setpull(S5PV210_GPF1(i), S3C_GPIO_PULL_NONE);
+	}
+
+	for (i = 0; i &lt; 8; i++) {
+		s3c_gpio_cfgpin(S5PV210_GPF2(i), S3C_GPIO_SFN(2));
+		s3c_gpio_setpull(S5PV210_GPF2(i), S3C_GPIO_PULL_NONE);
+	}
+
+	for (i = 0; i &lt; 4; i++) {
+		s3c_gpio_cfgpin(S5PV210_GPF3(i), S3C_GPIO_SFN(2));
+		s3c_gpio_setpull(S5PV210_GPF3(i), S3C_GPIO_PULL_NONE);
+	}
+
+	/* mDNIe SEL: why we shall write 0x2 ? */
+	writel(0x2, S5P_MDNIE_SEL);
+
+	/* drive strength to max */
+	writel(0xffffffff, S5PV210_GPF0_BASE + 0xc);
+	writel(0xffffffff, S5PV210_GPF1_BASE + 0xc);
+	writel(0xffffffff, S5PV210_GPF2_BASE + 0xc);
+	writel(0x000000ff, S5PV210_GPF3_BASE + 0xc);
+}
+
+#define S5PV210_GPD_0_0_TOUT_0  (0x2)
+#define S5PV210_GPD_0_1_TOUT_1  (0x2 &lt;&lt; 4)
+#define S5PV210_GPD_0_2_TOUT_2  (0x2 &lt;&lt; 8)
+#define S5PV210_GPD_0_3_TOUT_3  (0x2 &lt;&lt; 12) +static int flocs600_backlight_on(struct platform_device *pdev) +{ +	int err; + +	err = gpio_request(S5PV210_GPD0(3), "GPD0"); + +	if (err) { +		printk(KERN_ERR "failed to request GPD0 for " +			"lcd backlight control\n"); +		return err; +	} + +	gpio_direction_output(S5PV210_GPD0(3), 1); + +	s3c_gpio_cfgpin(S5PV210_GPD0(3), S5PV210_GPD_0_3_TOUT_3); + +	gpio_free(S5PV210_GPD0(3)); +	return 0; +} + +static int flocs600_backlight_off(struct platform_device *pdev, int onoff) +{ +	int err; + +	err = gpio_request(S5PV210_GPD0(3), "GPD0"); + +	if (err) { +		printk(KERN_ERR "failed to request GPD0 for " +				"lcd backlight control\n"); +		return err; +	} + +	gpio_direction_output(S5PV210_GPD0(3), 0); +	gpio_free(S5PV210_GPD0(3)); +	return 0; +} + +static int flocs600_reset_lcd(struct platform_device *pdev) +{ +	int err; + +	err = gpio_request(S5PV210_GPH0(6), "GPH0"); +	if (err) { +		printk(KERN_ERR "failed to request GPH0 for " +				"lcd reset control\n"); +		return err; +	} + +	gpio_direction_output(S5PV210_GPH0(6), 1); +	mdelay(100); + +	gpio_set_value(S5PV210_GPH0(6), 0); +	mdelay(10); + +	gpio_set_value(S5PV210_GPH0(6), 1); +	mdelay(10); + +	gpio_free(S5PV210_GPH0(6)); + +	return 0; +} + +static struct s3c_platform_fb flocs600_fb_data __initdata = { +	.hw_ver	= 0x62, +	.nr_wins = 5, +	.default_win = CONFIG_FB_S3C_DEFAULT_WINDOW, +	.swap = FB_SWAP_WORD | FB_SWAP_HWORD, + +	.lcd = &amp;flocs600, +	.cfg_gpio	= flocs600_cfg_gpio, +	.backlight_on	= flocs600_backlight_on, +	.backlight_onoff    = flocs600_backlight_off, +	.reset_lcd	= flocs600_reset_lcd, +}; +#endif + +  #ifdef CONFIG_S3C64XX_DEV_SPI    #define SMDK_MMCSPI_CS 0 @@ -1935,6 +2078,11 @@ static void __init smdkc110_machine_init(void)  	s3cfb_set_platdata(&amp;lte480wv_fb_data);  #endif   +/* Citizen Flocs FL0904 0.46" SVGA Add By: Bian Jiang 2012.4.12 */ +#ifdef CONFIG_FB_S3C_FLOCS600 +	s3cfb_set_platdata(&amp;flocs600_fb_data); +#endif +  	/* spi */  //#if 0	  #ifdef CONFIG_S3C64XX_DEV_SPI diff --git a/drivers/video/samsung/Kconfig b/drivers/video/samsung/Kconfig index 7738be14..7da6c62 100644 --- a/drivers/video/samsung/Kconfig +++ b/drivers/video/samsung/Kconfig @@ -71,13 +71,20 @@ config FB_S3C_Y_VRES  choice  depends on FB_S3C  prompt "Select LCD Type" -default FB_S3C_LTE480WV +default FB_S3C_FLOCS600 +config FB_S3C_FLOCS600 +	bool "FLOCS600" +	depends on (MACH_SMDKV210 || MACH_SMDKC110) +	---help--- +	  This enables support for Citizen FL0904 FLOCS600 0.46" SVGA LCD panel +  config FB_S3C_LTE480WV  	bool "LTE480WV"  	depends on (MACH_SMDKV210 || MACH_SMDKC110)  	---help---  	  This enables support for Samsung LTE480WV 4.8\" WVGA LCD panel   +  config FB_S3C_HT101HD1  	bool "HT101HD1"  	depends on MACH_SMDKV210 diff --git a/drivers/video/samsung/Makefile b/drivers/video/samsung/Makefile index e317c86..79390c8 100644 --- a/drivers/video/samsung/Makefile +++ b/drivers/video/samsung/Makefile @@ -7,6 +7,7 @@ obj-y				+= s3cfb.o  obj-$(CONFIG_ARCH_S5PV210)	+= s3cfb_fimd6x.o    obj-$(CONFIG_FB_S3C_LTE480WV)	+= s3cfb_lte480wv.o +obj-$(CONFIG_FB_S3C_FLOCS600)	+= s3cfb_flocs600.o  obj-$(CONFIG_FB_S3C_LVDS)       += s3cfb_lvds.o  obj-$(CONFIG_FB_S3C_HT101HD1)   += s3cfb_ht101hd1.o  obj-$(CONFIG_FB_S3C_TL2796)     += s3cfb_tl2796.o diff --git a/drivers/video/samsung/s3cfb.c b/drivers/video/samsung/s3cfb.c index a7a71e0..add9a47 100644 --- a/drivers/video/samsung/s3cfb.c +++ b/drivers/video/samsung/s3cfb.c @@ -983,6 +983,16 @@ static int __devinit s3cfb_probe(struct platform_device *pdev)  	}    	s3cfb_set_clock(fbdev); + +#if defined(CONFIG_DE_MOBILE_PHONE_BOARD) || defined(CONFIG_DE_BASE_BOARD) +    /* Add By: Bian Jiang 2012.3.12 +     *  WIN0 在uboot中使用了,但是为了保持uboot的logo显示,所以uboot不关闭win0 +     *  但是 如果不关闭win0,会导致播放视频和camera preview花屏。 +     */ +    s3cfb_set_window(fbdev, 0, 0); +#endif +  	s3cfb_set_window(fbdev, pdata-&gt;default_win, 1);
 
 	s3cfb_display_on(fbdev);
diff --git a/drivers/video/samsung/s3cfb_flocs600.c b/drivers/video/samsung/s3cfb_flocs600.c
new file mode 100644
index 0000000..3469a08
--- /dev/null
+++ b/drivers/video/samsung/s3cfb_flocs600.c
@@ -0,0 +1,46 @@
+/* linux/drivers/video/samsung/s3cfb_flocs600.c
+ *
+ * Citizen Flocs FL0904 0.46" SVGA Display Panel Support
+ *
+ * Jinsung Yang, Copyright (c) 2009 Samsung Electronics
+ * 	http://www.samsungsemi.com/
+ *
+ * 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.
+*/
+
+#include "s3cfb.h"
+
+static struct s3cfb_lcd flocs600 = {
+	.width = 800,
+	.height = 600,
+	.bpp = 32,
+	.freq = 60,
+
+	.timing = {
+		.h_fp = 8,
+		.h_bp = 13,
+		.h_sw = 3,
+		.v_fp = 5,
+		.v_fpe = 1,
+		.v_bp = 7,
+		.v_bpe = 1,
+		.v_sw = 1,
+	},
+
+	.polarity = {
+		.rise_vclk = 0,
+		.inv_hsync = 1,
+		.inv_vsync = 1,
+		.inv_vden = 0,
+	},
+};
+
+/* name should be fixed as 's3cfb_set_lcd_info' */
+void s3cfb_set_lcd_info(struct s3cfb_global *ctrl)
+{
+	flocs600.init_ldi = NULL;
+	ctrl-&gt;lcd = &amp;flocs600;
+}
+
--
1.7.4.1

下载地址:
0001-LCD-Porting-Citizen-FL0904-0.46-SVGA-flocs600

–EOF–

如何用ctags和Cscope来为大型项目建立索引

February 23rd, 2012 No comments

在使用cscope进行比较大的项目管理的时候,经常需要把不必要的文件或目录排除掉,下面我参考”如何用Cscope来为大型项目建立索引“, 写了个生成uboot cscope和ctags的脚本。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
border@b0rder:/mnt/ubuntu32/work/tss/src/uboot-tss$ cat vim.sh
#!/bin/bash
LNX=`pwd`
cd $LNX
find $LNX \
-path "$LNX/lib_*/*" ! -path "$LNX/lib_arm/*" -prune -o \
-path "$LNX/include/asm-*/*" ! -path "$LNX/include/asm-arm/*" -prune -o \
-path "$LNX/include/configs/*" ! -path "$LNX/include/configs/smdkc110_mtd.h" -prune -o \
-path "$LNX/cpu/*" ! -path "$LNX/cpu/s5pc11x*" -prune -o \
-name "*.[chxsS]" -print &gt;$LNX/cscope.files
 
#ctags --exclude=lib_avr32 --exclude=lib_blackfin --exclude=lib_i386 --exclude=lib_m68k --exclude=lib_microblaze --exclude=lib_mips --exclude=lib_nios --exclude=lib_nios2 --exclude=lib_ppc --exclude=lib_sh --exclude=lib_sparc -R
ctags -L cscope.files
cscope -Rkbq

 

参考:
1. 如何用Cscope来为大型项目建立索引
http://wisdombase.net/wiki/index.php/%E5%A6%82%E4%BD%95%E7%94%A8_Cscope_%E6%9D%A5%E4%B8%BA%E5%A4%A7%E5%9E%8B%E9%A1%B9%E7%9B%AE%E5%BB%BA%E7%AB%8B%E7%B4%A2%E5%BC%95

–EOF–

Categories: Kernel, Tech.Notes Tags: , , , , ,

buildroot编译出错信息

December 20th, 2011 3 comments

1. PATH环境变量有当前目录
错误信息:

border@b0rder:/work/tss/src/lichee/buildroot$ ./build.sh -p sun4i -m buildroot

You seem to have the current working directory in your PATH environment variable. This doesn’t work.

make: *** [dependencies] 错误 1

解决方法,

border@b0rder:/work/tss/src/lichee/buildroot$ echo $PATH .:/home/border/bin/jdk1.6.0_26/bin:.:.:/home/border/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/arm-2010.09/bin:/home/border/go/bin://home/border/bin:/usr/local/arm/arm-2009q3/bin:/home/border/bin:/work/vc1000/src/android-vc1000/out/host/linux-x86/bin:/home/border/bin:/home/border/work/depot_tools:/home/border/work/app/google_appengine:/work/vc1000/src/android-vc1000/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:/home/border/work/android/eclipse-x64:/home/border/work/ai/python/:/home/border/work/ai/python/tools

上面的.表示当前目录信息, 去掉. 后才能正常编译。

border@b0rder:/work/tss/src/lichee/buildroot$ export PATH=/home/border/bin/jdk1.6.0_26/bin:/home/border/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/arm-2010.09/bin:/home/border/go/bin://home/border/bin:/usr/local/arm/arm-2009q3/bin:/home/border/bin:/work/vc1000/src/android-vc1000/out/host/linux-x86/bin:/home/border/bin:/home/border/work/depot_tools:/home/border/work/app/google_appengine:/work/vc1000/src/android-vc1000/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:/home/border/work/android/eclipse-x64:/home/border/work/ai/python/:/home/border/work/ai/python/tools border@b0rder:/work/tss/src/lichee/buildroot$ echo $PATH /home/border/bin/jdk1.6.0_26/bin:/home/border/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/arm-2010.09/bin:/home/border/go/bin://home/border/bin:/usr/local/arm/arm-2009q3/bin:/home/border/bin:/work/vc1000/src/android-vc1000/out/host/linux-x86/bin:/home/border/bin:/home/border/work/depot_tools:/home/border/work/app/google_appengine:/work/vc1000/src/android-vc1000/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:/home/border/work/android/eclipse-x64:/home/border/work/ai/python/:/home/border/work/ai/python/tools

2. makeinfo
错误信息:

border@b0rder:/mnt/ubuntu32/work/tss/src/lichee$ ./build.sh -p sun4i -m buildroot

You must install ‘makeinfo’ on your build machine makeinfo is usually part of the texinfo package in your distribution

make: *** [dependencies] 错误 1

解决方法:

sudo apt-get install texinfo

–EOF–

Kernel debug with kgtp on android

November 1st, 2011 No comments

KGTP is a realtime and lightweight Linux Kernel GDB debugger and tracer. It makes Linux Kernel supply a GDB remote debug interface. Then GDB in current machine or remote machine can debug and trace Linux through GDB tracepoint without stopping the Linux Kernel. And even if the board doesn’t have GDB on it and doesn’t have interface for remote debug. It can debug the Linux Kernel using offline debug. Now, it supports X86-32, X86-64, MIPS and ARM.

This article describes how to use kgtp debug linux kernel on android.

Kernel Building

 General setup  --->
     [ * ] Prompt for development and/or incomplete code/drivers
     [ * ] Kprobe
Kernel hacking  --->
     [ * ] Compile the kernel with debug info
     [ * ] Compile the kernel with frame pointers

Building KGTP

Config KGTP Makefile

KERNELDIR := /work/vc1000/src/kernel-vc1000-2.3
ARCH=arm
CROSS_COMPILE=/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-

error: ‘GTP_VAR_RDTSC_ID’ undeclared(latest version fixed By: teawater )

  CC [M]  /home/border/work/kernel/kgtp/trunk/gtp.o
/home/border/work/kernel/kgtp/trunk/gtp.c: In function 'gtp_gdbrsp_qtv':
/home/border/work/kernel/kgtp/trunk/gtp.c:6318: error: 'GTP_VAR_RDTSC_ID' undeclared (first use in this function)
/home/border/work/kernel/kgtp/trunk/gtp.c:6318: error: (Each undeclared identifier is reported only once
/home/border/work/kernel/kgtp/trunk/gtp.c:6318: error: for each function it appears in.)
/home/border/work/kernel/kgtp/trunk/gtp.c:6320: error: implicit declaration of function 'rdtscll'

* solution:

diff --git a/trunk/gtp.c b/trunk/gtp.c
index 4d0c9a2..75c145e 100644
--- a/trunk/gtp.c
+++ b/trunk/gtp.c
@@ -6315,11 +6315,13 @@ gtp_gdbrsp_qtv(char *pkg)
                if (num == GTP_VAR_CLOCK_ID) {
                        val = (uint64_t)GTP_LOCAL_CLOCK;
                        goto output_value;
+#ifdef CONFIG_X86
                } else if (num == GTP_VAR_RDTSC_ID) {
                        unsigned long long a;
                        rdtscll(a);
                        val = (uint64_t)a;
                        goto output_value;
+#endif
                } else if (num == GTP_VAR_XTIME_SEC_ID
                           || num == GTP_VAR_XTIME_NSEC_ID) {
                        struct timespec time

Complie and Install KGTP

make
sudo su
adb push gtp.ko /system/vendor/lib
exit

KGTP Running On Android

#Open the KGTP interface in current machine.
su
cd /system/vendor/lib
insmod gtp.ko
lsmod
nc -l -p 1234 < /sys/kernel/debug/gtp > /sys/kernel/debug/gtp

Host PC

cd /work/vc1000/src/kernel-vc1000-2.3
make -j8

Network connect to gtp

# symbian use "set gnutarget elf32-littlearm-symbian"
# vxworks use "set gnutarget elf32-littlearm-vxworks"
gdb-release -ex "set gnutarget elf32-littlearm" -ex "file ./vmlinux"

# if you want see the debug info
(gdb) set debug remote 1

# connection your remote device
(gdb) target remote 192.168.2.213:1234

USB connect to gtp

sudo su
# forward socket(adb forward <local> <remote>)
adb forward tcp:1234 tcp:1234
exit
gdb-release -ex "set gnutarget elf32-littlearm" -ex "file ./vmlinux"
# connection your remote device
(gdb) target remote 127.0.0.1:1234

Debugging with gtp

(gdb) trace vfs_readdir
Tracepoint 1 at 0xc02289f0: file /build/buildd/linux-2.6.35/fs/readdir.c, line 23.
(gdb) actions
Enter actions for tracepoint 1, one per line.
End with a line saying just "end".
>collect $reg
>end
(gdb) tstart

Change To Android Device Shell And Run ls Command * Android Device

$ ls

Back To Host PC GDB Shell * Host PC

(gdb) shell ls
vmlinux-2.6.35-30-generic
(gdb) tstop
(gdb) tfind
Found trace frame 0, tracepoint 1
#0  vfs_readdir (file=0x0, filler=0x163d8ae3, buf=0x18c0) at /build/buildd/linux-2.6.35/fs/readdir.c:23
23      {

Good luck, Happy Hacking…

 

Very grateful for teawater

References

kgtp Linux Kernel GDB Tracepoint module

kgtp Quick start

kgtp How to

How To Use KGTP In Android

GDB Tracepoints