如果你只對內(nèi)核感興趣,你可以利用這篇文章來幫助你下載并且構(gòu)建出合適的內(nèi)核。
下面的信息我們假定你還沒有下載所有的 AOSP。如果你已經(jīng)下載了所有的 AOSP,你可以跳過 git clone 的部分到下載實際的內(nèi)核源碼。
在下面的例子中,我們將使用 Pandaboard 內(nèi)核。
這張表列出了內(nèi)核源碼的名字,位置以及二進制數(shù)據(jù):
| Devices | Binary location | Source location | Build configuration |
|---|---|---|---|
| shamu | device/moto/shamu-kernel | kernel/msm | shamu_defconfig |
| fugu | device/asus/fugu-kernel | kernel/x86_64 | fugu_defconfig |
| volantis | device/htc/flounder-kernel | kernel/tegra | flounder_defconfig |
| hammerhead | device/lge/hammerhead-kernel | kernel/msm | hammerhead_defconfig |
| flo | device/asus/flo-kernel/kernel | kernel/msm | flo_defconfig |
| deb | device/asus/flo-kernel/kernel | kernel/msm | flo_defconfig |
| manta | device/samsung/manta/kernel | kernel/exynos | manta_defconfig |
| mako | device/lge/mako-kernel/kernel | kernel/msm | mako_defconfig |
| grouper | device/asus/grouper/kernel | kernel/tegra | tegra3_android_defconfig |
| tilapia | device/asus/grouper/kernel | kernel/tegra | tegra3_android_defconfig |
| maguro | device/samsung/tuna/kernel | kernel/omap | tuna_defconfig |
| toro | device/samsung/tuna/kernel | kernel/omap | tuna_defconfig |
| panda | device/ti/panda/kernel | kernel/omap | panda_defconfig |
| stingray | device/moto/wingray/kernel | kernel/tegra | stingray_defconfig |
| wingray | device/moto/wingray/kernel | kernel/tegra | stingray_defconfig |
| crespo | device/samsung/crespo/kernel | kernel/samsung | herring_defconfig |
| crespo4g | device/samsung/crespo/kernel | kernel/samsung | herring_defconfig |
你可能會想查看設(shè)備工程中核心組件里面你所感興趣的 git 日志。
設(shè)備工程在當前格式的設(shè)備 /<vendor>/<name> 目錄下。
$ git clone https://android.googlesource.com/device/ti/panda
$ cd panda
$ git log --max-count=1 kernel
這里的內(nèi)核組件提交信息中包含了一部分有問題的內(nèi)核源碼的 git log 信息。第一進入的是最近一次的,也就是用于構(gòu)建內(nèi)核的信息。你在下面的步驟中會需要用到它。
為了查明在實際的系統(tǒng)映像中所使用的內(nèi)核版本,在內(nèi)核文件中執(zhí)行下面的代碼:
$ dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'
在 Nexus 5 (hammerhead),你可以用這個命令:
$ dd if=zImage-dtb bs=1 skip=$(LC_ALL=C od -Ad -x -w2 zImage-dtb | grep 8b1f | cut -d ' ' -f1 | head -1) | zgrep -a 'Linux version'
下載哪一個取決于你所想要的:
$ git clone https://android.googlesource.com/kernel/common.git
$ git clone https://android.googlesource.com/kernel/x86_64.git
$ git clone https://android.googlesource.com/kernel/exynos.git
$ git clone https://android.googlesource.com/kernel/goldfish.git
$ git clone https://android.googlesource.com/kernel/msm.git
$ git clone https://android.googlesource.com/kernel/omap.git
$ git clone https://android.googlesource.com/kernel/samsung.git
$ git clone https://android.googlesource.com/kernel/tegra.git
goldfish 工程中包含為模擬器平臺使用的內(nèi)核源碼。
msm 工程有可供 ADP1,ADP2,Nexus One,Nexus 4,Nexus 5,Nexus 6,也可以被當做一個起始點給 Qualcomm MSM 芯片組使用。
omap 工程被用于 PandaBoard 和 Galaxy Nexus,也可以被當做一個起始點給 TIOMAP 芯片組使用。
samsung 工程是為了 Xoom,Nexus 7,Nexus 9,也可以被當做一個起始點給 Samsung Hummingbird 芯片組使用。
tegra 工程是給 Xoom,Nexus 7,Nexus 9,也可以被當做一個起始點給 NVIDIA Tegra 芯片組使用。
exynos 工程包含供 Nexus 10 的核心源碼,也可以被當做一個起始點給 Samsung Exynos 芯片組使用。
確保預生成的工具鏈在你的環(huán)境變量中
$ export PATH=$(pwd)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH
或者
$ export PATH=$(pwd)/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin:$PATH
在一個 Linux host 中,如果你沒有 Android 源碼樹,你可以從下面的地址中下載預編譯工具鏈:
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6
作為一個例子,我們將會使用下面的命令來構(gòu)建 panda 內(nèi)核:
$ export ARCH=arm
$ export SUBARCH=arm
$ export CROSS_COMPILE=arm-eabi-
$ cd omap
$ git checkout <commit_from_first_step>
$ make panda_defconfig
$ make
構(gòu)建 tuan 內(nèi)核,你需要將之前的命令中所有 'panda' 改為 'tuna'。
核心組件將會輸出:arch/arm/boot/zlmage。它可以被拷貝進入 Android 源碼樹中,以便于構(gòu)建適合的 boot 鏡像。
或者你可以使用 make bootimage 命令,包含 TARGET_PREBUILD_KERNEL 變量,或者其他任何 make 命令行用來構(gòu)建 boot 鏡像。
$ export TARGET_PREBUILT_KERNEL=$your_kernel_path/arch/arm/boot/zImage
那個變量支持所有用過 device/common/populare-new-device.sh 命令啟動的設(shè)備。