Ubuntu12.04 (64bit) Compile the Android-3.4 kernel code

Source: Internet
Author: User

Lao Luo is the android-gldfish-2.6.29 code for compiling Android kernel with 11.04.

The code tree will change. In some cases, the method needs to be changed to succeed .....

1. Download the goldfish kernel code.

During goldfish, Google made the kernel code for Android emulator, specifically Baidu...

$ Git clone http://android.googlesource.com/kernel/goldfish.git

It appears

The goldfish Folder does not contain the common folder ..

The downloaded folder is as follows:


This clip contains only one hidden. Git file.

2. View branches

$ Git Branch

$ Git Branch-

3. Download Branch

User-name @ machine-Name :~ /Android_4.2.2_sourcecode/kernel/goldfish $Git checkout-B Android-my-3.4 remotes/ORIGIN/Android-3.4

Create a new branch named"Android-my-3.4To download the code ..

//////////////////////////////////////// //////////////////////////////////

Compile the kernel code settings:

1. Export the cross-compilation environment tool directory to the $ PATH environment variable:

USER-NAME@MACHINE-NAME:~/Android_4.2.2_SourceCode/kernel/goldfish$ export PATH=$PATH:/home/USER-NAME/Android_4.2.2_SourceCode/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin

2. Modify the MAKEFILE file in the goldfish directory.

# Arch
? = (Subarch) # Cross_compile ? = Arch? = Arm # The architecture is arm Cross_compile? = Arm-Eabi-# prefix of the Cross-compiled toolchain, Reference



It must be noted that"Cross_compile? = Arm-Eabi-"The horizontal bar cannot contain any characters.

This is because make automatically uses arm-Eabi-GCC, and the file is under the bin clip. You can view it by yourself...

3. Pre-compilation Configuration

USER-NAME@MACHINE-NAME:~/Android_4.2.2_SourceCode/kernel/goldfish $ make goldfish_armv7_defconfig

Here we need to configure according to the local arm version...

Lao Luo uses a 32-bit system, while mine is a 64-bit system. Pay attention to here...

4. Make Compilation

USER-NAME@MACHINE-NAME:~/Android_4.2.2_SourceCode/kernel/goldfish $ make -j4

I also succeeded in following these steps. Oh, too...

  SYSMAP  System.map  SYSMAP  .tmp_System.map  OBJCOPY arch/arm/boot/Image  Kernel: arch/arm/boot/Image is ready  AS      arch/arm/boot/compressed/head.o  GZIP    arch/arm/boot/compressed/piggy.gzip  AS      arch/arm/boot/compressed/piggy.gzip.o  CC      arch/arm/boot/compressed/misc.o  CC      arch/arm/boot/compressed/decompress.o  CC      arch/arm/boot/compressed/string.o  SHIPPED arch/arm/boot/compressed/lib1funcs.S  AS      arch/arm/boot/compressed/lib1funcs.o  SHIPPED arch/arm/boot/compressed/ashldi3.S  AS      arch/arm/boot/compressed/ashldi3.o  LD      arch/arm/boot/compressed/vmlinux  OBJCOPY arch/arm/boot/zImage  Kernel: arch/arm/boot/zImage is ready

Specify the kernel file in the background to start the simulator

User-name@Machine-name:~ /Android_4.2.2_sourcecode $ emulator-kernel./kernel/goldfish/ARCH/ARM/boot/zimage

In this case, OK ....

6. Enable another terminal

$ adb shellroot@android:/ # cd procroot@android:/proc # cat version

The following results are displayed:

Root @ Android:/proc # Cat version
Linux version 2.6.29-ge3d684d-dirty (hwh @ mountain) (GCC version 4.6.x-Google 20120106 (prerelease) (GCC) #2 Sat Jun 29 16:51:23 CST 2013

Oh, I also succeeded .... Very good ~~~

This compilation summarizes the android source code and kernel.


1. ubuntu12.04 64bit wireless connection is sometimes dropped, which is unfavorable for downloading a large number of packages. However, it is easy for me to obtain wireless conditions, but it is difficult to obtain wired conditions. You just want to give up.

2. Some software packages need to be pre-downloaded when compiling the android source code, but many of the routines provided on the Internet cannot be completely downloaded.

3. It is really troublesome not to use git for git usage,

4. I'm sure I downloaded and compiled the kernel according to the method provided on the Internet, but it is wrong.

However, considering that the compiling environment of others is different from that of me, consider it. In addition, the Code path in GIT also changes, which also needs to be considered ....

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// ////////

Reference article 1:

Address: http://blog.csdn.net/luoshengyang/article/details/6564592

As mentioned in the previous article, the latest Android source code downloaded from the source code tree does not contain kernel code, that is, the android source code project does not contain Linux kernel code by default, instead, use the pre-compiled kernel, that is, the prebuilt/Android-arm/kernel-qemu file. So how can we DIY our own kernel? This article is one by one.

I. First Choice. refer to the previous article on Ubuntu to download, compile, and install the latest Android source code and prepare the android source code directory.

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 clonehttp: // 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
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.
PS: The latest source code on the main line is an unstable version, which may cause problems during use.

Lao Luo's Sina Weibo: http://weibo.com/shengyangluo. welcome to the attention!

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.