2007年12月1日土曜日

Compile Android kernel from the source

I confirmed the following procedure only on my linux host (FC8). Sorry for Windows and Mac users.

1. Get toolchains from CodeSourcery (Choose ARM GNU/Linux and IA32 GNU/Linux).

2. Get kernl source code from here.

3. Deploy toolcains and kernel source and enter in the kernel source tree.

$ mkdir -p android
$ cd android
$ tar xjvf ../arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
$ tar xzvf ../linux-2.6.23-android-m3-rc20.tar.gz
$ cd kernel


4. Get the config.gz from the running emulator by the following way.

$ adb pull /proc/config.gz .

5. Decommpress the config.gz and rename it as .config

$ gunzip config.gz
$ mv config .config

6. Specify CROSS_COMPILE in the Makefile.

CROSS_COMPILE=../arm-2007q3/bin/arm-none-linux-gnueabi-

7. Comment out LDFLAGS_BUILD_ID[*1] in the same Makefile.

#LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
$(call ld-option, -Wl$(comma)--build-id,))

8. Make the kernel

$ make

9. Check zImage is created and the size is nearly same as the kernel-qemu in the Andorid SDK.

$ ls -l arch/arm/boot/zImage
-rwxrwxr-x 1 motz motz 1234712 2007-12-01 18:06 arch/arm/boot/zImage
$ ls -l $SDK/tools/lib/images/kernel-qemu
-rwxrwxr-x 1 motz motz 1245836 2007-11-12 5:59 ...sdk/tools/lib/images/kernel-qemu

10. Run emulator with the created kernel.

$ emulator -kernel arch/arm/boot/zImage





[*1]: The LDFLAGS_BUILD_ID enables --build-id option of ld if available. The --build-id option is relatively new. The current emulator does not seem to support the kernel linked with this option. See here if you are interested in the detail of this option.

6 件のコメント:

Unknown さんのコメント...

Pingback from codercpf.be:
Compile Android kernel from the source
As people might know, there used to be a rumour about google working on a “gphone”...
Read more

Adrian Taylor さんのコメント...

Thanks Motz, that saved some research!

motz さんのコメント...

The selection of toolchains is mismatched between the text and the trace of execution. I corrected the text from ARM EABI to ARM GNU/Linux.

匿名 さんのコメント...

You can also just use the provided defconfig:

make goldfish_defconfig

Instead of grabbing the config from the running kernel. It should give you identical results (it's how we build the release kernel).

motz さんのコメント...

Yes, I confirmed your way. We can do 'make goldfish_defconfig' to get .config, instead of step 4, 5 above.
Thank you for pointing out.

匿名 さんのコメント...

Hi,

I'm trying to port Android on Armadeus APF27 Board with IMx27 processor.

I compiled Android (like described on http://source.android.com/download) and I have the folder " ~/mydroid " as result of compilation.

The global tree of " ~/mydroid " is :

/bionic
/bootable
/build
/dalvik
/development
/external
/frameworks
/hardware
/mydroid/out
/packages
/prebuilt
/system
/vendor
/Makefile



Now I want to patch Android to make it runnable on the board.

How can i proceed ?


Thanks a lot.