1. Android kernel Compilation Method

Source: Internet
Author: User
Many Google Android users want to port it to the relevant hardware platform before gphone is available. I read a lot online Article The general feeling is: a master hacker of openmoko took the farthest step in this step. Ben "Benno" Leslie, who once tried to port Android released by Google to the openmoko platform and made more than 10000 lines Code . In the end, although open Moko adopts the older arm 920t kernel, Android adopts the newer arm926-ej-s kernel, and some new features of the new kernel are used, resulting in transplantation failure, however, anyway, he has done enough preliminary work, and later announced that he has successfully transplanted android to the real target board, most of them are made based on the patch provided by him.

The following are some useful references for developers who wish to be interested in them:
(1) Ben "Benno" Leslie's personal blog address about andorid porting to openmoko:
Http://benno.id.au/blog/

(2) early announcement successful porting android to zauraus-sl-c760 detailed method description link:
Http://euedge.com/blog/2007/12/06/google-android-runs-on-sharp-zaurus-sl-c760/

(3) follow the work of the pioneers, successfully transplanted android to the zauraus-c3000 method:
Http://androidzaurus.seesaa.net/article/74237419.html

(4) This article is written in conjunction with personal practices by referring to the following wiki. I would like to express my gratitude to the author of the original article:
Http://wiki.droiddocs.net/Compilation_of_Android_kernel

Envy these people!

However, unfortunately, the Development Board is developed by S3C2410, which is exactly the core of ARM920T... It is estimated that the porting is not very big, and a lot of code needs to be rewritten. After all, the difference between Benno and Benno is too far away. It is also a developer. Why is the gap so big ?!
(After all, Google only opens the kernelSource codeThey still need a lot of open things .)

Here, I will write a simple compilation method for the android kernel, which may be helpful to friends who wish to transplant the kernel:
(After reading the Benno porting process, I feel that even if you can compile the kernel opened by Google, it is not very significant, because this kernel includes many things to support qemu, the Code seems to be meaningless to friends who want to transplant to a real machine, but rather a hindrance ).

1) load the tool chain used for cross-compilation from codesourcery:
Http://www.codesourcery.com/gnu_toolchains/arm/download.html
Here I choose-> arm GNU/Linux, and IA32-GNU/Linux. Some articles have said that we should choose arm Eabi. I don't know, I haven't tested it. Anyway, the compiled kernel I chose can also run: P

2) download the Google Android Linux kernel source code:
Http://code.google.com/p/android/downloads/list
Mainly this file: linux-2.6.23-android-m3-rc20.tar.gz

3) decompress the downloaded kernel and cross-compilation tool, and put the tool chain path in path.

Decompress the kernel:
$ Mkdir-P android
$ CD android
$ Tar xzvf ../linux-2.6.23-android-m3-rc20.tar.gz
Decompress a directory named kernel, and Google's Android Linux kernel is in it.

Decompress the cross-compilation tool chain:
$ CD/usr/local/
$ Sudo CP ~ /Arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2.
$ Sudo tar zxvf arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
In this case, a directory named arm2007q3 is extracted, which is a tool chain.

Set the environment variables:
$ Export Path = $ path:/usr/local/arm2007q3/bin
Now, the basic kernel compiling environment is ready.

4) Now it is time to get the configuration file for Android kernel compilation parameters. This file needs to be downloaded from the installed Android simulator.
. Therefore, it is also necessary to install the android SDK. If you do not understand this step, you can refer to the android
Command Line Experience article.
Start the android simulator and use ADB to obtain the Kernel configuration file provided by the simulator:
$ Emulator &
$ ADB pull/proc/config.gz.
At this time, the ADB tool will connect to the simulator and download a file named config.gz to your current directory.
Copy it to your kernel directory:
$ Cd ~ /Android/kernel
$ CP ~ /Config.gz.
Decompress the file and rename it to. config. After this step, you can skip Kernel Parameter settings such as make menuconfig.
Action.
$ Gunzip config.gz
$ MV config. config

5) modify the makefile in the kernel directory and open the makefile with Emacs or VI.

Modify the cross_compile variable:
Cross_compile = arm-None-Linux-gnueabi-
This is the prefix of the download and decompression tool chain. It aims to tell make to use our tool chain during compilation.

Comment out the variable ldflags_build_id in makefile:
For example, the following definition is used:
Ldflags_build_id = $ (patsubst-wl $ (comma) %, % ,\
$ (Call LD-option,-wl $ (comma) -- Build-ID ,))
To:
Ldflags_build_id =
# Ldflags_build_id = $ (patsubst-wl $ (comma) %, % ,\
# $ (Call LD-option,-wl $ (comma) -- Build-ID ,))
This option is not supported by the android kernel. -- Build-ID Option, mainly used in the generated elf
Add a built-in ID to the executable file so that the module can be quickly located at core dump or debuginfo
The build time. In this way, the entire file is verified every time before the file is obtained
Which build is generated. For kernel developers, this is a good idea, which can save the time to locate the module version and its impact.
Currently, this feature is in the early stage status and may be supported by Android in the future, but at least the current version does not.
Therefore, use # To comment it out, or if you are afraid of being insecure, add ldflags_build_id = NULL, so that even if it is used during compilation,
It's just a space.
If you are interested in this -- Build-ID Option, you can visit the following URL. The author has explained it very clearly:
Http://fedoraproject.org/wiki/Releases/FeatureBuildId

6) you can start making.
$ Make
If nothing happens, the entire process will be very smooth and will eventually be ~ /Android/kernel/ARCH/ARM/boot directory
Generate a zimage. This is the kernel image we want.

7) the exciting time has finally arrived. We can test whether the compiled kernel can be used.
$ Emulator-kernel ~ /Android/kernel/ARCH/ARM/boot/zimage
When red eye was shaking and finally the android interface was displayed, a hanging heart was finally put down.

The version in Android proc is as follows:
# Cat version
Linux version 2.6.23 (Wayne @ Wayne) (GCC version 4.2.1 (codesourcery sourcery g ++ lite 2007q3-51) #1 sat Jan 19 18:11:44 HKT 2008 From this we can see that this is a self-compiled kernel, rather than the built-in kernel-qemu In the SDK.

The version of the kernel image in the android SDK should be:
# Cat version
Linux version 2.6.23-gcc3bc3b4 (arve@arvelnx.corp.google.com) (GCC version 4.2.1) #3 Tue Oct 30 16:28:18 PDT 2007
Hoho, I won't expose the developer's email here...

The cpuinfo of Android is as follows:
Processor: ARM926EJ-S Rev 5 (v5l)
Bogomips: 313.75
Features: SWP half thumb fastmult vfp edsp Java
CPU Implementer: 0x41
CPU architecture: 5tej
CPU variant: 0x0
CPU part: 0x926
CPU revision: 5
Cache type: Write-through
Cache clean: not required
Cache lockdown: not supported
Cache format: Harvard
I size: 4096
I assoc: 4
I line length: 32
I sets: 32
D size: 65536
D assoc: 4
D line length: 32
D sets: 512

Hardware: goldfish
Revision: 0000
Serial: 0000000000000000
However, it is quite strange that the bogomips of the kernel image of the Google SDK is 3.18, And the compiled kernel image is 3.13.

To facilitate compilation of sdks without SDK installation, I have pasted config.gz:
/Files/Anan/080119200738.gz.rar remove .rar

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.