Compile the android kernel source code in Ubuntu11.10

Source: Internet
Author: User

In previous articles, I introduced some problems encountered in the configuration process, including "how to download the android source code for Ubuntu Linux", "how to configure the Eclipse development environment for android under Ubuntu11.10, and Ubuntu11.10 android source code 4.0.3 compilation method. This article continues to introduce how to compile the android kernel in Ubuntu11.10.
 
The android kernel is not automatically compiled when the android source code is compiled. Therefore, you need to manually compile this part of the code. It takes much less time to compile the kernel than to compile the android source code.
 
1. Determine the kernel version
 
Go to the kernel directory where the android kernel source code is stored. I downloaded the common. git and goldfish. git. Take goldfish as an example. Enter the goldfish directory and enter the following command on the command line to display all branches and the current branches:
 
1
$ Git bransh-
The output result is as follows:
 
1
* Master
2
Remotes/origin/HEAD-> origin/master
3
Remotes/origin/android-goldfsh-2.6.29
4
Remotes/origin/master
Run the following command to select the latest version (goldfish is the CPU described by the android simulator ):
 
1
$ Git checkout-B android-goldfish-2.6.29 origin/android-goldfish-2.6.29
Enter the command git branch-a again, and the latest branch is displayed, indicating that the selected branch currently works. The output is as follows:
 
1
* Android-goldfish-2.6.29
2
Master
3
Remotes/origin/HEAD-> origin/master
4
Remotes/origin/android-goldfsh-2.6.29
5
Remotes/origin/master
2. Set Environment Variables
 
When compiling the android kernel, a cross-compiler is required. In the downloaded android source code tree, there is a prebuilt folder that contains the cross-compilation tool required to compile the kernel. Therefore, you need to set it to environment variables for ease of use. Open the. bashrc file in the user directory and add the following code
 
1
Export PATH = $ PATH :~ /Android/source/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin
2
Export ARCH = arm
Save and exit. Run the following command to update the file in the user directory.
 
1
$ Source ~ /. Bashrc
An error may be prompted during compilation because it may not be updated in time after it is added, for example, the Directory of the Cross-compilation tool cannot be found, therefore, update is required here (if the environment variable is added, the system prompts that the cross-compilation tool directory cannot be found during compilation, you can try to update it several times ).
 
3. Set cross-compilation Parameters
 
You also need to set the cross-compilation parameters used during compilation before compilation.
 
First, open the Makefile file in the android/kernel/goldfish/directory, find the CROSS_COMPILE variable, and point it to the arm-eabi compiler in the prebuilt provided by android source code. The Code is as follows:
 
1
CROSS_COMPILE? = Arm-eabi-
Then find the following code:
 
1
LDFLAGS_BUILD_ID = $ (patsubst-Wl $ (comma) %, % ,\
2
$ (Call ld-option,-Wl $ (comma) -- build-id ,))
Delete or comment it out (it is recommended to comment it out for future use), and add an empty LDFLAGS_BUILD_ID definition, as shown below:
 
1
# LDFLAGS_BUILD_ID = $ (patsubst-Wl $ (comma) %, % ,\
2
# $ (Call ld-option,-Wl $ (comma) -- build-id ,))
3
LDFLAGS_BUILD_ID =
4. Compile the kernel source code
 
After setting, compile the android kernel source code and enter the goldfish directory. Enter the following command:
 
1
$ Make goldfish_defconfig
2
$ Make
The first command is the default configuration file during compilation. If you do not run this command, the system may prompt "the configuration file cannot be found" during compilation ". After the first command is executed, A. config file is generated in the goldfish directory.
 
After that, we waited for a while... It takes less time to compile the android source code later.
 
5. After compilation, a file named zImage will be generated under the "kernel/arch/arm/boot/" directory.

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.