编译android源码官方教程(6)编译内核
Building Kernels
This page details how to build only the kernel. The following instructions assume you have not downloaded all of AOSP; if you have already done so, you can skip the git clone steps except the step that downloads the kernel sources.
All examples in this section use the hikey kernel.
Selecting a kernel
This table lists the name and locations of the kernel sources and binaries:
| Device | Binary location | Source location | Build configuration |
|---|---|---|---|
| hikey | device/linaro/hikey-kernel | kernel/hikey-linaro | hikey_defconfig |
| angler | device/huawei/angler-kernel | kernel/msm | angler_defconfig |
| bullhead | device/lge/bullhead-kernel | kernel/msm | bullhead_defconfig |
| 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 |
After determining the device project you want to work with, view the git log for the kernel binary. Device projects use the form device/<vendor>/<name>.
$ git clone https://android.googlesource.com/kernel/hikey-linaro
$ cd hikey-linaro
$ git log --max-count=1 kernel
The commit message for the kernel binary contains a partial git log of the kernel sources used to build the binary. The first entry in the log is the most recent (the one used to build the kernel). Make a note of the commit message as you will need it in a later step.
Identifying kernel version
To determine the kernel version used in a system image, run the following command against the kernel file:
$ 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'
For Nexus 5 (hammerhead), the command is:
$ 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'
Downloading sources
Download the source for the kernel you want to build using the appropriate git clone command:
$ git clone https://android.googlesource.com/kernel/common.git
$ git clone https://android.googlesource.com/kernel/hikey-linaro
$ 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
- The
goldfishproject contains the kernel sources for the emulated platforms. - The
msmproject has the sources for ADP1, ADP2, Nexus One, Nexus 4, Nexus 5, Nexus 6, Nexus 5X, Nexus 6P, Nexus 7 (2013), and can be used as a starting point for work on Qualcomm MSM chipsets. - The
omapproject is used for PandaBoard and Galaxy Nexus, and can be used as a starting point for work on TI OMAP chipsets. - The
samsungproject is used for Nexus S, and can be used as a starting point for work on Samsung Hummingbird chipsets. - The
tegraproject is for Xoom, Nexus 7 (2012), Nexus 9, and can be used as a starting point for work on NVIDIA Tegra chipsets. - The
exynosproject has the kernel sources for Nexus 10, and can be used as a starting point for work on Samsung Exynos chipsets. - The
x86_64project has the kernel sources for Nexus Player, and can be used as a starting point for work on Intel x86_64 chipsets. - The
hikey-linaroproject is used for HiKey reference boards, and can be used as a starting point for work on HiSilicon 620 chipsets.
Downloading a prebuilt gcc
Ensure the prebuilt toolchain is in your path:
$ export PATH=$(pwd)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH
or
$ export PATH=$(pwd)/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin:$PATH
On a Linux host, if you don't have an Android source tree, you can download the prebuilt toolchain from:
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6
Building the kernel
When you know the last commit message for a kernel and have successfully downloaded the kernel source and prebuilt gcc, you are ready to build the kernel. The following build commands use the hikey kernel:
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-android-
$ cd hikey-linaro
$ git checkout -b android-hikey-linaro-4.1 origin/android-hikey-linaro-4.1
$ make hikey_defconfig
$ make
To build a different kernel, simply replace hikey-linaro with the name of the kernel you want to build.
The image outputs to the arch/arm64/boot/Image directory; the kernel binary outputs to thearch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb fle. Copy the Image directory and the hi6220-hikey.dtb file to thehikey-kernel directory.
Alternatively, you can include the TARGET_PREBUILT_KERNEL variable while using make bootimage (or any other make command line that builds a boot image). This variable is supported by all devices as it is set up via device/common/populate-new-device.sh. For example:
$ export TARGET_PREBUILT_KERNEL=$your_kernel_path/arch/arm/boot/zImage-dtb
Note: Kernel names differ by device. To locate the correct filename for your kernel, refer todevice/<vendor>/<name> in the kernel source.
编译android源码官方教程(6)编译内核的更多相关文章
- 编译android源码官方教程(5)编译完之后刷机、编译fastboot
Running Builds IN THIS DOCUMENT Building fastboot and adb Booting into fastboot mode Unlocking the b ...
- 编译android源码官方教程(2)建立编译环境「linux & mac osx」
https://source.android.com/source/initializing.html Establishing a Build Environment IN THIS DOCUMEN ...
- 编译android源码官方教程(4)开始编译
Preparing to Build IN THIS DOCUMENT Obtain proprietary binaries Download proprietary binaries Extrac ...
- 编译android源码官方教程(3)下载代码
https://source.android.com/source/downloading.html Downloading the Source IN THIS DOCUMENT Installin ...
- 编译android源码官方教程(1)硬件、系统要求
https://source.android.com/source/requirements.html Requirements IN THIS DOCUMENT Hardware requireme ...
- 在ubuntu16.04上编译android源码【转】
本文转载自:http://blog.csdn.net/fuchaosz/article/details/51487585 1 前言 经过3天奋战,终于在Ubuntu 16.04上把Android 6. ...
- 深入浅出 - Android系统移植与平台开发(五)- 编译Android源码(转)
2.3编译Android源码 Android源码体积非常庞大,由Dalvik虚拟机.Linux内核.编译系统.框架代码.Android定制C库.测试套件.系统应用程序等部分组成,在编译Android源 ...
- 【转】在Ubuntu下编译Android源码并运行Emulator
原文网址:http://www.mcuos.com/thread-4553-1-1.html 建立编译环境 1.在VirtualBox上安装Ubuntu 2.安装JDK $ sudo apt-ge ...
- Ubuntu12.04编译Android4.0.1源码全过程-----附wubi安装ubuntu编译android源码硬盘空间不够的问题解决
昨晚在编译源码,make一段时间之后报错如下: # A fatal error has been detected by the Java Runtime Environment: # # SIGSE ...
随机推荐
- 在OSX下卸载Xamarin
To uninstall Xamarin Studio, you'll want to run the following commands from a Terminal: sudo rm -rf ...
- JavaScript入门篇 编程练习
编程挑战 一.定义"改变颜色"的函数 提示: obj.style.color obj.style.backgroundColor 二.定义"改变宽高"的函数 提 ...
- bootstrap全局CSS样式学习
参考http://v3.bootcss.com/css/,根据自己的记忆进行的复述,加深记忆. 首先介绍bootstrap全局CSS样式 只通过使用bootstrap.css,即可获得统一的样式设置. ...
- linq查询结果转换为指定字段类型的list集合
转换查询结果为ProductId字段的类型的list集合 (from s in _db.Mobile_TeamAction || s.ActionStatus == select new { s.Pr ...
- JMeter学习-004-WEB脚本入门实战
此文为 JMeter 入门实战实例.我是 JMeter 初学菜鸟一个,因而此文适合 JMeter 初学者参阅.同时,因本人知识有限,若文中存在不足的地方,敬请大神不吝指正,非常感谢! 闲话少述,话归正 ...
- 关于 Android 5.0 原生系统网络图标上的感叹号问题解决方法
解决方案 adb shell settings put global captive_portal_server g.cn 参考 关于 android 5.0 网络图标上的感叹号及其解决办法
- Leetcode: Pacific Atlantic Water Flow
Given an m x n matrix of non-negative integers representing the height of each unit cell in a contin ...
- java获取获得Timestamp类型的当前系统时间。以及java.util.date 、java.sql.Date之间的转换
java获取取得Timestamp类型的当前系统时间java获取取得Timestamp类型的当前系统时间 格式:2010-11-04 16:19:42 方法1: Timestamp d = new T ...
- 免费的网络扫描器-Advanced IP Scanner
软件会自动检测电脑所在的网段,自动决定扫描范围.(例如电脑IP是192.168.1.101,扫描范围就是192.168.1.*) 官方网站:http://www.advanced-ip-scanner ...
- 白话LINQ系列1---什么是LINQ?
一.本系列目标 1.理解LINQ: 2.能写得复杂的LINQ语句(比如:动态查询): 3.理解表达式树及相关概念: 4.熟练运用LINQ写出优美的代码(希望一起努力,最终达到): 二.LINQ为何物? ...