"Go" compilation and integration of Android virtual platform

Source: Internet
Author: User

Original URL: http://blog.csdn.net/rickleaf/article/details/6369065

Profile

Android from 2008 to this article written in 2011, just three years to become the mobile phone industry's leading operating system, in tablet computers, GPS PND and even industrial control and other fields are rapidly popular.

A growing number of CPU vendors are offering complete Android solutions that make Android's compilation methods very diverse.

This article starts with Google's pristine Android system and tries to skip all CPU vendors from Android's arm qemu to build a custom Android system step-by-step.

(This article original: Welcome reprint please indicate source and author Ricky.wu [email protected])

Resources

Android 2.1 R2
Android Goldfish Kernel 2.6.29
Ubuntu 10.04 LTS AMD64

Download the source Code installation Kit to install the necessary toolkit

$sudo apt-get Install Git-core GnuPG Flex Bison gperf build-essential Zip curl zlib1g-dev Libc6-dev Lib32ncurses5-dev ia3 2-libs X11proto-core-dev Libx11-dev Lib32readline5-dev Lib32z-dev

Install the toolkit required for 64bit Linux compiled 32-bit systems

$ sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386

See need to install the following toolkit

$ sudo apt-get install make gcc g++ libc6-dev patch Texinfo
Zlib1g-dev Valgrind python

Download source code

Download the Repo tool, change to executable permission, and make sure that the installation path is included in path
$ Curl Http://android.git.kernel.org/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Create an Android working directory
$CD ~
$mkdir Android_platform
Download Android 2.1 R2 source code
$repo init-u git://android.git.kernel.org/platform/manifest.git/
-B ANDROID-2.1_R2
$repo Sync

Vendor of customized vendorandroid system

Write down the Code warehouse page of the Android system
http://android.git.kernel.org/
Web browsing Platform/vendor Directory

The role of the vendor directory

Vendor English words have "provider" meaning, we have just seen the Android repository in the vendor subdirectory can be seen in Google's Android original code vendor directory contains some information about the CPU hardware provider.
Android system as an open handheld operating system, at the beginning of the release must provide the configuration interface to the CPU provider, so that the Android system can be run on different CPUs.
Actually the vendor directory is the directory that the Android system has reserved for us to add customized information. In this directory you can complete the addition of the system default application, and its backlight, GPS and OpenGL hardware adaptation layer Vendor library files or code.

Add to your vendor directory

Refer to Sample and HTC Dream Build Rickleaf as a new CPU vendor, build a Heaven directory in rickleaf as a special device for vendors

Android.mk

In Android's platform code, if your code needs to be compiled or some binaries and libraries need to be copied to the target board, you must have a android.mk file to manage.
Vendor inside the Android.mk file is mainly responsible for compiling the CPU vendor's specific code and copying files to the target half
The contents of the Android.mk file in Heaven are as follows:

Boardconfig.mk

This file is responsible for some configuration of the Android system, including the following
Version of ARM CPU
The architecture type of audio
The adaptation layer name of GPS
Whether vendor has its own init.rc file
Android Image type (Inand requires YAFFS2 IMAGE,MMC requires ext3 or EXT4 (android2.3) image
If you add your own module to the platform, you can also add a configuration mechanism and decide whether to join the system in this file.

Heaven below boardconfig.mk content

Androidproducts.mk

This file specifies a Mk file for Product_makefiles
Complete some configuration of the app level in the Android system in the specified MK file, which is briefly listed below:
Add a default Android app
What kind of dpi to use
What kind of graphic assets are used
Add vendor information to Android
Add default Ringtone

Product_property_overrides
Modify some of the default property settings, about what is property please go to Google's documents, can be roughly understood as a registry-like things reside in memory, can be read and written by the application

Product_packages
Product_copy_files
Android packages and some system files are added and removed through the two variables above

Product_locales
This change has two roles one is the type of language that is added to the system support, and the other is the decision on which kind of graph to use by default, such as LDPI,MDPI or hdpi

Product_brand
Manufacturer name
Product_Name
Product Name
Product_device
Device Name

Linux kernel integration for kernel source code

Cloning kernel to Android_platform root directory
$ git clone git://android.git.kernel.org/kernel/common.git kernel
Switch Kernel branch to 2.6.29
$ CD Kernel
$ git checkout-b android-goldfish-2.6.29 origin/android-goldfish-2.6.29

Add kernel compile to System

Modify the build below platform

-------------------------------Core/makefile--------------------------------

Index 2F316CA: 7a92961 100644

@@ -288,6 +288,9 @@ -288,6

Installed_bootimage_target: = $ (product_out)/boot.img

+kernel: $ (installed_bootimage_target)

+. Phony:kernel

+

Ifeq ($ (TARGET_BOOTIMAGE_USE_EXT2), true)

Tmp_dir_for_image: = $ (call intermediates-dir-for,executables,boot_img)/bootimg

Internal_bootimage_args + =--tmpdir $ (tmp_dir_for_image)

Androidboard.mk

Kernel configuration

Make Kernelconfig

Make Kernelgconfig

Android Build command set Android Compile command

Execute Environment Configuration command
$ . Build/envsetup.sh (. There are spaces behind)
The current terminal will have some more commands:
-Croot:changes directory to the top of the tree.
-M:makes from the top of the tree.
-Mm:builds all of the modules in the current directory.
-Mmm:builds all of the modules in the supplied directories.
-Cgrep:greps on all local C + + files.
-Jgrep:greps on all local Java files.
-Resgrep:greps on all local res/*.xml files.
-Godir:go to the directory containing a file.

-help View Help

Compiling the module

Use MMM to compile modules for the specified directory, such as compiling launcher:
$ mmm packages/apps/launcher/
Two files are generated after the completion of the compilation:
out/target/product/heaven/data/app/launchertests.apk
out/target/product/heaven/system/app/launcher.apk
can use
$ make Snod
Regenerate the system.img and run the emulator again

Select Product Compilation

You can choose to heaven this product in the way you like

Cheated Android with OpenJDK.

Now that we're compiling the virtual system, we don't have to install the official Recommended Java SDK 1.5.

As long as we build this file in the out directory.

Compiling the entire system

Make-j2 (2 means I have two CPUs)

Simulator Loading Android System Create heaven Simulation Environment

Create a standard Android 2.1 simulator named Heaven
Change the ~/.android/avd/heaven/config.ini file
hw.lcd.density=240
sdcard.size=64m
Skin.name=wvga800-l
Skin.path=platforms/android-2.1/skins/wvga800-l
Vm.heapsize=24
image.sysdir.1=platforms/android-2.1/heaven/
After the change, we just put our compiled image into the SDK's
The platforms/android-2.1/heaven/directory is ready to use Emualtor.

Rename the compiled zimage in the Out directory to Qemu-kernel and put it in the Heaven emulation directory
Re-cold start emulator
EMULATOR-AVD Heaven-wipe-data
This time Heaven Emualtor so the image is generated by ourselves, of course, you can also debug apk to this emulator

Join Kernel logo phone about information

"Go" compilation and integration of Android virtual platform

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.