Download, compile and install the latest Android kernel source code (Linux Kernel) on Ubuntu

Source: Internet
Author: User

Article reprinted to CSDN community Luo Shenyang's Android tour, original address: http://blog.csdn.net/luoshengyang/article/details/6564592

As mentioned in the previous article, the latest Android source code downloaded from the source tree, is not included in the kernel code, that is, the Android source code project does not contain the Linux kernel code, but the use of pre-compiled kernel, that is prebuilt/ Android-arm/kernel/kernel-qemu file. So, how can you diy your own kernel? This article comes in one by one.

First, refer to the previous article on Ubuntu download, compile and install the latest Android source code to prepare the Android source code directory.

Two. Download the Linux Kernel for Android source code.

1. Using the Git tool to download, execute the following command:

[email protected]:~/android$ mkdir kernel

[email protected]:~/android$ cd kernel [email protected]:~/android/kernel$ git clonehttp://android.googlesource.com/kernel/goldfish.git       Also after a long wait, in the kernel directory there is a common directory, the Linux kernel code is here. 2. After the download is complete, you can view the downloaded kernel code version: [email protected]:~/android/kernel$ cd Common [email protected]:~/android/kernel/common$ git branch android-2.6.36 3. The above is the core source code on the main line, now we need to apply to the simulator's kernel, so we need toTo checkout Goldfish version: [email protected]:~/android/kernel/common$ git branch-a * android-2.6.36 Remotes/origin/head-origin/android-2.6.36
remotes/origin/android-2.6.35
remotes/origin/android-2.6.36
remotes/origin/archive/android-2.6.25
remotes/origin/archive/android-2.6.27
remotes/origin/archive/android-2.6.29
remotes/origin/archive/android-2.6.32
remotes/origin/archive/android-gldfish-2.6.29
remotes/origin/archive/android-goldfish-2.6.27
      Select android-gldfish-2.6.29: [email protected]:~/android/kernel/common$ git checkout remotes/origin/archive/android-gldfish-2.6.29 Three. Compile the kernel code. 1. Export the cross-compilation tool directory to the $PATH environment variable: [email protected]:~/android/kernel/common$ export path= $PATH: ~/android/prebuilt/linux-x86/toolchain/ Arm-eabi-4.4.3/bin2. Modify the following two behaviors of the makefile file under the common directory: # ARCH ? = (Subarch) # Cross_compile ?=  ARCH = Arm #体系结构为arm cross_compile? = arm-eabi-#交叉编译工具链前缀, refer to ~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin catalogue 3. Start compiling: [email protected]:~/android/kernel/common$ make Goldfish_defconfig        [email protected]:~/android/kernel/common$ makeAfter compiling successfully, you can see the following two lines: objcopy Arch/arm/boot/zimage
Kernel:arch/arm/boot/zimage
is ready
      You can also perform make menuconfig to configure the compile options before you execute the makes command.     Four. Run the compiled kernel in the emulator. 1. Before starting the emulator, set the emulator directory to the environment variable $path: [email protected]:~/android$ export path= $PATH: ~/android/out/host/linux-x86/bin 2. Set the ANDROID_PRODUCT_OUT environment variable: [email protected]:~/android$ Export Android_product_out=~/android/out/target/product/generic 3. In the background, specify the kernel file to start the emulator:        [email protected]:~/android$ emulator-kernel./kernel/common/arch/arm/boot/zimage &       4. Connect the emulator with the ADB tool, view the kernel version information, and see if the kernel running on the emulator is the kernel we just compiled: [email protected]:~/android$ adb shell At this point, if the adb shell command is run for the first time, you will see the following output, and then run the ADB shell command again without having to worry about it. * Daemon not running. Start it now on Port 5037 * * Daemon started successfully * error:device Offline       Switch to proc directory: [Email protected]:/# CD proc [email protected]:/proc # cat version Linux version 2.6.29-gb0d93f B-dirty ([email protected]) (GCC version 4.4.3 (gcc)) #1 Fri June 3 23:17:24 HKT 2011 from machine name [email protected] and date 1 Fri June 3 23:17:24 HKT 2011 It can be seen that the kernel used by the simulator is the kernel that was just compiled.   PS: The latest source code on the main line is an unstable version, the use of the process may be problematic more formal method of compiling source code, please refer to the official website: http://source.android.com/source/building-kernels.html Lao Luo's Sina Weibo: Http://weibo.com/shengyangluo, welcome attention!

Download, compile and install the latest Android kernel source code (Linux Kernel) on Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.