Compile the android Linux Kernel

Source: Internet
Author: User

Reference: http://linux.chinaunix.net/techdoc/beginner/2009/02/06/1060906.shtml

Running Environment: ubuntu8.10

1. Build a cross-compilation environment
Android's default hardware processor is arm, so we need to build a cross-compilation environment on our host machine. Come to codesourcery (http://www.codesourcery.com/gnu_toolchains/arm/download.html), click the link corresponding to GNU/Linux, and then click the ia32 GNU/Linux installer link to download directly.
Extract arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 to a directory, as shown in ~ /Programes /. Add the PATH environment variable:
Vim ~ /. Bashrc
Add:
Arm_toolchian = ~ /Programes/arm-2008q3/bin/
Export path =$ {path }:$ {arm_toolchian };
Save and source ~ /. Bashrc

2. Obtain the kernel source code
Http://code.google.com/p/android/downloads/list
Note that the kernel version should be the same as the Simulator version you selected.
After downloading the file, decompress the package and obtain the kernel. Git Folder:
Tar-xvf ~ /Download/linux-2.6.25-android-1.0_r1.tar.gz

3. Obtain the kernel compilation configuration file
Configure is required to compile the kernel. In general, there are many configure options, which we usually do not know. When the android simulator is running, there is a file/proc/config.gz, and config.gzis the configuration information file of the current kernel. We can obtain config.gz and decompress it under kernel. Git/(renamed as. config ):
CD kernel. Git/
Emulator &

ADB pull/proc/config.gz

Gunzip config.gz

MV config. config

4. Modify makefile
Modify row 195:
Cross_compile = arm-None-Linux-gnueabi-
Change the cross_compile value to arm-None-Linux-gnueabi-. This is the prefix of the Cross-compilation toolchain we have installed. Here, we will tell make to use this toolchain during compilation.
Comment out row 3:
# Ldflags_build_id = $ (patsubst-wl $ (comma) %, % ,/
# $ (Call LD-option,-wl $ (comma) -- Build-ID ,))
Comment out the build id value because the current Android kernel does not support this option.

5. Compile
Make
Compile it quickly and generate zimage:
Ld arch/ARM/boot/compressed/vmlinux

Objcopy ARCH/ARM/boot/zimage

Kernel: ARCH/ARM/boot/zimage is ready
The zimage size is 1.23 m, and the android-sdk-linux_x86-1.0_r2/tools/lib/images/kernel-qemu is 1.24 m.

6. Use a simulator to load the kernel for testing.
CD Android/out/cupcake/out/target/product/generic
Emulator-image system. IMG-data userdata. IMG-ramdisk. IMG-kernel ~ /Project/Android/kernel. Git/ARCH/ARM/boot/zimage &
The simulator is loaded successfully.

Related Article

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.