Andrew Huang
转载请注明作者及出处
一.准备工作
有一个 可以参考,这是G4的.
内核下载
对于HTC G8可以选择HTC Wildfire – Froyo MR – 2.6.32 kernel source code ,最终下载的文件是
关于编译器,从原理上讲一般的eabi的ARM 编译器应该都可以。我先用我的arm-linux-gcc 4.2.2 先试一下。
解压内核
tar xvf buzz-MR-2.6.32-g8f75634.tar.gz
mv buzz-MR-2.6.32-g8f75634 g8-buzz-2.6.32
取配置文件
这个内核是没有配置好的内核文件备份,因此必须要从一台激活的HTC G8手机取得配置文件。
直接用如下命令
adb pull /proc/config.gz
取得当前内核配置,将其解压
gunzip config.gz
cp config g8-buzz-2.6.32/.config
二.编译内核
修改内核编译器,即内核的Makefile
原来是 CROSS_COMPILE ?= arm-eabi- 将其修改成我当前的编译器
CROSS_COMPILE ?= arm-linux-
make menuconfig 可以查看其CPU的的类型
export LANG=en_US.UTF-8
make
第一次编译报错
- arch/arm/kernel/unwind.c:34:2: error: #warning Your compiler is too buggy; it is known to not compile ARM unwind support.
-
arch/arm/kernel/unwind.c:35:2: error: #warning Change compiler or disable ARM _UNWIND option.
因此准备换一个编译版本较高的编译器,换成4.5.1
有编译错误
- cc1: warnings being treated as errors
-
init/main.c: In function 'do_one_initcall':
-
init/main.c:706:10: error: 'calltime.tv64' may be used uninitialized in this function
这是未初始化三个变量
ktime_t calltime, delta, rettime;
参考这里说明
将代码更新成
- /* ktime_t calltime, delta, rettime;*/
-
707 DEFINE_KTIME(calltime);
-
708 DEFINE_KTIME(delta);
-
709 DEFINE_KTIME(rettime);
修正后又碰如下错误
- arch/arm/mm/alignment.c:716:21: error: 'offset.un' may be used uninitialized in this function
union offset_union offset;
将其修改为
716 union offset_union offset = { .un = 0};
结果又碰到
- kernel/async.c: In function 'async_thread':
-
kernel/async.c:126:10: error: 'calltime.tv64' may be used uninitialized in this function
-
kernel/async.c:126:10: note: 'calltime.tv64' was declared here
-
kernel/async.c: In function 'async_synchronize_cookie_domain':
-
kernel/async.c:282:10: error: 'starttime.tv64' may be used uninitialized in this function
原因同前,一样修改
又碰到leds
- drivers/leds/leds-microp.c: In function 'microp_led_jogball_brightness_set':
-
drivers/leds/leds-microp.c:117:2: error: case value '1' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:121:2: error: case value '3' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:125:2: error: case value '7' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c: In function 'microp_led_wimax_brightness_set':
-
drivers/leds/leds-microp.c:163:2: error: case value '1' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:164:2: error: case value '2' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:165:2: error: case value '3' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:166:2: error: case value '4' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:167:2: error: case value '5' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:168:2: error: case value '129' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:169:2: error: case value '130' not in enumerated type 'enum led_brightness'
-
drivers/leds/leds-microp.c:170:2: error: case value '131' not in enumerated type 'enum led_brightness'
查看include/linux/leds.h 只有如下定义
- enum led_brightness {
-
LED_OFF = 0,
-
LED_HALF = 127,
-
LED_FULL = 255,
-
};
增加定义
又碰到
- cc1: warnings being treated as errors
-
drivers/md/dm.c: In function 'split_bvec':
-
drivers/md/dm.c:1032:3: error: statement with no effect
-
drivers/md/dm.c: In function 'clone_bio':
-
drivers/md/dm.c:1060:3: error: statement with no effect
错误实在太多了,没办法只能将-Werror 选项去掉,
即将.config中的 注释掉
CONFIG_FORCE_WARNING_AS_ERROR=y
- LD vmlinux
-
SYSMAP System.map
-
SYSMAP .tmp_System.map
-
OBJCOPY arch/arm/boot/Image
-
Kernel: arch/arm/boot/Image is ready
-
AS arch/arm/boot/compressed/head.o
-
GZIP arch/arm/boot/compressed/piggy.gz
-
AS arch/arm/boot/compressed/piggy.o
-
CC arch/arm/boot/compressed/misc.o
-
LD arch/arm/boot/compressed/vmlinux
-
OBJCOPY arch/arm/boot/zImage
-
Kernel: arch/arm/boot/zImage is ready
-
Building modules, stage 2.
-
MODPOST 1 modules
-
CC drivers/net/wireless/bcm4329_204/bcm4329.mod.o
-
LD [M] drivers/net/wireless/bcm4329_204/bcm4329.ko
-
[root@gz g8-buzz-2.6.32]# vi .config
-
[root@gz g8-buzz-2.6.32]# vim Makefile
-
[root@gz g8-buzz-2.6.32]# vim .config
-
[root@gz g8-buzz-2.6.32]# vim Makefile
阅读(1921) | 评论(0) | 转发(0) |