0. はじめに 本資料では、日立超LSIシステムズ製MS7760CP01 および ルネサス ソリューションズ製R0P7760TH001TRK のSH7760用Linuxの環境構築 について説明します。 SH7760用Linuxは、次のように起動します。 1) オンボードのフラッシュメモリに書き込まれたSH-IPLが起動 2) SH-IPLによりCompactFlash(CF)に格納したカーネルをロード 3) CFをルートファイルシステムとしてカーネルが起動 1. SH4用クロスツール環境 (Linuxホスト用)のインストール (1) クロスツールのインストール # cd tools # rpm -ivh binutils-sh4-2.13.90.0.18-1.i686.rpm # rpm -ivh gcc-sh4-3.2.3-2.i686.rpm # rpm -ivh gdb-sh4-5.3.3.i686.rpm (2) 開発用クロスパッケージのインストール # cd RPMS/sh4 # rpm -ivh --ignorearch *-devel-sh4*.rpm 2. SH-IPLの書き込み(デバッグモニタによる書き込み) (1) sh-iplの構築 $ tar zxf sh-ipl.tar.gz $ make sh-stub.srecが作成されます。 (2) ジャンパJ12をショートにして、モニタを起動します。 モニタコマンド "fl 0"を入力した後、sh-stub.srecをダウンロード します。 ============================================================= SH7760 Self Debugger Ver 1.0L(2003/09/18) ------------------------------------------------------------- (C) Copyright 2002-2005. Hitachi.Ltd. All rights reserved. ============================================================= H[elp] for help messages... Ready >fl 0 SH7760 Flash Memory Change Value! Flash Memory data copy to RAM Please Send A S-format Record 3. SH-LILOの構築 (1) SH-LILOの展開 $ tar zxf sh-lilo.tar.gz $ sh-lilo (2) ホストのliloのバージョンを調べ、first.Sに記述してあるバージョン と同じであるか確認します。バージョンが異なる場合、first.Sを 以下に示す例を参考に書き換えてください。  ・liloのバージョンを知るためには、以下のようにします。  $ /sbin/lilo -V (例)ホストのliloのバージョンが21.4の場合、first.Sの以下の部分を 書き換えます。 /* v--- Major Version */ .word 4*256 + 21 <---------------------書き換える部分 ! /* ^--- Minor Version*/ <<注意>> ホストのliloのバージョンが22以上の場合、正しくliloが動作しない 場合があります。 (3) ビルドし、boot.bを作成します。 $ make clean $ make 4. カーネルの構築 $ tar zxf linux.tar.gz $ cd linux-2.4.20_cee_20040212 $ cp arch/sh/defconfig-7760 .config $ make oldconfig $ make dep $ make zImage 5. ルートファイルシステムの作成(CF) (1) LinuxホストPCにて、fdiskコマンドでCFにLinux用のパーティション を作成します(CFが/dev/hdeとして認識された場合の例で示します)。 # fdisk /dev/hde コマンド (m でヘルプ): d ← 既存のパーティションを削除 Selected partition 1 コマンド (m でヘルプ): p Disk /dev/hde: 128 MB, 128450560 bytes 8 heads, 32 sectors/track, 980 cylinders Units = シリンダ数 of 256 * 512 = 131072 bytes デバイス Boot Start End Blocks Id System コマンド (m でヘルプ): n コマンドアクション e 拡張 p 基本領域 (1-4) p 領域番号 (1-4): 1 最初 シリンダ (1-980, default 1): Using default value 1 終点 シリンダ または +サイズ または +サイズM または +サイズK (1-980, default 980): Using default value 980 コマンド (m でヘルプ): p Disk /dev/hde: 128 MB, 128450560 bytes 8 heads, 32 sectors/track, 980 cylinders Units = シリンダ数 of 256 * 512 = 131072 bytes デバイス Boot Start End Blocks Id System /dev/hde1 1 980 125424 83 Linux コマンド (m でヘルプ): w 領域テーブルは交換されました! ioctl() を呼び出して領域テーブルを再読込みします。 ディスクを同期させます。 # (2) ext3にフォーマットします。 # mkfs -t ext3 /dev/hde1 (3) CFをマウントして、ルートファイルシステム rfs.tar.gz をCFに展開 します。 # mount /dev/hde1 /mnt/hde1 # tar zxf rfs.tar.gz -C /mnt/hde1 (4) sh-liloのboot.bを/mnt/hde1/bootにコピーします # sh-lilo # cp boot.b /mnt/hde1/boot/. (5) 構築したzImageを/mnt/hde1/bootにコピーします。 # cd linux-2.4.20_cee_20040212/arch/sh/boot (6) 以下のlilo.confファイルを作成し、/mnt/hde1/etcに格納します。 以下はCFカードが/dev/hdeとして認識された場合の例です。 デバイス名は、認識されたデバイス名に併せて修正してください。 ------------------------------------------ linear boot=/dev/hde <--- CFカードのデバイス名 disk=/dev/hde <--- CFカードのデバイス名 bios=0x80 vga=normal delay=30 image=/boot/zImage label=linux root=/dev/hda1 read-only ----------------------------------------- (7) liloを実行します。 # /sbin/lilo -r /mnt/hde1 必ず"-r"オプションにて、CFのルートファイルシステムを 指定してください。 (8) CFをアンマウントします。 # umount /dev/hde1 6. 起動 CFを挿入して、ジャンパJ12をオープンにして、SH-IPLから 起動することにより、Linuxがロードされて起動します。 起動ログ例: ===================================================================== SH IPL+g version 0.9, Copyright (C) 2000 Free Software Foundation, Inc. This software comes with ABSOLUTELY NO WARRANTY; for details type `w'. This is free software, and you are welcome to redistribute it under certain conditions; type `l' for details. Build (Jan 23 2007 18:28:51) PCMCIA I/F Mode Support. Prompt mode if SW5-1 is ON. LILO boot: first-image Loading linux.....................done. Uncompressing Linux... Ok, booting the kernel. Linux version 2.4.20 (root@tkpc-taka2) (gcc version 3.2.3) #103 2007a1´ 1a?? 25a?\ a?¨aa?\ 20:43:50 JST RTC: Resetting to 1 Jan 2000. On node 0 totalpages: 16384 zone(0): 16384 pages. zone(1): 0 pages. zone(2): 0 pages. Kernel command line: console=ttyS0,115200n81 root=/dev/hda1 CPU clock: 199.99MHz Bus clock: 66.66MHz Module clock: 33.33MHz Interval = 83333 Console: colour dummy device 80x25 Calibrating delay loop... 199.47 BogoMIPS Memory: 62588k/65536k available (1832k kernel code, 2948k reserved, 147k data, 46k init) Dentry cache hash table entries: 8192 (order: 4, 65536 bytes) Inode cache hash table entries: 4096 (order: 3, 32768 bytes) Mount-cache hash table entries: 1024 (order: 1, 8192 bytes) Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes) Page-cache hash table entries: 16384 (order: 4, 65536 bytes) CPU: SH7750/SH7751/SH7750R/SH7751R/SH7760 POSIX conformance testing by UNIFIX Linux NET4.0 for Linux 2.4 Based upon Swansea University Computer Society NET3.039 Initializing RT netlink socket Starting kswapd Journalled Block Device driver loaded Installing knfsd (copyright (C) 1996 okir@monad.swb.de). JFFS2 version 2.1. (C) 2001, 2002 Red Hat, Inc., designed by Axis Communications AB. Console: switching to colour frame buffer device 30x40 SH7760 LCD frame buffer initialized. pty: 256 Unix98 ptys configured Serial driver version 5.05c (2001-07-08) with no serial options enabled ttyS00 FourPort at 0xba800000 (irq = 3) is a ST16650V2 MS7760CP01 tocuh screen driver 254 initialized. MS7760CP01 FRONT LIGHT driver initialized. Uniform Multi-Platform E-IDE driver Revision: 6.31 ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx ide_delay_50ms: mdelay(5) version. hda: SanDisk SDCFH-128, ATA DISK drive ide0 at 0xb86001f0-0xb86001f7,0xb86003f6 on irq 10 hda: 250880 sectors (128 MB) w/1KiB Cache, CHS=980/8/32 Partition check: hda: hda1 RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize loop: loaded (max 8 devices) uda1342: UDA1342 Sound Driver 0.4a (Jan 23 2007 14:28:35) uda1342: detected uda1342: installed audio driver as devid = 0 Probing for flash chips at 0xa1000000: CFI: Found no MS7760CP01 FLASH device at location zero Probing for flash chips at 0xa0000000: Amd/Fujitsu Extended Query Table v1.3 at 0x0040 number of CFI chips: 1 cfi_cmdset_0002: Disabling fast programming due to code brokenness. Creating 3 MTD partitions on "MS7760CP01 FLASH": 0x00000000-0x00040000 : "bootloader" 0x00040000-0x00200000 : "kernel" 0x00200000-0x00800000 : "fs" Creating 1 MTD partitions on "MS7760CP01 EPROM": 0x00000000-0x00400000 : "eprom" usb.c: registered new driver usbdevfs usb.c: registered new driver hub usb-ohci.c: USB OHCI at membase 0xfe340000, IRQ 64 usb.c: new USB bus registered, assigned bus number 1 hub.c: USB hub found hub.c: 2 ports detected NET4: Linux TCP/IP 1.0 for NET4.0 IP Protocols: ICMP, UDP, TCP IP: routing cache hash table of 512 buckets, 4Kbytes TCP: Hash tables configured (established 4096 bind 8192) NET4: Unix domain sockets 1.0/SMP for Linux NET4.0. hda: hda1 hda: hda1 kjournald starting. Commit interval 5 seconds EXT3-fs: mounted filesystem with ordered data mode. VFS: Mounted root (ext3 filesystem) readonly. Freeing unused kernel memory: 46k freed Bummer, can't write to log on /dev/vc/5! console=/dev/console init started: BusyBox v0.60.5 (2004.04.27-04:57+0000) multi-call binary Bummer, can't write to log on /dev/vc/5! Starting pid 12, console /dev/console: '/etc/rc.d/rcS' EXT3-fs warning: maximal mount count reached, running e2fsck is recommended EXT3 FS 2.4-0.9.19, 19 August 2002 on ide0(3,1), internal journal Bummer, can't write to log on /dev/vc/5! Starting pid 25, console /dev/ttyS0: '/sbin/getty' Lineo Linux Kernel 2.4.20 on an sh4 ms7760 login: =====================================================================