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

Source: Internet
Author: User

As mentioned in the previous article, the latest Android source code downloaded from the source code tree does not contain kernel code, that is, the android source code project does not contain Linux kernel code by default, instead, use the pre-compiled kernel, that is, the prebuilt/Android-arm/kernel-qemu file. So how can we DIY our own kernel? This article is one by one.

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

2. Download the Linux kernel for Android source code.

1. Use the GIT tool to download and execute the following command:

User-name @ machine-Name :~ /Android $ mkdir Kernel

User-name @ machine-Name :~ /Android $ CD Kernel
User-name @ machine-Name :~ /Android/kernel $ git clone git: // android.git.kernel.org/kernel/common.git
After a long wait, there is a common directory under the kernel directory, and the Linux kernel code is here.
2. After the download is complete, you can view the downloaded kernel code version:
User-name @ machine-Name :~ /Android/kernel $ CD common
User-name @ machine-Name :~ /Android/kernel/common $ git Branch
Android 2.6.36
3. After downloading the android Linux kernel code, you will find that there is no hardware configuration file to be used by the simulator in arch/ARM/configs.
Goldfish_defconfig, which is used to compile the kernel code. Therefore, checkout goldfish version is required:
User-name @ machine-Name :~ /Android/kernel/common $ git branch-
* 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-goldfsh-2.6.27
Select android-gldfish-2.6.29:
User-name @ machine-Name :~ /Android/kernel/common $ git checkout remotes/ORIGIN/archive/android-gldfish-2.6.29
After downloading, you can see the file goldfish_defconfig under ARCH/ARM/configs.
3. Compile the kernel code.
1. Export the cross-compilation tool directory to the $ PATH environment variable:
User-name @ machine-Name :~ /Android/kernel/common $ export Path = $ path :~ /Android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
2. Modify the MAKEFILE file in the common directory in the following two actions:
# Arch? = (Subarch)
# Cross_compile? =
Arch? = Arm # The architecture is arm
Cross_compile? = Arm-Eabi-# prefix of the Cross-compiled toolchain. For details, refer ~ /Android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin directory
3. Start Compilation:
User-name @ machine-Name :~ /Android/kernel/common $ make goldfish_defconfig
User-name @ machine-Name :~ /Android/kernel/common $ make
After the compilation is successful, you can see the following two lines:
Objcopy ARCH/ARM/boot/zimage
Kernel: ARCH/ARM/boot/zimage is ready
Before executing the make command, you can also execute make menuconfig to configure the compilation options first.
4. Run the compiled kernel in the simulator.
1. Before starting the simulator, set the simulator directory to the environment variable $ path:
User-name @ machine-Name :~ /Android $ export Path = $ path :~ /Android/out/host/linux-x86/bin
2. Set the android_product_out environment variable:
User-name @ machine-Name :~ /Android $ export android_product_out = ~ /Android/out/target/product/generic
3. Specify the Kernel File to start the simulator in the background:
User-name @ machine-Name :~ /Android $ emulator-kernel./kernel/common/ARCH/ARM/boot/zimage &
4. Use the ADB tool to connect to the simulator, view the kernel version information, and see if the kernel running on the simulator is the kernel we just compiled:
User-name @ machine-Name :~ /Android $ ADB Shell
If this is the first time you run the ADB shell command, you will see the following output. You can 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 the proc directory:
Root @ Android:/# cd proc
Root @ Android:/proc # Cat version
Linux version 2.6.29-gb0d93fb-dirty (Luo @ ubuntu-11-04) (GCC version 4.4.3 (GCC) #1 Fri Jun 3 23:17:24 HKT 2011
From the machine name Luo @ ubuntu-11-04 and date 1 Fri Jun 3 23:17:24 HKT 2011 we can see that the simulator uses the kernel just compiled.

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.