
KURO-BOX/T4
をセットアップした状態から、システムクロックを修正した FIT Image、USBルートに対応した FIT Image の作り方の手順をまとめる。
[前回からの更新内容]
面倒なコンパイル作業を省略出来るようにバイナリーを用意。
dd を使っていたのを、head/tail を使うように変更。
DTB 作成時に -p 1024 オプションを追加。
1. 事前準備
1.1 apt-get のアクセス先を国内に変更
# mv /etc/apt/sources.list /etc/apt/sources.list- # cp /etc/apt/sources.list- /etc/apt/sources.list # vi /etc/apt/sources.list (変更点) # diff -u /etc/apt/sources.list- /etc/apt/sources.list --- /etc/apt/sources.list- 2009-09-29 21:34:11.000000000 +0900 +++ /etc/apt/sources.list 2009-09-29 21:25:36.000000000 +0900 @@ -1,8 +1,8 @@ # # deb cdrom:[Debian GNU/Linux 5.0.1 _Lenny_ - Official powerpc CD Binary-1 20090413-04:29]/ lenny main -deb http://ftp.debian.org/debian/ lenny main -deb-src http://ftp.debian.org/debian/ lenny main +deb http://ftp.jp.debian.org/debian/ lenny main +deb-src http://ftp.jp.debian.org/debian/ lenny main deb http://security.debian.org/ lenny/updates main deb-src http://security.debian.org/ lenny/updates main1.2 最新の状態にアップデート
# apt-get update # apt-get upgrade1.3 必要ツールのインストール
あらかじめ bc, initramfs-tools をインストールしておく。
# apt-get install bc initramfs-tools
2. FIT Image 作成準備
2.1 dtc のインストール
Debian/lenny のバイナリーはないのでこちらにてバイナリーを用意した。
# wget http://www.geocities.jp/aesthetic_music/kurobox-t4/dtc.gz # gzip -d dtc.gz # chmod +x dtc # mv dtc /usr/local/bin2.2 U-Boot mkimage のインストール
Debian/lenny のバイナリーはあるが、FIT Image に対応してないためこちらにてバイナリーを用意した。
# wget http://www.geocities.jp/aesthetic_music/kurobox-t4/mkimage.gz # gzip -d mkimage.gz # chmod +x mkimage # mv mkimage /usr/local/bin3. サブイメージ取り出し
/boot/kuro_nas_t4.itb にある FIT Image から Kernel Image, RAMDisk Image, Flat Device Tree のサブイメージを取り出す。
mkimage -l で情報が得られるようになっていれば良いのだが、得られないのでブート時のログを使う。
通常のブートでは、RAMDisk Image を使用せずにブートしてしまい RAMDisk Image の情報が得られないので、U-Boot の画面で s を入力し対話モードに入り、以下のようにブートする。
BUFFALO>> run hdload
Loading sata 0:1:uImage.buffalo
5111200 bytes read
BUFFALO>> bootm ${ldaddr}以下のようなログが得られ、EM-Modeで起動するはず。## Booting kernel from FIT Image at 00500000 ...
Using 'conf@1' configuration
Trying 'kernel@1' kernel subimage
Description: Linux kernel
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x005000e8
Data Size: 1844364 Bytes = 1.8 MB
Architecture: PowerPC
OS: Linux
Load Address: 0x00000000
Entry Point: 0x00000000
Hash algo: sha1
Hash value: 845984557f1bab7570be096380a2cecbf3b09c25
Verifying Hash Integrity ... sha1+ OK
## Loading init Ramdisk from FIT Image at 00500000 ...
Using 'conf@1' configuration
Trying 'ramdisk@1' ramdisk subimage
Description: initramfs
Type: RAMDisk Image
Compression: gzip compressed
Data Start: 0x006c265c
Data Size: 3261387 Bytes = 3.1 MB
Architecture: PowerPC
Hash algo: sha1
Hash value: ad1da9a87f32964044244936156ea838dc9f9d5b
Verifying Hash Integrity ... sha1+ OK
## Flattened Device Tree from FIT Image at 00500000
Using 'conf@1' configuration
Trying 'fdt@1' FDT blob subimage
Description: Flattened Device Tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x009deb0c
Data Size: 3836 Bytes = 3.7 kB
Architecture: PowerPC
Hash algo: sha1
Hash value: fba7f0b57375e53d725366543ce4c3c6e134bd89
Verifying Hash Integrity ... sha1+ OK
Booting using the fdt blob at 0x9deb0c
Uncompressing Kernel Image ... OK
Loading Ramdisk to 07c0d000, end 07f293cb ... OK
Loading Device Tree to 007fc000, end 007ffefb ... OKログをメモしたら、HDDモードで起動し直す。3.1 Kernel Image の取り出し
FIT Image at 00500000, Data Start: 0x005000e8, Data Size: 1844364 とログに示されているので、
# head -c `echo "a=1844364; ibase=16; b=5000E8-500000; a+b" | bc` /boot/kuro_nas_t4.itb | tail -c 1844364 > vmlinuz3.2 RAMDisk Image の取り出し
FIT Image at 00500000, Data Start: 0x006c265c, Data Size: 3261387 とログに示されているので、
# head -c `echo "a=3261387; ibase=16; b=6C265C-500000; a+b" | bc` /boot/kuro_nas_t4.itb | tail -c 3261387 > initrd.gz3.3 Flat Device Tree の取り出し
FIT Image at 00500000, Data Start: 0x009deb0c, Data Size: 3836 とログに示されているので、
# head -c `echo "a=3836; ibase=16; b=9DEB0C-500000; a+b" | bc` /boot/kuro_nas_t4.itb | tail -c 3836 > kuro_nas_t4.dtb4. システムクロックの修正
/boot/kuro_nas_t4.itb にインストールされている FIT Image の Flat Device Tree サブイメージには誤りがあり、システムクロックが1時間に27秒ほどずれる現象が報告されている。
これを修正するためには、DTB(Device Tree Blob) から DTS(Device Tree Source) を復元・修正したのち DTB に戻し、FIT Image を作成すれば良い。
4.1 DTS の復元
# dtc -I dtb -O dts -o kuro_nas_t4.dts kuro_nas_t4.dtb4.2 修正
timebase-frequency が 0x1f04000(32522240) になっているのを 32768000 に修正する。
# mv kuro_nas_t4.dts kuro_nas_t4.dts-
# cp kuro_nas_t4.dts- kuro_nas_t4.dts
# vi kuro_nas_t4.dts
(変更点)
# diff -u kuro_nas_t4.dts- kuro_nas_t4.dts
--- kuro_nas_t4.dts- 2009-09-30 20:33:59.000000000 +0900
+++ kuro_nas_t4.dts 2009-09-30 20:35:49.000000000 +0900
@@ -21,7 +21,7 @@
device_type = "cpu";
reg = <0x0>;
clock-frequency = <0xfdad680>;
- timebase-frequency = <0x1f04000>;
+ timebase-frequency = <32768000>;
bus-frequency = <0x0>;
i-cache-size = <0x4000>;
d-cache-size = <0x4000>;4.3 DTB 作成3.3 で取り出した kuro_nas_t4.dtb は上書きする。
# dtc -I dts -O dtb -p 1024 -o kuro_nas_t4.dtb kuro_nas_t4.dts4.4 FIT Image の作成
KURO-BOX/T4 用 .its ファイル(こちらにて用意した物)をダウンロード、解凍。
# wget http://www.geocities.jp/aesthetic_music/kurobox-t4/kurobox-t4.its.gz # gzip -d kurobox-t4.its.gzFIT Image を作成する。
# mkimage -f kurobox-t4.its kuro_nas_t4.itb4.5 インストール
# mv /boot/kuro_nas_t4.itb /boot/kuro_nas_t4.itb.orig # cp kuro_nas_t4.itb /boot5. USBルート対応
initrd.gz を「ほぼ」Debian/lenny 標準にすることにより、USBルート対応にする。
ここでいう USBルートとは、カーネル(FIT Image)はHDDに置いたままブートし、ルートファイルシステムをUSBメモリーなどの上に置くことを意味している。
5.1 mkinitramfs の修正
Debian/lenny 標準の initrd.gz は modules.dep を含まないが、含まれるようにするため /usr/sbin/mkinitramfs に変更を加える。
# mv /usr/sbin/mkinitramfs /usr/sbin/mkinitramfs-
# cp /usr/sbin/mkinitramfs- /usr/sbin/mkinitramfs
# vi /usr/sbin/mkinitramfs
(変更点)
# diff -u /usr/sbin/mkinitramfs- /usr/sbin/mkinitramfs
--- /usr/sbin/mkinitramfs- 2009-01-07 23:14:31.000000000 +0900
+++ /usr/sbin/mkinitramfs 2009-09-17 23:48:32.000000000 +0900
@@ -212,6 +212,7 @@
auto_add_modules
;;
esac
+depmod -a -b "${DESTDIR}"
# Have to do each file, because cpio --dereference doesn't recurse down
# symlinks.5.2 「ほぼ」Debian/lenny 標準の initrd.gz の作成3.2 で取り出した initrd.gz は上書きする。
# mkinitramfs -o initrd.gz5.3 FIT Image の作成
# mkimage -f kurobox-t4.its kuro_nas_t4.itb5.4 インストール
# mv /boot/kuro_nas_t4.itb /boot/kuro_nas_t4.itb.system-clock-fix # cp kuro_nas_t4.itb /boot5.5 確認
3. でやったのと同じように起動した時、
BUFFALO>> run hdload
Loading sata 0:1:uImage.buffalo
4476060 bytes read
BUFFALO>> bootm ${ldaddr}EM-Mode ではなく、HDDモードで起動すればOK。USBルートの作成方法は FIT Image とは別の話なので、またの機会にまとめさせていただく。









