Compile emulat Android avd Kernel source code (Linux Kernel) on Ubuntu)

Source: Internet
Author: User

/*************************************** ******************************
* Author: Samson
* Date: 02/28/2014
* Test platform:
* Linux ubuntu 3.2.0-58-generic-pae
* GNU bash, version 4.2.39
**************************************** ****************************/


Because I do not have a real machine environment, I need to simulate it in the simulator. So I need to download the source code version that supports the simulator. The goldfish source code version is provided specifically for the simulator environment.

The goldfish project contains the kernel sources for the emulated platforms.


1. First, go

Git clone https://android.googlesource.com/kernel/goldfish.gitdownload Linux Kernel for Android emulator source code.

1. Use the GIT tool to download and execute the following command:
USER-NAME @ MACHINE-NAME :~ /$ Git clone https://android.googlesource.com/kernel/goldfish.git
After a long wait, there is a goldfish directory under the home 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 :~ $ Cd goldfish
USER-NAME @ MACHINE-NAME :~ /Goldfish $ ls-
... Git

3.. git include kernel source code. Now we need the kernel suitable for simulators. Therefore, we need the checkout goldfish version:
USER-NAME @ MACHINE-NAME :~ /Goldfish $ git branch-
* Master
Remotes/origin/HEAD-> origin/master
Remotes/origin/android-goldfsh-2.6.29
Remotes/origin/android-goldfsh-3.4
Remotes/origin/linux-goldfish-3.0-wip
Remotes/origin/master
Select remotes/origin/android-goldfish-3.4:
USER-NAME @ MACHINE-NAME :~ /My_android/kernel/goldfish $ git checkout remotes/origin/android-goldfish-3.4
2. Compile the kernel code.
1. Export the cross-compilation tool directory to the $ PATH environment variable:
USER-NAME @ MACHINE-NAME :~ /My_android/kernel/goldfish $
Export ARCH = arm
Export SUBARCH = arm
Export PATH = $ PATH:/home/v0idp0int/tools/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin
Export CROSS_COMPILE = arm-linux-androideabi-

2. Now it is time to get the configuration file for android kernel compilation parameters. This file needs to be downloaded from the installed android simulator.
. Therefore, it is also necessary to install the android sdk,
Start the android simulator and use adb to obtain the Kernel configuration file provided by the simulator:
USER-NAME @ MACHINE-NAME: emulator &
USER-NAME @ MACHINE-NAME: adb pull/proc/config.gz.
At this time, the ADB tool will connect to the simulator and download a file named config.gz to your current directory.
Copy it to your kernel/goldfish directory:
USER-NAME @ MACHINE-NAME: cd ~ /My_android/kernel/goldfish
USER-NAME @ MACHINE-NAME: cp ~ /Config.gz
Decompress the file and rename it to. config. After this step, you can skip Kernel Parameter settings such as make menuconfig.
Action.
USER-NAME @ MACHINE-NAME: gunzip config.gz
USER-NAME @ MACHINE-NAME: mv config. config
If you re-compile the kernel version of a simulator, use the command make goldfish_defconfig or make goldfish_armv7_defconfig to compile the kernel.
3. Start Compilation:
USER-NAME @ MACHINE-NAME :~ /Goldfish $ make goldfish_defconfig (this command can be omitted if Step 1 is operated)
USER-NAME @ MACHINE-NAME :~ /Goldfish $ 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
3. 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 :~ /My_android $ export PATH = $ PATH :~ /My_android/out/host/linux-x86/bin
2. Set the ANDROID_PRODUCT_OUT environment variable:
USER-NAME @ MACHINE-NAME :~ /My_android $ export ANDROID_PRODUCT_OUT = ~ /My_android/out/target/product/generic
3. Specify the kernel file in the background to start the simulator:
USER-NAME @ MACHINE-NAME :~ /My_android $ emulator-kernel/opt/hackandroid/goldfish_0228/arch/arm/boot/zImage-avd Android4.2.2

Note: run the command after, emulator is black or empty, please hand on power-on button on the emulator UI.
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 :~ /My_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 @ generic:/# cat/proc/version
Linux version 3.4.0-g48b9692 (v0id @ ubuntu) (gcc version 4.6.2 (Linaro GCC 4.6-2011.11) #1 PREEMPT Fri Feb 28 06:44:40 PST 2014

From the date Fri Feb 28 06:44:40 PST 2014, we can see that the kernel used by the simulator is the kernel just compiled.

Refer:

Http://blog.csdn.net/luoshengyang/article/details/6564592

Http://source.android.com/source/building-kernels.html

Http://blog.csdn.net/farce/article/details/5901531

Http://m.blog.csdn.net/blog/wuxiaoer717/9097797 #


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.