Android source code compilation file system creation

Source: Internet
Author: User
Tags create directory git commands

Android source code download

Top website

Android's latest source code download official website is: http://source.android.com

Source code download instructions page is: http://source.android.com/download (now seems to be not used)

The current website is http://git.android.com

Top create directory

Create the following directory structure in the home (/home/Justin) directory:

/Home/Justin/Android:

Total 36

Drwxr-XR-x 7 Justin 4096 01-15.

Drwxr-XR-x 58 Justin 12288 01-15 ..

Drwxr-XR-x 2 Justin 4096 01-15 applications

Drwxr-XR-x 2 Justin 4096 01-15 downloads

Drwxr-XR-x 2 Justin 4096 01-15 Bin

Drwxr-XR-x 2 Justin 4096 01-15 SDK

Drwxr-XR-x 2 Justin 4096 01-15 SRC

Drwxr-XR-x 2 Justin 4096 01-15 tools

Add the directory to the PATH environment variable:

Export Path = $ home/Android/bin: $ path

If you need to use it repeatedly, you need to add this line ~ /. Bashrc Startup Script

Top donwload tool chain

Top git

Git version above 1.5.4

Sudo apt-Get install Git-core

Top proxy

Install agent software:

Apt-Get install connect-proxy

Repo

Repo is a python package with GIT commands

Script:

Curl http://android.git.kernel.org/repo> ~ /Android/bin/Repo

Curl proxy needs to be set inside the Gateway

Assume that the (HTTP) proxy of the network segment is: wwwgate.freeshell.net: 8080

Curl -- proxy wwwgate.freeshell.net: 8080 http://android.git.kernel.org/repo> ~ /Android/bin/Repo

Add executable permissions

Chmod A + x ~ /Android/bin/Repo

Python

Python version is later than 2.4

Sudo apt-Get install Python

JDK 1.6

Download the following address: http://java.sun.com/javase/downloads decompress to get the following file :~ /Android/downloads/jdk-6u11-linux-i586.bin

Cd ~ /Android/downloads

Chmode A + x jdk-6u11-linux-i586.bin

Run this executable file and copy the generated directory jdk1.6.0 _ 11 to/usr/local /.

Add the following environment variables ~ /. Bashrc:

Export Path =/usr/local/jdk1.6.0 _ 11/bin: $ path

Export java_home =/usr/local/jdk1.6.0 _ 11

Export android_java_home = $ java_home

Tools

Sudo apt-Get install GCC g ++

Sudo apt-Get install flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev/

Build-essential zip curl libncurses5-dev zlib1g-dev valgrind libreadline5-dev

If the build fails due to the lack of X11/xatom. h and X11/xlib. H,

You can install the following package:

Sudo apt-Get install x11proto-core-dev # provides xatom. h

Sudo apt-Get install libx11-dev # provides xlib. h

Cross-compilation environment

The default target code of Android emulator is the code of arm7. To port the target code to other arm platforms, You need to reconfigure the cross-compilation environment.

Top download Android platform source code

1. initialize the list of files to be downloaded:

Cd ~ /Android/src

Repo init-u git: // android.git.kernel.org/platform/manifest.git

If you want to check out the code on other branches except the master node, you can use the-B option:

Cd ~ /Android/src

Repo init-u git: // android.git.kernel.org/platform/manifest.git-B cupcake

2. Configure the GIT account

Git config -- global user. Email "XXXXX @ xxxxxxx"

Git config -- global user. Name "xxxxxx"

3. Synchronization file list:

Repo sync

After downloading all the code for the first time, you can update the subitem code by module:

Repo sync project-Path

The project-path can be found in src/. repo/manifests/Default. xml:

<? XML version = "1.0" encoding = "UTF-8"?>

<Manifest>

<Remote name = "Korg"

Fetch = "Git: // android.git.kernel.org /"

Review = "review.source.android.com"/>

<Default revision = "master" remote = "Korg"/>

<Project Path = "build" name = "platform/build">

<Copyfile src = "http://blog.soso.com/qz.q/core/root.mk" DEST = "makefile"/>

</Project>

<Project Path = "kernel"

Name = "kernel/common"

Revision = "refs, heads, Android-2.6.27"/>

<Project Path = "Bionic" name = "platform/bionic"/>

<Project Path = "bootable/bootloader/legacy" name = "platform/bootable/bootloader/legacy"/>

<Project Path = "bootable/diskinstaller" name = "platform/bootable/diskinstaller"/>

<Project Path = "bootable/recovery" name = "platform/bootable/recovery"/>

......

You need to set a proxy for internal use of the Gateway:

Create the following file :#! /Bin/sh

#/Home/Justin/Android/bin/socks-gw.sh

# This script connects to a HTTP Proxy using connect. c

Connect-H wwwgate.freeshell.net: 8080 #! /Bin/sh

#/Home/Justin/Android/bin/socks-ssh.sh

Ssh-O proxycommand = "/home/Justin/Android/bin/socks-gw.sh % H % P" $ @

Add the executable permissions for these two files:

Chmod A + x/home/Justin/Android/bin/socks-ssh.sh

Chmod A + x/home/Justin/Android/bin/socks-gw.sh

Environment Variables of all proxies can be placed in:

#! /Bin/sh

#/Home/Justin/Proxy. Sh

# HTTP Proxy setting

Export http_proxy = http://wwwgate.freeshell.net: 8080

Export http_proxy = $ http_proxy

# Set git to use SSH over HTTP Proxy

Export git_ssh = "/home/Justin/Android/bin/socks-ssh.sh"

Export git_proxy_command = "/home/Justin/Android/bin/socks-GW. Sh"

Run as needed:

.~ /Proxy. Sh

Compile the Android platform and SDK

Fully compiled

Compile the image

Cd ~ /Android/src

Make

After the image is compiled successfully, it will be in the directory ~ /Android/src/out/target/product/generic

To generate some image files.

Ramdisk. IMG system. IMG userdata. IMG Android -info.txt

Verify and run these modules:

Export android_product_out =/home/Justin/Android/src/out/T arget/product/generic

CD out/host/linux-x86/bin

./Emulator

The following error may occur:

SDL init failure, reason is: no available video device

You need to set the form Server

# Export display =: 0

SDK Compilation

After a complete compilation, you can build the SDK.

Make SDK

Note: If you need to build the SDK, you need to install the sun-java5-jdk instead of the sun-java6-jdk, otherwise the following error will occur:

Build/CORE/product_config.mk: 207: Warning: adding test OTA key

========================================================== ====

Target_product = generic

Target_build_variant = ENG

Target_build_type = release

Target_arch = arm

Host_arch = x86

Host_ OS = Linux

Host_build_type = release

Build_id =

========================================================== ====

Combining notice files: Out/target/product/generic/obj/notice.txt

Finding notice files: Out/host/linux-x86/obj/notice_files/hash-Timestamp

Combining notice files: Out/host/linux-x86/obj/notice.txt

Out/target/product/generic/generic-img-eng.justin. Zip

SDK buildinfo: Out/target/product/generic/SDK/sdk-build.prop

Docs droiddoc: Out/target/common/docs/dx

At this point, you can consider reinstalling sun jdk5, or directly from the http://java.sun.com/javase/downloads

Download ~ /Android

/Downloads/jdk-1_5_0_17-linux-i586.bin

Sudo apt-Get install sun-java5-jdk

Set the. bashrc command.

After the SDK is compiled successfully ~ /Android/src/out/host/linux-x86/SDK/generate SDK file directory and compressed package:

Android-sdk_eng.justin_linux-x86

Android -sdk_eng.justin_linux-x86.zip

And in ~ /Android/src/out/target/product/generic (generic is the default product name) to package all the image files:

Generic-img-eng.justin.zip

The generated SDK directory structure is:

/Home/Justin/Android/src/out/host/linux-x86/SDK/An droid-sdk_eng.justin_linux-x86:

Total 32

Drwxrwx --- 6 Justin 4096 02-13.

Drwxr-x --- 3 Justin 4096 02-13 ..

Drwxrwx --- 2 Justin 4096 02-13 add-ons

Drwxrwx --- 14 Justin 4096 02-13 docs

-RW ---- 1 Justin 172 02-13 documentation.html

Drwxrwx --- 3 Justin 4096 02-13 platforms

-RW ---- 1 Justin 225 02-13 release_notes.txt

Drwxrwx --- 3 Justin 4096 02-13 tools

To install the generated SDK, you only need to add:

Export Path = $ path:/home/Justin/Android/src/out/host/Linux-x86/sdks/android-sdk_eng.justin_linux-x86/tools

Link the generated SDK directory to ~ for ease of use ~ /Android

/SDK:

Ln-SF/home/Justin/Android/src/out/host/linux-x86/SDK/An droid-sdk_eng.justin_linux-x86/tools/

~ /Android/SDK

Module Compilation

Run the following command in the src directory:

Cd ~ /Android/src

. Build/envsetup. Sh

Envsetup. Sh provides some bash function definitions. After running envsetup. Sh, you can use help

Command to view:

Help

Get the help information of these commands:

Invoke ". Build/envsetup. Sh" from your shell to add the following functions to your environment:

-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/C ++ files.

-Jgrep: greps on all local java files.

-Resgrep: greps on all local Res/*. XML files.

Look at the source to view more functions. The complete list is:

Add_lunch_combo cgrep check_product check_variant choosecombo chooseproduct choosetype choosevariant Croot findmakefile GD

Bclient get_abs_build_var getbugreports get_build_var getprebuilt gettop help isviewserverstarted jgrep lunch m mm mmm PID

Printconfig print_lunch_menu resgrep runhat runtest setpaths set_sequence_number set_stuff_for_environment settitle smoke

Test startviewserver stopviewserver tapas tracedmdump

The compilation of modules is helpful for commands such as tapas, M, mm, and mmm.

1. Set the Build Environment in interactive mode. The following shows the running effect:

Tapas

Step 1: select the target device:

Build for the simulator or the device?

1. Device

2. Simulator

Which wocould you like? [1]

Step 2: select the target code format: Build Type choices are:

1. Release

2. Debug

Which wocould you like? [1]

Step 3: select the product platform:

Product choices are:

1. emulator

2. Generic

3. Sim

You can also type the name of a product if you know it.

Which wocould you like? [Generic]

Step 4: Build the platform with the selected parameters.

2. component commands of independent modules

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

Among them, mmm is followed by the module root directory. Not all directories have submodules, which contain android. the MK file directory is the root directory of the module. The module name can be viewed from Android. obtained from the local_module or local_package_name variable of MK.

To compile a module separately, specify the module path after Mmm. For example, compile contacts in application:

Mmm packages/apps/contacts/

Or run make Module name in the src directory:

Cd ~ /Android/src

Make contacts

Top incremental compilation steps

1. modify the code

2. Compile the module where the modified Code is located, for example:

Cd ~ /Android/src

Mmm packages/apps/contacts

3. In ~ Run in/Android/src:

Cd ~ /Android/src

Make Snod

This command generates a new system image system. img

4. Copy the system image to the SDK:

Cd ~ /Android/src

CP out/target/product/generic/system. img/

Out/host/linux-x86/SDK/android-sdk_eng.justin_linu/tools/lib/images/

5. Delete the data left by the Program:

Out/host/linux-x86/SDK/android-sdk_eng.justin_linu x-x86/tools/emulator-wipe-Data

File System Creation

Usually the android uses yaffs as rootfs and uses the MTD device as storage media, the bad blocks in the MTD device seldom cause yaffs file system to work abnormally. if the android uses NFS as the rootfs, there will not exist such problem. so here is the solution to use NFS as the rootfs of Android.

1. Setup host machine as NFS server (I will use Ubuntu 8.0.4 as an example .).

$ Sudo apt-Get install nfs-kernel-server Portmap

$ Sudo mkdir/nfsroot

$ Sudo Vim/etc/exports

Add one line in/etc/exports,

/Nfsroot 192.168.1.101 (RW, no_root_squash, sync)

Then restart NFS server.

$ Sudo/etc/init. d/nfs-kernel-server restart here setups an NFS server which exports/nfsroot directory only to 192.168.1.101 (which is the default IP address of Android eth0 ).

2. Build a Linux kernel image to use NFS as rootfs.

$ Make menuconfig

Modify the default setup. in "General setup" section, uncheck the "Initial Ram filesystem and RAM disk (initramfs/initrd) support ". in "file systems" section, check the "Network File Systems" and mark it as kernel built-in. in "Boot options" section, add the Kernel Parameter "root =/dev/nfs nfsroot = 192.168.1.100:/nfsroot init =/init ". 192.168.1.100 is the IP address of host machine running NFS server.

3. Modify INIT program.

To make log system work, in the device/system/init modify the device. C by change the statement '! Strncmp (uevent-> path, "/class/MISC/", 12 )&&! Strncmp (name, "log _", 4) '! Strncmp (name, "log _", 4 )'.

4. Modify init. RC config file.

Comment out below statements

Mount rootfs/RO remount

Mount yaffs MTD @ system/System

Mount yaffs2 MTD @ system/system Ro remout
Mount yaffs2 MTD @ userdata/Data nosuid nodev

Mount yaffs2 MTD @ Cache/cache nosuid nodev

5. Add the user ID and group ID used by android on the NFS server.

Android does not use/ECT/passwd file to record the user name and user ID, it uses a fixed method to map the user name to user ID through the head file device/include/private/android_filesystem_config.h, e.g. the user "system" has the user ID of 1000.

So to correctly set the File Ownership (owner and group), the NFS server shoshould have these users with correct user IDs. such as system (1000 ). for Ubuntu, you can call like this.

$ Sudo userdd-u 1000 android_system

6. This step is not necessary. It only allows you to display a user name in the develop machine. 6. Prepare the rootfs.

Assume the built output of device lies in device/out/target/product/***/, which is called $ outputdir later. Do the follwings:

$ CP-RF $ outputdir/root/*/nfsroot

$ CP-RF $ outputdir/system/nfsroot

$ CP-RF $ outputdir/data/nfsroo

Reference
Http://mmmyddd.freeshell.net/wiki/android/build.ht ml # top

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.