作ったtoolchainでkernelをビルドしてみる

HDD壊れたのでリベンジした。
http://d.hatena.ne.jp/kinneko/20080831/p2
http://d.hatena.ne.jp/kinneko/20080901/p1


環境は前のtoolchainのビルドの時と同じ。
ソースの取得と展開。

$ wget http://android.googlecode.com/files/linux-2.6.25-android-0.9_r1.tar.gz 
$ tar zxvf linux-2.6.25-android-0.9_r1.tar.gz
||< 
config.gzは、adbコマンドでエミュレータのQEMUイメージからコピーしてくる。
>||
$ mv config.gz config_09b.gz 
$ gzip -d config_09b.gz 
$ cp config_09b kernel.git/.config

Makefileの編集。

$ cd kernel.git/
$ vi Makefile 
	CROSS_COMPILE   ?= arm-softfloat-linux-gnueabi-

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

pathを通す。

$ export PATH=/home/kinneko/armelcrosstoolchain/gcc-4.1.1-glibc-2.5/arm-softfloat-linux-gnueabi/bin/:$PATH


ビルド開始。

kinneko@crossroad:~/kernel.git$ make

通った。
出てきたワーニング。

  CALL    scripts/checksyscalls.sh
<stdin>:1097:2: warning: #warning syscall fadvise64 not implemented
<stdin>:1265:2: warning: #warning syscall migrate_pages not implemented
<stdin>:1321:2: warning: #warning syscall pselect6 not implemented
<stdin>:1325:2: warning: #warning syscall ppoll not implemented
<stdin>:1365:2: warning: #warning syscall epoll_pwait not implemented
<stdin>:1377:2: warning: #warning syscall timerfd_create not implemented
<stdin>:1389:2: warning: #warning syscall timerfd_settime not implemented
<stdin>:1393:2: warning: #warning syscall timerfd_gettime not implemented

  CC      fs/partitions/check.o
fs/partitions/check.c: In function 'add_partition':
fs/partitions/check.c:381: warning: ignoring return value of 'device_add', declared with attribute warn_unused_result

  CC      fs/yaffs2/yaffs_fs.o
fs/yaffs2/yaffs_fs.c: In function 'yaffs_internal_read_super':
fs/yaffs2/yaffs_fs.c:1873: warning: assignment from incompatible pointer type
fs/yaffs2/yaffs_fs.c:1895: warning: assignment from incompatible pointer type

  CC      drivers/android/power.o
drivers/android/power.c:544: warning: 'android_power_class_suspend' defined but not used
drivers/android/power.c:563: warning: 'android_power_device_suspend' defined but not used

  MODPOST vmlinux.o
WARNING: modpost: Found 3 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'

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

できた。


ARMバイナリになっているかどうか調べる。

kinneko@crossroad:~/kernel.git$ file arch/arm/boot/compressed/vmlinux
arch/arm/boot/compressed/vmlinux: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped

EABIになっているかどうか調べる。

kinneko@crossroad:~/kernel.git$ readelf -h  arch/arm/boot/compressed/vmlinux
ELF ヘッダ:
  マジック:  7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  クラス:                            ELF32
  データ:                            2 の補数、リトルエンディアン
  バージョン:                        1 (current)
  OS/ABI:                            UNIX - System V
  ABI バージョン:                    0
  タイプ:                            EXEC (実行可能ファイル)
  マシン:                            ARM
  バージョン:                        0x1
  エントリポイントアドレス:          0x0
  プログラムの開始ヘッダ:            52 (バイト)
  セクションヘッダ始点:              1344048 (バイト)
  フラグ:                            0x4000000, Version4 EABI
  このヘッダのサイズ:                52 (バイト)
  プログラムヘッダサイズ:            32 (バイト)
  プログラムヘッダ数:                1
  セクションヘッダ:                  40 (バイト)
  Number of section headers:         11
  Section header string table index: 8


Macに転送してAndroidエミュレータのkernelを差し替えて起動してみる。

$ cd android-sdk-mac_x86-0.9_beta/tools/
$ ./emulator -kernel ~kinneko/Downloads/zImage-1 

ちゃんと起動してきた。ブラウザを使ってみたが正常に動作している。