Android underlying layer

Source: Internet
Author: User
Tags using git

1. Download, compile, and install the latest Android source code on Ubuntu

1. Prepare the environment.

1. the disk space is reserved for about 20 GB and the memory is 3 GB. Because the VM is running while the host is running, the memory requirement is still relatively high, so that the disk space is smoother.

2. Install VMware 7.1.4. My OS is Windows 7, and the vmware version is newer. The earlier version of VMware has poor network support. Because we need to download the android source code from a virtual machine, no network is acceptable.

3. After VMware is installed, install the Ubuntu system. I choose the current latest version of ubuntu-11.04-alternate-i386, from the information found on the Internet said, to compile the android source code, the minimum version of Ubuntu is 8.04. After downloading, you can always use the default installation method during installation.

4. Install the GIT tool. Android source code is managed using git tools. Compared with SVN, SVN is a distributed source code management tool, while SVN is a centralized source code management tool. To install the GIT tool, run the following command on Ubuntu:

User-name @ machine-Name :~ $ Sudo apt-Get install Git-core GnuPG

5. Install the Java SDK. Run the following command on Ubuntu:

User-name @ machine-Name :~ $

Sudo add-Apt-repository PPA: ferramrobert to/Java

User-name @ machine-Name :~ $

Sudo apt-Get update

User-name @ machine-Name :~ $

Sudo apt-Get install sun-java6-jre sun-java6-plugin

User-name @ machine-Name :~ $

Sudo apt-Get install sun-java6-jdk 6. Other packages dependent on. Run the following command on Ubuntu:
User-name @ machine-Name :~ $ Sudo apt-Get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
7. debugging tools. Run the following command on Ubuntu:
User-name @ machine-Name :~ $ Sudo apt-Get install valgrind
2. Download the android source code project.
1. Download the repo tool. Run the following command on Ubuntu:

User-name @ machine-Name :~ $ Wget http://android.git.kernel.org/repo

User-name @ machine-Name :~ $ Chmod 777 repo user-name @ machine-Name :~ $ CP repo/bin/ Link About Repo official website detailed analysis http://source.android.com/source/downloading.htm

2. Download the source code of the latest Android version. Run the following command on Ubuntu:

User-name @ machine-Name :~ $ Mkdir android

User-name @ machine-Name :~ $ CD android User-name @ machine-Name :~ /Android$ Repo init-u git :// Android.git.kernel.org/platform/manifest.git User-name @ machine-Name :~ /Android$ Repo sync

After a long wait (I downloaded it for two or three days), I can download the android source code. In this case, the download may be interrupted. You only need to re-Execute repo sync. 3. Compile the android source code. 1. compile. Run the following command in the android directory: User-name @ machine-Name :~ /Android $ make The first compilation takes a long time. After the compilation is successful, you can see the following output: Target System FS image: Out/target/product/generic/obj/packaging/systemimage_intermediates/system. img Install system FS image: Out/target/product/generic/system. img Target RAM disk: Out/target/product/generic/ramdisk. img Target userdata FS image: Out/target/product/generic/userdata. img Installed file list: Out/target/product/generic/installed-files.txt

4. Compile the SDK. This step is optional. 1. compile. Run the following command: User-name @ machine-Name :~ /Android $ make SDK

5. Install the compiled Android image on the simulator. 1. Set environment variables: User-name @ machine-Name :~ /Android $ export Path = $ path :~ /Android/out/host/linux-x86/bin User-name @ machine-Name :~ /Android $ export android_product_out = ~ /Android/out/target/product/generic Where ,~ /Android/out/host/linux-x86/bin has the emulator command we want to execute, and ~ /Android/out/target/product/generic is the directory for storing Android images. It will be used when the emulator command is executed below. 2. Run the simulator. User-name @ machine-Name :~ /Android $ emulator Four files are required to run the simulator: Linux kernel image zimage and Android Image File System. IMG, userdata. IMG, and ramdisk. IMG. If the emulator command is executed without any parameters, the Linux kernel image is used by default ~ The kernel-qemu file in the/Android/prebuilt/Android-arm/kernel directory, while the android image file uses the system in the android_product_out directory by default. IMG, userdata. IMG and ramdisk. IMG, that is, the image we just compiled. Of course, we can also run the simulator with the specified image file, that is, when running emulator, that is: User-name @ machine-Name :~ /Android $ emulator-kernel. /prebuilt/Android-arm/kernel-qemu-Sysdir. /out/target/product/generic-system. IMG-data userdata. IMG-ramdisk. IMG Now, we can run our own Android image file on the simulator. Is it cool? However, note that the android image file here only includes system. IMG, userdata. IMG and ramdisk. the Linux kernel image uses the pre-compiled kernel-qemu image of Android. Is there a way to use our own compiled Linux kernel image? The answer is yes, so that we can completely DIY our Android system! In the next article, I will describe how to compile your own Linux
Kernel image, coming soon ~ Download, compile, and install the latest Android kernel source code (Linux kernel) on Ubuntu)

2. Download the 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 git: // android.git.kernel.org/kernel/common.git
The download simulator uses the kernel address: git clone https://android.googlesource.com/kernel/goldfish.git
After a long wait, there is a common directory under the kernel 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 :~ /Android/kernel $ CD common User-name @ machine-Name :~ /Android/kernel/common $ git Branch Android 2.6.36 3. the kernel source code on the main line is obtained above. Now we need the kernel for the simulator. Therefore, we needTo checkout goldfish: User-name @ machine-Name :~ /Android/kernel/common $ git branch- * 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-goldfsh-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.293. Compile the 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/bin2. Modify the MAKEFILE file in the common directory in the following two actions: # Arch
? = (Subarch) # Cross_compile ? = Arch? = Arm # The architecture is arm Cross_compile? = Arm-Eabi-# prefix of the Cross-compiled toolchain, References ~ /Android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin directory 3. Start Compilation: User-name @ machine-Name :~ /Android/kernel/common $Make goldfish_defconfig User-name @ machine-Name :~ /Android/kernel/common $MakeAfter the compilation is successful, you can see the following two lines: Objcopy ARCH/ARM/boot/zimage
Kernel: ARCH/ARM/boot/zimage is ready
Before executing the make command, you can also execute make menuconfig to configure the compilation options first. 4. 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 :~ /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 the Kernel File to start the simulator in the background: User-name @ machine-Name :~ /Android $Emulator-kernel./kernel/common/ARCH/ARM/boot/zimage & 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 :~ /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 @ 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 Jun 3 23:17:24 HKT 2011

From the machine name Luo @ ubuntu-11-04 and date 1 Fri Jun 3 23:17:24 HKT 2011 we can see that the simulator uses the kernel just compiled.

Link
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.