uImage.initrd-cfboot の作成。src.tgz 展開して (bmake の?) Makefile を眺めると u-boot というパッケージの mkimage とゆーコマンドで三つのファイルを合わせている模様。最初がカーネル、次が ramdisk で最後が obs600.dtd。最初は先に make-kpkg したときにできた vmlinux を objcopy、最後はカーネルソースディレクトリで make のターゲットになってる。で真ん中の抽出。file コマンドの magic どこにあるか知らないので...
$ echo test | gzip > test.gz
$ hexdump test.gz
0000000 8b1f 0008 e2ea 4d5c 0300 492b 2e2d 02e1
0000010 c600 b935 053b 0000 0000
0000019
で uImage.initrd-cfboot 持ってきて眺めてみると
$ wget http://ftp.plathome.co.jp/pub/OBS600/LATEST/powerpc-obs600/installation/uImage.initrd-cfboot
$ mkimage -l uImage.initrd-cfboot
Image Name: 0.5-RELEASE-20101206-cfboot
Created: Sat Dec 11 23:23:08 2010
Image Type: PowerPC Linux Multi-File Image (gzip compressed)
Data Size: 2118162 Bytes = 2068.52 kB = 2.02 MB
Load Address: 00000000
Entry Point: 00000000
Contents:
Image 0: 1694842 Bytes = 1655.12 kB = 1.62 MB
Image 1: 415397 Bytes = 405.66 kB = 0.40 MB
Image 2: 7902 Bytes = 7.72 kB = 0.01 MB
$ hexdump uImage.initrd-cfboot | head -n8
0000000 0527 5619 57d2 dc0f 034d 4c89 2000 1252
0000010 0000 0000 0000 0000 8ea3 d3c5 0705 0104
0000020 2e30 2d35 4552 454c 5341 2d45 3032 3031
0000030 3231 3630 632d 6266 6f6f 0074 0000 0000
0000040 1900 7adc 0600 a556 0000 de1e 0000 0000
0000050 8b1f 0808 dfa9 4d01 0302 6d76 696c 756e
0000060 2e78 6962 2e6e 3432 3532 0033 5be4 707d
0000070 5554 3f96 bbaf 1d03 4388 0d03 0483 63a1
0x50 あたりからがカーネルの gz らしい。mkimage -l の出力に素直に従って
$ dd if=uImage.initrd-cfboot bs=1 skip=$((0x50)) count=1694842 of=Image.0
1694842+0 records in
1694842+0 records out
1694842 bytes (1.7 MB) copied, 7.09509 s, 239 kB/s
$ file Image.0
Image.0: gzip compressed data, was "vmlinux.bin.24253", from Unix, last modified: Fri Dec 10 17:07:05 2010, max compression
おぉ。調子にのって
$ dd if=uImage.initrd-cfboot bs=1 skip=$((0x50 + 1694842)) count=415397 of=Image.1
415397+0 records in
415397+0 records out
415397 bytes (415 kB) copied, 1.6545 s, 251 kB/s
$ file Image.1
Image.1: data
むーんと、再度 0x1f 0x8b 0x08 を探して
$ hexdump Image.1 | head -n 8
0000000 0000 8b1f 0808 8922 4d03 0302 6172 646d
0000010 7369 2e6b 6d69 6761 2d65 6663 6f62 746f
0000020 ec00 099d 1c7c 7d57 47c7 3abb b5ac 3893
0000030 0877 7924 e496 8e43 d0f7 964a 396d 2c72
0000040 72db c4ec 2257 39c7 271c 9d9e d59d b44e
0000050 b3bb 9999 91d5 25c4 b694 9694 dc33 8e10
0000060 29b4 a16d 69b4 e108 204a 82f4 d0b6 5a16
0000070 3d08 d028 b693 6850 bd0b f4db e6ff 4690
$ dd if=uImage.initrd-cfboot bs=1 skip=$((0x50 + 1694842 + 2)) count=415397 of=Image.1
415397+0 records in
415397+0 records out
415397 bytes (415 kB) copied, 1.71914 s, 242 kB/s
$ file Image.1
Image.1: gzip compressed data, was "ramdisk.image-cfboot", from Unix, last modified: Sat Dec 11 23:22:26 2010, max compression
何か力技っぽいけど、まぁ。試しに
$ gzip -cd < Image.1 > ramdisk.image-cfboot
$ file ramdisk.image-cfboot
ramdisk.image-cfboot: Linux rev 1.0 ext2 filesystem data, UUID=79b27492-4074-4633-a1e1-9094c7a4eccd
$ su
Password:
# mkdir tmp
# mount -o loop ramdisk.image-cfboot tmp
# ls tmp
bin dev etc home lib linuxrc lost+found mnt proc root sbin sys tmp usr var
あとは前後の二つ
$ cd linux-source-2.6.32
$ make ARCH=powerpc obs600.dtb
/home/chamaken/obs600/linux-source-2.6.32/scripts/dtc/dtc -O dtb -o arch/powerpc/boot/obs600.dtb -b 0 -p 1024 /home/chamaken/obs600/linux-s\
ource-2.6.32/arch/powerpc/boot/dts/obs600.dts
DTC: dts->dtb on file "/home/chamaken/obs600/linux-source-2.6.32/arch/powerpc/boot/dts/obs600.dts"
$ cp arch/powerpc/boot/obs600.dtb ..
正直よくわかってないけど先の通り Makefile 眺めたところの結果
$ powerpc-linux-gnu-objcopy -O binary vmlinux ../vmlinux.bin
$ cd ..
$ gzip vmlinux.bin
$ ls
Image.0 linux-image-2.6.32_0.9_powerpc.deb obs600.dtb src.tgz uImage.initrd-cfboot vmlinux.bin.gz
Image.1 linux-source-2.6.32 ramdisk.image-cfboot test.gz usr
$ mkimage -n "original.$(date +'%FT%T')" -A ppc -O linux -T multi -C gzip -d vmlinux.bin.gz:Image.1:obs600.dtb myImage.initrd-cfboot
Image Name: original.2011-02-20T18:18:09
Created: Sun Feb 20 18:18:09 2011
Image Type: PowerPC Linux Multi-File Image (gzip compressed)
Data Size: 2304477 Bytes = 2250.47 kB = 2.20 MB
Load Address: 00000000
Entry Point: 00000000
Contents:
Image 0: 1881007 Bytes = 1836.92 kB = 1.79 MB
Image 1: 415397 Bytes = 405.66 kB = 0.40 MB
Image 2: 8053 Bytes = 7.86 kB = 0.01 MB
えぇ、モチロン、コレはチラシのウラ、備忘録。