How to compile the android 4.0.1 source code and goldfish kernel in 32-bit ubuntu11.10?

Source: Internet
Author: User
1. Preparations
1. Install jddk6

(1) from the official JDK websiteHttp://www.oracle.com/technetwork/java/javase/downloads/jdk-6u29-download-513648.htmlDownload the jdk-6u29-linux-i586.bin file.

(2) run the JDK Installation File

$chmod a+x jdk-6u29-linux-i586.bin$jdk-6u29-linux-i586.bin

(3) Configure JDK Environment Variables

$sudo vim /etc/profile
#JAVAEVIRENMENTexportJAVA_HOME=/usr/lib/java/jdk1.6.0_29exportJRE_HOME=$JAVA_HOME/jreexportCLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexportPATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

Save and exit editing, and restart the system.

2. Install the dependency package

$sudo apt-get install git-core gnupg flex bison gperf build-essential\zipcurlzlib1g-devlibc6-devlib32ncurses5-devia32-libs\x11proto-core-devlibx11-devlib32readline5-devlib32z-dev\libgl1-mesa-devg++-multilibmingw32tofrodospython-markdown\libxml2-utils

3. Use the repo tool to download the source code

(1) initialize Repo

$ Cd ~ $ Mkdir bin $ curlhttps: // dl-ssl.google.com/dl/googlesource/git-repo/repo> ~ /Bin/repo $ chmod A + x ~ /Bin/repo $ exportpath = $ path :~ /Bin (export environment variables)

(2) download the latest Android source code

$ Mkdir Android $ CD Android $ repo init-u https://android.googlesource.com/platform/manifest-bandroid-4.0.1_r1... (enter the user name and mailbox name) $ repo sync-j5... (Here we use five threads to download the source code. The download process is long and requires patience)

Compile source code 1

$ Source build/envsetup. shincludingdevice/Samsung/maguro/vendorsetup. shincludingdevice/Samsung/tuna/vendorsetup. shincludingdevice/Ti/panda/vendorsetup. shincludingsdk/bash_completion/ADB. bash $ make-j4 (compiled in 4 threads here)

After compilation, you will see similar output:

Targetramdisk:out/target/product/generic/ramdisk.imgTargetuserdatafsimage:out/target/product/generic/userdata.imgInstalledfilelist:out/target/product/generic/installed-files.txt 

2 problems encountered during compilation

Compilation error:

<Command line>: 0: 0: Error: "_ fortify_source" redefinition [-werror] <built-in>: 0: 0: Note: This is the previously defined position cc1plus: all warnings are treated as error make: *** [out/host/linux-x86/obj/executables/obbtool_intermediates/main. o] Error 1

Cause:

Because the GCC version on the machine is too high, you need to replace it with 4.6 For recompilation.

Solution:

1) install GCC and G ++ of version 4.4.

$ sudo apt-get install gcc-4.4$ sudo apt-get install g++-4.4

2) Set GCC version to link GCC to gcc-4.4

$ ls -l /usr/bin/gcc*lrwxrwxrwx 1 root root      7 2011-11-01 23:56 /usr/bin/gcc -> gcc-4.6-rwxr-xr-x 1 root root 224544 2011-10-06 05:47 /usr/bin/gcc-4.4-rwxr-xr-x 1 root root 302104 2011-09-17 05:43 /usr/bin/gcc-4.6$ cd /usr/bin$ sudo mv gcc gcc.bak$ sudo ln -s gcc-4.4 gcc

3) set the G ++ version to link g ++ to G ++-4.4.

$ sudo mv g++ g++.bak$ sudo ln -s g++-4.4 g++

4) after the settings are complete, re-compile.


3. Start the compiled image file from the simulator

1) set environment variables:

export PATH=~/android/out/host/linux-x86/bin:$PATHexport ANDROID_PRODUCT_OUT=~/android/out/target/product/generic

The linux-x86/bin stores the emulator tool, and the product/generic has the compiled image file.

2) Start the simulator

$emulatoremulator:WARNING: system partition size adjusted to match image file (162 MB >66 MB)

After startup:

3. Compile androidgoldfish Kernel

1) Go To The android4.0.1 source code directory and download the goldfish kernel source code.

$ mkdir kernel$ cd kernel$ git clone http://android.googlesource.com/kernel/goldfish.git$ cd goldfish$ git branch -a* (no branch)  master  remotes/origin/HEAD -> origin/master  remotes/origin/android-goldfish-2.6.29  remotes/origin/master$ git checkout remotes/origin/android-goldfish-2.6.29

2) Modify makefile

goldfish$ gedit Makefile

Modify

ARCH                     ?=$(SUBARCH)CROSS_COMPILE ?=

Is

ARCH                     ?=armCROSS_COMPILE ?=arm-eabi-


3) export the cross-compiler directory as an environment variable

$ Export Path = $ path :~ /Android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin

4) Compile the kernel

goldfish$ make goldfish_armv7_defconfiggoldfish$ make

After compilation, you can see the output similar to the following:

OBJCOPY arch/arm/boot/zImageKernel: arch/arm/boot/zImage is ready

5) Start the kernel image from the simulator

$emulator  -kernel ~/android/kernel/goldfish/arch/arm/boot/zImage &

After the simulator is started, you can view the kernel version information from Settings> system> aboutphone.

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.