Android Kernel source Downloads, compiles, installs _android in Ubuntu

Source: Internet
Author: User

The latest Android source code downloaded from the source tree does not include kernel code, which means that the Android source project does not include Linux kernel code by default, but uses a precompiled kernel, which is Prebuilt/android-arm/kernel /kernel-qemu files. So, how can diy own core? This article comes in one by one ways.

First of all, refer to the previous article in the Android source in Ubuntu download, compile and install the Android source code directory ready.

Two. Download 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 http://android.googlesource.com/kernel/goldfish.git

Also after a long wait, in the kernel directory has a common directory, 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. The above is the main line of the kernel source code, now we need to apply to the simulator for the kernel, so we need to checkout goldfish version:

 user-name@machine-name:~/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:

User-name@machine-name: ~/android/kernel/common$ git checkout remotes/origin/archive/ android-gldfish-2.6.29

Three. Compile 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 following two behaviors of the makefile file under the common directory:

# ARCH? = (Subarch)
# cross_compile?=
ARCH? = Arm #体系结构为arm
Cross_compile = arm-eabi-#交叉编译工具链前缀, reference ~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin directory

3. Start compiling:

user-name@machine-name:~/android/kernel/common$ make Goldfish_defconfig
user-name@machine-name:~/android/kernel/common$ make

After the compilation succeeds, 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 executing the makes command.

four. Run the compiled kernel in the emulator.

1. Before starting the simulator, set the emulator 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 kernel file launch simulator in the background:

user-name@machine-name:~/android$ emulator-kernel./kernel/common/arch/arm/boot/zimage &

4. Connect the simulator with the ADB tool and view the kernel version information to see if the kernel running on the emulator is the kernel we just compiled:

user-name@machine-name:~/android$ adb Shell

If this is the first time the ADB shell command is run, you will see the following output, regardless of it, and then run the ADB shell command once more.

* Daemon not running. Start it now on Port 5037 *
* Daemon started successfully *
Error:device offline

Switch to 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 June 3 23:17:24 HKT 201 1

From the machine name luo@ubuntu-11-04 and date 1 Fri June 3 23:17:24 HKT 2011 You can see that the emulator uses a kernel that is 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 source code compilation methods, please refer to the official website: http://source.android.com/source/building-kernels.html

The above is the installation of the Ubuntu Android source kernel, in the process of compiling to be able to meet the above problems, follow up, and hope to help study the Android kernel friends.

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.