Android kernel source code cross-Compilation

Source: Internet
Author: User

1. Use git to download some android kernel source code

First, create a directory to save the android kernel source code.

Mkdir
Android_kernel

Cd
Android_kernel

Android
Kernel website http://android.git.kernel.org/

Git
Clone git: // android.git.kernel.org/kernel/common.git

After downloading the android kernel source code, you will see the common directory. Even if the kernel source code is downloaded

To download a kernel version, run the following commands:

Git
Branch-a // display all branches

Git
Branch-r // display the branch of romote

Git
Checkout // check a branch

Ii. Set the cross-compilation environment

The cross-compilation environment already exists in the android source code. For download of the source code, see download and compile the android source code. In the source directory android_source/prebuilt/linux-x86/toolchain/, You can see multiple cross-compiled tools

Mac @ mac-desktop :~ /Works/android_dev/prebuilt/linux-x86/toolchain $
Ls-all

Total usage 44

Drwxr-xr-x 9 mac MACOs 4096
Arm-eabi-4.2.1

Drwxr-xr-x 9 mac MACOs 4096
Arm-eabi-4.3.1

Drwxr-xr-x 10 mac MACOs 4096
Arm-eabi-4.4.0

Drwxr-xr-x 10 mac MACOs 4096
Arm-eabi-4.4.3

Drwxr-xr-x 10 mac MACOs 4096
Arm-linux-androideabi-4.4.x

Drwxr-xr-x 6 mac MACOs 4096
I686-android-linux-4.4.3

Drwxr-xr-x 8 mac MACOs 4096
I686-linux-glibc2.7-4.4.3

Drwxr-xr-x 10 mac MACOs 4096
I686-unknown-linux-gnu-4.2.1

Drwxr-xr-x 6 mac MACOs 4096
Sh-4.3.3

The latest version is generally used.

3. Configure the config file during compilation

Because the compiled image is to be flushed to run on the simulator, and the processor architecture of the simulator is based on goldfish, You need to download the config file related to goldfish. Download Method:

Mac @ mac-desktop :~ /Works/kernel-2.6.29 $
Git branch-

* (No branch)

Android 2.6.29

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/android-2.6.37

Remotes/origin/android-2.6.38

Remotes/origin/android-2.6.39

Remotes/origin/android-3.0

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

Remotes/origin/linux-bcm43xx-2.6.39

Remotes/origin/linux-wl12xx-2.6.39

Download remotes/origin/archive/android-gldfish-2.6.29
Version:

Git
Checkout origin/archive/android-gldfish-2.6.29

Then you can see the file goldfish_defconfig under arch/arm/configs.

Copy the goldfish_defconfig file to the android_kernel directory and rename it as. config.

Iv. make Compilation

First, set the environment:

Export
PATH = $ PATH :~ /Android_source/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin

Then modify the Makefile:

ARCH =
Arm # The architecture is arm

CROSS_COMPILE
= Arm-eabi-# prefix of the Cross-compiled toolchain, see/toolchain/arm-eabi-4.4.3/bin

Then you can make the compilation. During the compilation process, the "yes/not" prompt will be displayed continuously. If you can understand it, pay more attention to it. If you cannot understand it, press Enter. If the preceding settings are correct, after compilation is complete, the following prompt is displayed:

OBJCOPY
Arch/arm/boot/zImage

Kernel:
Arch/arm/boot/zImage is ready

5. Compile zImage and start the simulator with the new kernel.

./Emulator
-Avd android2.1-kernel ~ // Kernel-2.6.29/arch/arm/boot/zImage

View the system information on the simulator:

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.