星期六, 11月 27, 2010

如何編譯 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
$ git clone git://android.git.kernel.org/platform/hardware/libhardware.git
$ git clone git://android.git.kernel.org/platform/hardware/libhardware_legacy.git
$ git clone git://android.git.kernel.org/platform/hardware/msm7k.git
$ git clone git://android.git.kernel.org/platform/prebuilt.git


3. 下載 Motorola Xt5 source code 並放到 ~/A688


https://opensource.motorola.com/sf/frs/do/viewRelease/projects.quenchxt/frs.xt5.xt502


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
$ export ARCH=arm
$ export CROSS_COMPILE=arm-eabi-
$ 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=
編好的 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

1 則留言:

匿名 提到...

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..