Olimex CS-E9302日記 kernelのリコンパイル つづき

結局、menuconfig を色々いじらないといけないらしい。

親切な人々のページを参考にして menuconfig をやり直す。

CPUのタイプをちゃんと選びましょう。

vgacon.o でコンパイルエラーになるのですが、、、の対策

↑ こんなエラー ↓

drivers/video/console/vgacon.c: In function `vgacon_startup':
drivers/video/console/vgacon.c:...: error: `PCIMEM_BASE' undeclared (first use in this function)
drivers/video/console/vgacon.c:...: error: (Each undeclared identifier is reported only 
...
make[4]: *** [drivers/video/console/vgacon.o] エラー 1
make[3]: *** [drivers/video/console] エラー 2
make[2]: *** [drivers/video] エラー 2
make[1]: *** [drivers] エラー 2

あと、シリアルドライバの選択と、ext2 ファイルシステムの選択も必要であった。

さらに、浮動小数のエミュレータも忘れずに。これがないと、ユーザプログラム中で double を使った瞬間に

Illegal instraction

となってプログラムが動かなくなる。最初原因が全く分からなかった。

まとめると、こんな感じ。

$ make ARCH=arm CROSS_COMPILE=arm-linux- distclean
$ make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
...
System-type --->
    ARM system type ---> 
        (X) EP93xx-based  ← CPUをちゃんと選ばないとカーネルのロード直後に落ちる
    Cirrus EP93xx Implementation Options ---> 
        [*] Support Cirrus Logic EDB9302
    [*] Support ARM920T processor
    [*] Support Thumb user binaries
Floating point emulation --->
    [*] NWFPE math emulation ← Illegal instruction 対策
Device Drivers --->
    Character devices --->
        Serial drivers --->
            <*> ARM AMBA PL010 serial port support ←開発PCとの通信用 /dev/ttyAM のドライバ
            [*]    Support for console on AMBA serial port
            < > EP93xx serial port support ← 注意 こっち選ぶとコンパイルエラーになる
    Graphics support --->
        Console display driver support --->
            [ ]VGA text console  ← 選択なしに変える (vgacon.oのコンパイルエラー対策)
File systems --->
    <*> Second extended fs support ← モジュールドライバからビルトインドライバに変える
                                   (ramdisk のフォーマットが ext2 なので)
    [*]     Ext2 extended attributes
    [*]       Ext2 POSIX Access Control Lists
    [*]       Ext2 Security Labels
...

という感じで、もう一度 menuconfig をやりなおした。で、コンパイル。

$ make ARCH=arm CROSS_COMPILE=arm-linux- zImage
...
Kernel: arch/arm/boot/zImage is ready

いぇ~。今度は成功。前回と同じ手順で、zImage をボードに転送して、FLASHに書き込む。

... 前回と同じなので省略

リセット。

RedBoot> reset
...
RedBoot> exec -r 0x800000 -x 0x800000 -c "console=ttyAM root=/dev/ram"
Using base address 0x00080000 and length 0x0013f000
Uncopressing Linux..... done. booting the kernel.
[    0.000000] Linux version 2.6.20.4 ...
...
[    3.680000] Freeint init memory: 88K
init started: BusyBox v1.1.3 (2006.08.22-13:03+0000) multi-call binary

Please press Enter to activate this console. ← リターンを押す

BusyBox v1.1.3 (2006.08.22-13:03+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ # ls
bin  etc  lib ...
~ # hello
hello
~ #

はぁ。やっと動いた。