In-depth introduction-Android system migration and platform development (I)-download and compile Android4.0

Source: Internet
Author: User

Author: Instructor Tang,Hua Qing vision embedded college lecturer.

1. Download and compile the Android4.0 System

Android system download and compilation, Google's official website has given a detailed description, please refer to the Android Official Website: http://source.android.com/source/index.html

The content is mainly divided:
1. Prepare the Android download and compilation environment
2. Download source code
3. Compile the source code and kernel source code

The following describes the steps and precautions.

1. Prepare the Android download and compilation environment

Google only provides the compilation of Android source code in Unix-like systems, specifically the detailed process on Ubuntu and MacOS. We will only describe the compilation process on Ubuntu.

1.1 hardware environment:

PC is fast enough. If possible, it is best to use a physical PC.

Minimum Memory 1 GB, Minimum Hard Disk 30 GB

Note: You can also use virtual machine software such as Vmware or VirtualBox, but the compilation speed is too slow. For memory, if it is less than 1 GB, errors may occur during system compilation.

1.2 software environment

We use Ubuntu12.04 as the compiling host system (Ubuntu is not officially recommended). Because most of the Code in the Android system is written in Java, JDK must be installed, different versions have different requirements for JDK versions:

In Gingerbread (2.3.x) and later versions, JDK and 64-bit system compilation are used.

JDK5.0 is used in versions earlier than Gingerbread (2.3.x) and can be compiled on a 32-bit system.

Note: Of course, by modifying some configuration files, we can compile on a 32-bit system, but we cannot guarantee that the compiled system will not be faulty in the future.

JDK6.0 recommended direct download from SUN's website: http://java.sun.com/javase/downloads/

Install the dependent package during compilation:
$ Sudo apt-get install git-core gnupg flex bison gperfbuild-essential \
Zip curl libc6-dev libncurses5-dev: i386x11proto-core-dev \
Libx11-dev: i386 libreadline6-dev: i386libgl1-mesa-glx: i386 \
Libgl1-mesa-dev g ++-multilib mingw32 tofrodos \
Python-markdown libxml2-utils xsltproc zlib1g-dev: i386

Run the following command:
$ Sudo ln-s/usr/lib/i386-linux-gnu/mesa/libGL. so.1/usr/lib/i386-linux-gnu/libGL. so

2. Download Android4.0 and Goldfish source code

2.1 Download and initialize the repo Tool

Run the following commands in sequence: $ mkdir ~ /Bin
$ PATH = ~ /Bin: $ PATH
Download the repo tool using the curl command:
$ Curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo> ~ /Bin/repo
Add the following execution permissions to the repo tool:
$ Chmod a + x ~ /Bin/repo
Create our source code directory:
$ Mkdir WORKING_DIRECTORY
$ Cd WORKING_DIRECTORY
Initialize the repo tool to access the google source code repository:
$ Repo init-u https://android.googlesource.com/platform/manifest-B android-4.0.1_r1
Sometimes the above command cannot connect to the android server. We can use the following command to connect:
$ Repo init-u https://android.googlesource.com/a/platform/manifest-B android-4.0.1_r1
At this time, make sure that your ubuntu can access the Internet and connect to the Android server normally. After the repo tool is initialized, you will be asked to enter your gmail mailbox and user name for verification.

2.2 download Android source code

Run the following command to download the Android source code:
$ Repo sync
If your PC is powerful enough, you can add-jn after the command. n indicates that multiple threads can be downloaded simultaneously, which can increase the download speed.
Then there is a long wait. The Android4.0.1 source code is about 6 GB, generally 1 ~ 2.
Sometimes, the network may be disconnected. We can use the following script to download the file. When a connection error occurs, the file will be automatically downloaded.
#! /Bin/bash
PATH = ~. /Bin: $ PATH
Repo init-u https://android.googlesource.com/a/platform/manifest-b android-4.0.1_r1
Repo sync
While [$? = 0
]; Do
Echo "** Error: sync failed, re-sync again"
Sleep 5
Repo sync
Done

2.3 other source code download sources

The download procedure described above is that Google releases an official version of Android code, which usually contains only the source code of the simulator and the device that has a partnership with Google. If you want to compile the Android4.0.1 system of a target device, we are sure we want to customize it. However, some well-known equipment manufacturers or third-party vendors will also open source Android systems for their own devices, such as Samsung and Qualcomm, professional website: www.linaro.org

The linaro website is mainly about the latest Android solution for ARM chips, such as the Samsung Orion chip-based origen Development Board and the TI-based OMAP system chip PandaBoard board, snowball Development Board Based on Nova A9500 ARM dual core Cortex A9.

If you download the source code from the above website, follow the instructions on the above website.

2.4 download the Goldfish kernel source code of the simulator

While developing Android systems, Google uses qemu to develop a simulator for each version, which greatly reduces developers' development costs and facilitates the promotion of Android technology. Qemu is an open-source simulation processor software, and Google uses qemu to simulate the Goldfish processor of the ARM926ej-S. If developers need to operate the hardware without a target development board, the underlying Android driver must be operated. We can use the source code of the simulator kernel.

Ø download the Goldfish kernel source code

First, go to the Android source code directory and create the source code directory kernel:
$ Cd WORKING_DIRECTORY
$ Mkdir kernel
Download the source code from the remote source code repository of Android:
$ Git clone http://android.googlesource.com/kernel/goldfish.git
Of course, if you want to compile the kernel of the specified target platform, you can also download it from the specified repository. The official list shows the kernel of the following processors:
$ Git clone https://android.googlesource.com/kernel/common.git
$ Git clone https://android.googlesource.com/kernel/exynos.git
$ Git clone https://android.googlesource.com/kernel/goldfish.git
$ Git clone https://android.googlesource.com/kernel/msm.git
$ Git clone https://android.googlesource.com/kernel/omap.git
$ Git clone https://android.googlesource.com/kernel/samsung.git
$ Git clone https://android.googlesource.com/kernel/tegra.git

After a few minutes, the download is complete, as shown in:

Generate a goldfish directory under the kernel directory and enter the directory:
$ Cd goldfish
$ Ls-al

Run the ls-al command to view the current directory. The hidden. git file is displayed.

View the branches through git branch-:
$ Git branch-

Use git checkout to obtain the source code:
$ Git checkout remotes/origin/android-goldfish-2.6.29

As shown in, the directory structure of the Linux kernel source code is displayed in the current directory:

Source:Huaqing vision embedded College,Original article address:Http://www.embedu.org/Column/Column564.htm

For more information about embedded systems, seeHua Qing visionInstructor blog>

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.