如何編譯 A688 手機的 Kernel

以下編譯環境為 Ubuntu 10.10 X64

1. 先安裝必要套件

$ sudo apt-get install git-core gnupg
 sun-java5-jdk flex bison gperf libsdl-dev
 libesd0-dev libwxgtk2.6-dev build-essential
 zip curl libncurses5-dev zlib1g-dev
2. 建立資料夾並下載相關 source code 及編譯工具

$ mkdir ~/A688

$ cd A688

$ git clone git://android.git.kernel.org/platform/frameworks/base.git<br>$ git clone git://android.git.kernel.org/platform/hardware/libhardware.git<br>$ git clone git://android.git.kernel.org/platform/hardware/libhardware_legacy.git<br>$ git clone git://android.git.kernel.org/platform/hardware/msm7k.git<br>$ git clone git://android.git.kernel.org/platform/prebuilt.git
3. 下載 Motorola Xt5 source code 並放到 ~/A688
<a title="https://opensource.motorola.com/sf/frs/do/viewRelease/projects.quenchxt/frs.xt5.xt502" href="https://opensource.motorola.com/sf/frs/do/viewRelease/projects.quenchxt/frs.xt5.xt502">https://opensource.motorola.com/sf/frs/do/viewRelease/projects.quenchxt/frs.xt5.xt502</a>
4. 解開 source code
$ cd A688
$ tar –zxvf bionic.tar.gz
$ tar –zxvf dalvik.tar.gz
$ tar –zxvf external.tar.gz
$ tar –zxvf kernel.tar.gz
5. 從手機取出目前 kernel.gz 的 config 並放到 ~/A688/Kernel/
(1) 將手機連到電腦
(2) cd ~/A688/Kernel/
(3) adb pull /proc/config.gz config.gz
(4) gunzip config.gz 
(5) mv config .config
6. 設定環境變數
$ export PLATFORM_DIR=~/A688<br>$ export ARCH=arm<br>$ export CROSS_COMPILE=arm-eabi-<br>$ export PATH=~/A688/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:$PATH
7. 修改 Makefile

找到

KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \

                     -fno-strict-aliasing -fno-common \

                     -Werror \

                     -Werror-implicit-function-declaration

修改成

KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \

                     -fno-strict-aliasing -fno-common

  #                  -Werror \

  #                  -Werror-implicit-function-declaration

8. 開始編譯
$ make ANDROID_BUILD_TOP=<br>編好的 kernel 會在
 ~/A688/kernel/arch/arm/boot/zImage
9. 解開 boot.img 換成新的 kernel
$ cd ~/RomRepackTools_Linux
$ cp ~/A688/kernel/arch/arm/boot/zImage .
$ ./unpack-bootimg.pl boot.img
$ ./repack-bootimg.pl zImage boot.img-ramdisk boot_newkernel.img
10. 更新手機的 kernel
$ fastboot flash boot boot_newkernel.img
  • Anonymous

    how about the wifi driver? i can’t use my wifi because the wifi kernel module (ar6000.ko) must be recompiled based on modified kernel.
    i can’t find the source code of ar6k on the kernel source code of xt5.
    are you have any sugestion?

    thank you..