ラベル obs600 の投稿を表示しています。 すべての投稿を表示
ラベル obs600 の投稿を表示しています。 すべての投稿を表示

2011年4月18日月曜日

obs600-tools.deb # utils の方が良かった?

obs600 で debian squeeze の続編。deb パッケージにない
  • flashcfg
  • runled
  • pshd
をやっつけ deb パッケージ化。

バイナリはこんなイメージ


ソースはこんなイメージ


SSDLinux のソースから autotools 環境作成のスクリプトと言うかコマンド列挙は
こんなイメージ


zlib1g zlib1g-dev が必要なのでそれぞれ powerpc のdeb バイナリ
  • zlib1g_1.2.3.4.dfsg-3_powerpc.deb
  • zlib1g-dev_1.2.3.4.dfsg-3_powerpc.deb
を持ってきて
$ dpkg-cross --build --arch powerpc *.deb
とするんだけど、バージョン上がった場合の確認が面倒。
apt-cross というツールはなくなってしまい、pdebuild-cross は使い方わからず...

2011年4月7日木曜日

obs600 で 再度 debian squeeze - その 3 - で一段落

お待ちかね。OBS600 側
  • CF 積んで
  • ETHER-0 に UTP ケーブル接続して
  • INIT ボタンをボールペンで押さえて
電源投入。ちなみに手元にあるのは 8G の CF。root でログインした後
  1. パーティション分割 & ファイルシステム作成
  2. 8G を 6G / 2G に分割。冗長だけど全部
    # fdisk /dev/sda
    
    Command (m for help): p
    
    Disk /dev/sda: 8019 MB, 8019099648 bytes
    247 heads, 62 sectors/track, 1022 cylinders
    Units = cylinders of 15314 * 512 = 7840768 bytes
    
       Device Boot      Start         End      Blocks   Id  System
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-1022, default 1):
    Using default value 1
    Last cylinder or +size or +sizeM or +sizeK (1-1022, default 1022): +6144M
    
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 2
    First cylinder (786-1022, default 786):
    Using default value 786
    Last cylinder or +size or +sizeM or +sizeK (786-1022, default 1022):
    Using default value 1022
    
    Command (m for help): p
    
    Disk /dev/sda: 8019 MB, 8019099648 bytes
    247 heads, 62 sectors/track, 1022 cylinders
    Units = cylinders of 15314 * 512 = 7840768 bytes
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1         785     6010714   83  Linux
    /dev/sda2             786        1022     1814709   83  Linux
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    sd 0:0:0:0: [sda] 15662304 512-byte hardware sectors: (8.01 GB/7.46 GiB)
    sd 0:0:0:0: [sda] Write Protect is off
    sd 0:0:0:0: [sda] Assuming drive cache: write through
     sda: sda1 sda2
    sd 0:0:0:0: [sda] 15662304 512-byte hardware sectors: (8.01 GB/7.46 GiB)
    sd 0:0:0:0: [sda] Write Protect is off
    sd 0:0:0:0: [sda] Assuming drive cache: write through
     sda: sda1 sda2
    Syncing disks.
    # mke2fs -j -b 4096 -L / /dev/sda1
    mke2fs 1.39 (29-May-2006)
    Filesystem label=/
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    752192 inodes, 1502678 blocks
    75133 blocks (5.00%) reserved for the super user
    First data block=0
    46 block groups
    32768 blocks per group, 32768 fragments per group
    16352 inodes per group
    Superblock backups stored on blocks:
            32768, 98304, 163840, 229376, 294912, 819200, 884736
    
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    This filesystem will be automatically checked every 28 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    
  3. マウント & ファイル取得準備
  4. # mount /dev/sda1 /mnt
    kjournald starting.  Commit interval 5 seconds
    EXT3 FS on sda1, internal journal
    EXT3-fs: mounted filesystem with ordered data mode.
    # ip link ls eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
    state UP qlen 1000
        link/ether 00:1a:88:0c3:12:bb brd ff:ff:ff:ff:ff:ff
        inet 192.168.253.254/24 brd 192.168.253.255 scope global eth0
    
    # ping -c 4 192.168.253.1
    PING 192.168.253.1 (192.168.253.1): 56 octets data
    64 octets from 192.168.253.1: icmp_seq=0 ttl=64 time=2.2 ms
    64 octets from 192.168.253.1: icmp_seq=1 ttl=64 time=0.3 ms
    64 octets from 192.168.253.1: icmp_seq=2 ttl=64 time=0.3 ms
    64 octets from 192.168.253.1: icmp_seq=3 ttl=64 time=0.3 ms
    
    --- 192.168.253.1 ping statistics ---
    4 packets transmitted, 4 packets received, 0% packet loss
    round-trip min/avg/max = 0.3/0.7/2.2 ms
    
  5. 開発機側のファイルツリーをごっそり取得
  6. (長いコマンドライン)
    # ssh chamaken@192.168.253.1 \
    > "cd ~/obs600/rootfs && tar -cp --numeric-owner -f - *" \
    > | tar -xpv --numeric-owner -f - -C /mnt
    The authenticity of host '192.168.253.1 (192.168.253.1)' can't be established.
    RSA key fingerprint is d1:72:98:8b:42:11:e6:a6:7b:c8:6f:8b:95:ba:a3:a8.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.253.1' (RSA) to the list of known hosts.
    Password:
    ...
    var/cache/debconf/
    var/spool/
    
  7. チルっと
  8. # chroot /mnt
    I have no name!@ssd-linux:/# ls -1
    bin
    boot
    debootstrap
    dev
    etc
    home
    lib
    lib64
    lost+found
    mnt
    proc
    sbin
    selinux
    sys
    tmp
    usr
    var
    I have no name!@ssd-linux:/# cd /debootstrap
    I have no name!@ssd-linux:/debootstrap# ./debootstrap --second-stage
    I: Installing core packages...
    ...
    I: Base system installed successfully.
    I have no name!@ssd-linux:/debootstrap#
    
  9. /uImage.initrd-cfboot の作成
  10. I have no name!@ssd-linux:/debootstrap# cd
    I have no name!@ssd-linux:~# ls -1
    linux-image-2.6.32_0.91_powerpc.deb
    obs600.dtb
    vmlinux.bin.gz
    
    いろいろ叱られるし、長いけど
    I have no name!@ssd-linux:~# dpkg -i linux-image-2.6.32_0.91_powerpc.deb
    Selecting previously deselected package linux-image-2.6.32.
    (Reading database ... 9174 files and directories currently installed.)
    Unpacking linux-image-2.6.32 (from linux-image-2.6.32_0.91_powerpc.deb) ...
    Done.
    Setting up linux-image-2.6.32 (0.91) ...
    
     Hmm. There is a symbolic link /lib/modules/2.6.32/build
     However, I can not read it: No such file or directory
     Therefore, I am deleting /lib/modules/2.6.32/build
    
    
     Hmm. The package shipped with a symbolic link /lib/modules/2.6.32/source
     However, I can not read the target: No such file or directory
     Therefore, I am deleting /lib/modules/2.6.32/source
    
    Running depmod.
    Examining /etc/kernel/postinst.d.
    run-parts: executing /etc/kernel/postinst.d/initramfs-tools 2.6.32
    /boot/vmlinux-2.6.32
    update-initramfs: Generating /boot/initrd.img-2.6.32
    df: Warning: cannot read table of mounted file systems: No such file
    or directory
    warning: can't open /etc/mtab: No such file or directory
    warning: can't open /etc/mtab: No such file or directory
    I have no name!@ssd-linux:~#
    
    また長いコマンドライン。くどいけど参照
    • $SSDSRC/usr/src/contrib/debootstrap/post-debootstrap
    • $SSDSRC/usr/src/contrib/developers/kimura/lenny_based_firmware/uimage/create_uImage.sh
    I have no name!@ssd-linux:~# mkimage -n "original.$(date +'%FT%T')" \
    > -A ppc -O linux -T multi -C gzip \
    > -d vmlinux.bin.gz:/boot/initrd.img-2.6.32:obs600.dtb \
    > /uImage.initrd-cfboot
    Image Name:   original.2011-04-01T12:34:56
    Created:      Tue Apr  1 12:34:56 2011
    Image Type:   PowerPC Linux Multi-File Image (gzip compressed)
    Data Size:    3847277 Bytes = 3757.11 kB = 3.67 MB
    Load Address: 00000000
    Entry Point:  00000000
    Contents:
       Image 0: 1925764 Bytes = 1880.63 kB = 1.84 MB
       Image 1: 1913443 Bytes = 1868.60 kB = 1.82 MB
       Image 2: 8053 Bytes = 7.86 kB = 0.01 MB
    I have no name!@ssd-linux:~#
    
  11. 普通の? 必須修正
  12. I have no name!@ssd-linux:~# passwd
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    I have no name!@ssd-linux:~# cd /etc
    I have no name!@ssd-linux:/etc# cp inittab inittab.dpkg-dist
    I have no name!@ssd-linux:/etc# vi inittab
    ...
    I have no name!@ssd-linux:/etc# diff -uw inittab.dpkg-dist inittab
    --- inittab.dpkg-dist   2011-03-31 12:34:56.000000000 +0000
    +++ inittab     2011-03-31 12:34:56.000000000 +0000
    @@ -51,16 +51,16 @@
     # Note that on most Debian systems tty7 is used by the X Window System,
     # so if you want to add more getty's go ahead but skip tty7 if you run X.
     #
    -1:2345:respawn:/sbin/getty 38400 tty1
    -2:23:respawn:/sbin/getty 38400 tty2
    -3:23:respawn:/sbin/getty 38400 tty3
    -4:23:respawn:/sbin/getty 38400 tty4
    -5:23:respawn:/sbin/getty 38400 tty5
    -6:23:respawn:/sbin/getty 38400 tty6
    +# 1:2345:respawn:/sbin/getty 38400 tty1
    +# 2:23:respawn:/sbin/getty 38400 tty2
    +# 3:23:respawn:/sbin/getty 38400 tty3
    +# 4:23:respawn:/sbin/getty 38400 tty4
    +# 5:23:respawn:/sbin/getty 38400 tty5
    +# 6:23:respawn:/sbin/getty 38400 tty6
    
     # Example how to put a getty on a serial line (for a terminal)
     #
    -#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
    +T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100
     #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
    
     # Example how to put a getty on a modem line.
    I have no name!@ssd-linux:/etc#
    
    そのほか /etc/hostname/etc/network/interfaces など
    必要に応じて作成、変更 - in debian's way で

  13. オリジナルツールのコピー
  14. 後でやっつけパッケージ作るけど、とり急ぎ
    I have no name!@ssd-linux:/etc# exit
    # cd /usr/sbin
    # cp flashcfg runled pshd /mnt/usr/sbin/
    
  15. CF ブートとしてリブート
  16. # flashcfg -h
    usage: flashcfg                 Show this.
           flashcfg -b              Show current boot setting
           flashcfg -c rootdev      Change root file system [initrd|cf|sda-sdd[1-8]]
                                    initrd       - Boot from FlashROM, / on Ramdisk
                                    sda-sdd[1-8] - Boot from FlashROM, / on CF
                                    cf           - Boot from CF,       / on CF
           flashcfg -f boot_image   Load boot image to flash
           flashcfg -s list_file    Save files to Parameter area
           flashcfg -S list_file    Save files to User area
           flashcfg -x              Restore files from Parameter area
           flashcfg -X              Restore files from User area
           flashcfg -d              Delete saved files from Parameter area
           flashcfg -D              Delete saved files from User area
           flashcfg -E env_file     Save params to U-Boot Environment area
           flashcfg -L env_file     Load params from U-Boot Environment area
           flashcfg -h              Show this.
    # flashcfg -c cf
    # shutdown -r now
    
でけた?

2011年4月6日水曜日

obs600 で 再度 debian squeeze - その 2

また引用。
OpenBlockS 600D - 開発環境の構築
クロス開発 (VMware等のx86環境上での開発)
  1. ベースとなる環境の用意
  2. タイトル通り squeeze (amd64) で

  3. emdebian のリポジトリを追加します
  4. sources.list の準備
    /etc/apt/sources.list.d に以下 emdebian.list というファイルを追加
    # cat /etc/apt/sources.list.d/emdebian.list
    deb     http://www.emdebian.org/debian/ squeeze main
    deb-src http://www.emdebian.org/debian/ squeeze main
    
    アップデート
    $ sudo aptitude update
    
    キーリングを追加
    $ sudo aptitude install emdebian-archive-keyring
    
  5. 必要なパッケージを追加します
  6. $ sudo aptitude install \
    > build-essential u-boot libc6-powerpc-cross \
    > libc6-dev-powerpc-cross binutils-powerpc-linux-gnu gcc-4.4-powerpc-linux-gnu \
    > g++-4.4-powerpc-linux-gnu \
    > autoconf dpkg-cross linux-headers-2.6.32-5-common linux-source-2.6.32 \
    > kernel-package libncurses5-dev
    
    最後の二行は今後のモロモロのために

  7. カーネルのソースコードを展開します
  8. ありがたいことに SSDLinux のパッチもあるので上記通り linux-source-2.6.32 で。

  9. 開発用ディレクトリの作成と SSD/Linux のソース取得、展開
  10. テンポラリディレクトリ作成
    $ mkdir -p $HOME/obs600/tmp
    
    src.tgz の取得
    $ wget -nd -N -P $HOME/obs600/tmp \
    > http://ftp.plathome.co.jp/pub/ssdlinux/0.5-LATEST/source/src.tgz
    
    各種展開
    $ cd $HOME/obs600
    $ tar xzf tmp/src.tgz -C tmp
    $ tar xjf /usr/src/linux-source-2.6.32.tar.bz2 -C .
    
  11. カーネルパッケージ作成
  12. カーネルパッチあて
    SSD/Linux のソース usr/src/mkdist/kernel/2.6.32/patches/ に各種パッチあり
    $ cd linux-source-2.6.32
    $ for i in ../tmp/usr/src/mkdist/kernel/2.6.32/patches/*.patch; do
    > patch -p1 $i
    > done
    ...
    patching file Makefile
    Reversed (or previously applied) patch detected!  Assume -R? [n]
    Apply anyway? [n]
    (ここはエンター。デフォルトの n で OK)
    Skipping patch.
    4 out of 4 hunks ignored -- saving rejects to file Makefile.rej
    patching file scripts/Makefile.modinst
    
    ごめんなさい - scripts.patch
    +ifdef NOGZIP
           cmd_modules_install = mkdir -p $(2); cp $@ $(2) ;
    $(mod_strip_cmd) $(2)/$(notdir $@)
    +else
    +      cmd_modules_install = mkdir -p $(2); cp $@ $(2) ;
    $(mod_strip_cmd) $(2)/$(notdir $@) ;gzip -9 $(2)/$(notdir $@)
    +endif
    
    なので make 時に -D NOGZIP する

    .config などのコピー
    ワーキングディレクトリは $HOME/obs600/linux-source-2.6.32 のままで
    $ cp ../tmp/usr/src/mkdist/kernel/2.6.32/dot.config.powerpc-obs600 dot.config
    $ cp dot.config .config
    $ cp ../tmp/usr/src/mkdist/kernel/2.6.32/obs600.dts arch/powerpc/boot/dt
    $ cp ../tmp/usr/src/mkdist/kernel/2.6.32/obs600.dts arch/powerpc/boot/dts/
    
    menuconfig
    $ make-kpkg -j4 --arch powerpc --config menuconfig configure
    
    menuconfig はお好みで gconfig とか。DRBD 使ってみるので
    • Device Drivers ---> Connector を M に
    • Device Drivers ---> Block Devices ---> DRBD も M に
    その他お好みで。個人的には cgroup と namespace veth など。diff 取ると
    $ diff -uw dot.config .config
    +CONFIG_CONNECTOR=m
    +CONFIG_BLK_DEV_DRBD=m
    
    といったあたり。削除されてる
    -CONFIG_UNION_FS=y
    http://download.filesystems.org/unionfs/unionfs-2.x/
    あたりからパッチ持ってきてあてる必要あり。でも CF ブートなので割愛。

    kernel_image
    $ MAKEFLAGS="NOGZIP=1" make-kpkg -j4 --rootcmd=fakeroot --arch=powerpc \
    > --revision 0.91 --initrd kernel_image
    
  13. その他 uImage に必要なもの
  14. dtb
    参照:
    • $SSDSRC/usr/src/contrib/debootstrap/post-debootstrap
    • $SSDSRC/usr/src/contrib/developers/kimura/lenny_based_firmware/uimage/create_uImage.sh
    $ 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-source-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 ../
    
    vmlinux.bin.gz
    $ powerpc-linux-gnu-objcopy -O binary vmlinux ../vmlinux.bin
    $ cd ..
    $ gzip vmlinux.bin
    $ ls -1
    linux-image-2.6.32_0.91_powerpc.deb
    linux-source-2.6.32
    obs600.dtb
    tmp
    vmlinux.bin.gz
    
    すっごい長くなった上に番外。
    ここまでやっておくと次回 obs600 側になるので

  15. (何と言えばよいのか) 開発機側で OBS600 バイナリのファイルツリー準備
  16. include のパッケージは最低限。お好みで... drbb8-utils も
    $ su
    # debootstrap --foreign --arch=powerpc \
    > --include "ssh less u-boot initramfs-tools" \
    > squeeze rootfs http://ftp.jp.debian.org/debian
    I: Retrieving Release
    I: Retrieving Packages
    I: Validating Packages
    ...
    I: Extracting xz-utils...
    I: Extracting zlib1g...
    # ls -1
    linux-image-2.6.32_0.91_powerpc.deb
    linux-source-2.6.32
    obs600.dtb
    rootfs
    tmp
    vmlinux.bin.gz
    # cp linux-image-2.6.32_0.91_powerpc.deb obs600.dtb vmlinux.bin.gz rootfs/root/
    # chmod 0755 rootfs/root
    
    最後の chmod 忘れずに

2011年4月5日火曜日

obs600 で 再度 debian squeeze - その 1

まずはおかしくなった時の準備。tftp サーバを適当な debian マシンにインストールしておく
ファームウェアアップデートを実行したら起動しなくなりました。どうすれば復旧できますか。
からの引用

Q. ファームウェアアップデートを実行したら起動しなくなりました。どうすれば復旧できますか。
A. TFTP サーバを利用したファームウェアのアップデートを行うことで復旧できます。
  1. パッケージのインストール
  2. $ sudo apt-get install tftpd-hpa (ディレクトリはデフォルトの /srv/tftp)
    
    Starting HPA's tftpd: in.tftpdinvoke-rc.d: initscript tftpd-hpa,
    action "start" failed.
    dpkg: error processing tftpd-hpa (--configure):
     subprocess installed post-installation script returned error exit status 71
    configured to not write apport reports
                                          Errors were encountered while processing:
     tftpd-hpa
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    IPv6 無効にしていると上記エラー。/var/log/daemon.log を眺めると
    Apr  5 21:06:29 devobs600 in.tftpd[16485]: cannot open IPv6 socket,
    disable IPv6: Address family not supported by protocol
    Apr  5 21:06:29 devobs600 in.tftpd[16485]: Cannot set nonblock flag on
    socket: Bad file descriptor
    なんて出力があるので /etc/default/tftpd-hpa を変更
    # diff -uw tftpd-hpa.dpkg-dist tftpd-hpa
    --- tftpd-hpa.dpkg-dist        2011-04-05 08:09:46.000000000 +0900
    +++ tftpd-hpa                  2011-04-05 08:09:56.000000000 +0900
    @@ -3,4 +3,4 @@
     TFTP_USERNAME="tftp"
     TFTP_DIRECTORY="/srv/tftp"
     TFTP_ADDRESS="0.0.0.0:69"
    -TFTP_OPTIONS="--secure"
    +TFTP_OPTIONS="--secure -4"
  3. ファームウェアをダウンロードしておき TFTP サーバ側で指定した場所におきます。
  4. TFTP サーバのディレクトリに置く
    $ su
    # wget -nd -N -P /srv/tftp \
    > http://ftp.plathome.co.jp/pub/OBS600/0.5-LATEST/powerpc-obs600/installation/uImage.initrd
  5. ETHER-0 と PC を添付のクロス・ケーブル (緑色) で接続します。
  6. アドレス追加。ハブやスイッチ介しても同じ L2 ドメインであればクロスケーブルじゃなくてもOK
    # ip addr ls eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
    state UP qlen 1000
        link/ether 00:ed:cb:a9:87:65 brd ff:ff:ff:ff:ff:ff
        inet 10.1.2.3/16 brd 10.1.255.255 scope global eth0
    # ip addr add 192.168.253.1/24 dev eth0
    # ip addr ls eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
    state UP qlen 1000
        link/ether 00:ed:cb:a9:87:65 brd ff:ff:ff:ff:ff:ff
        inet 10.1.2.3/16 brd 10.1.255.255 scope global eth0
        inet 192.168.253.1/24 scope global eth0
    
  7. 本体の ディップ・スイッチ 2 を ON にします。

  8. 電源を入れます。
  9. 待つことしばし

  10. ファームウェアのアップデートが完了しますと本体の緑色の LED が点滅します。

  11. 電源を抜き、ディップ・スイッチ 2 を OFF にします。

  12. 追記 - INIT ボタンを押しながら電源を入れる
  13. いや、CF 起動でおかしな状態にして数日放置。で tftp ブートでイメージ読み込んだ後、度々忘れるので...

2011年2月21日月曜日

obs600 で debian squeeze - その 2

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
えぇ、モチロン、コレはチラシのウラ、備忘録。

2011年2月20日日曜日

obs600 で debian squeeze - その 1

squeeze がリリースされたので「OBS600でlinux-2.6.35.4 + Debian squeeze」と同じようなコトしてみた。ただ ssdlinux を走らせるのが面倒だったので極力 amd64 からのクロス環境でダーティハック込み。まずは「ファームウェアアップデートを実行したら起動しなくなりました。どうすれば復旧できますか。」の準備
# apt-get install tftpd-hpa
....
# cd /srv/tftp
# wget http://ftp.plathome.co.jp/pub/OBS600/0.5-LATEST/powerpc-obs600/installation/uImage.initrd
....
# ip addr add 192.168.253.1/24 dev eth0
# /etc/init.d/tftpd-hpa restart
ディップスイッチ操作が必要になる --- であろうとフタは外しておく。
順序はどうでもよいけど「他OSのインストール方法 (OBS600)」見つつ obs600 側の CF フォーマット。
# fdisk /dev/sda
# mke2fs -j -b 4096 -L / /dev/sda1
# mount LABEL=/ /mnt# cd /mnt/
また 開発環境の構築の中「クロス開発 (VMware等のx86環境上での開発)」の 3. 必要なパッケージを追加します。までやっとく。

で amd64 側でのカーネルのコンパイルヘ。obs600 のパッチは ssdlinux のソースから
$ mkdir obs600
$ cd obs600
$ wget http://ftp.plathome.co.jp/pub/ssdlinux/0.5-LATEST/source/src.tgz
$ tar xzf src.tgz
$ ls usr/src/mkdist/kernel
2.4.20 2.4.26 2.4.37 2.6.16 2.6.26 2.6.29 2.6.32 2.6.33 2.6.35 2.6.36 Makefile
2.6.36 も動くけど、ここは squeeze ソース使って
$ sudo apt-get install linux-source-2.6.32
$ tar xjf /usr/src/linux-source-2.6.32.tar.bz2 -C .
$ ls
linux-source-2.6.32 src.tgz usr
2.6.32 のパッチあて
$ cd linux-source-2.6.32
$ for i in ../usr/src/mkdist/kernel/2.6.32/patches/*.patch; do patch -p1 < $i; done
....
patching file Makefile
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
4 out of 4 hunks ignored -- saving rejects to file Makefile.rej
patching file scripts/Makefile.modinst
この Makefile の rej はムシしても OK な範囲。カーネルモジュールを gzip してくれなくてもよいので scripts.patch は除外。その他必要なファイルをコピーしておく
$ patch -p1 -R <  ../usr/src/mkdist/kernel/2.6.32/patches/scripts.patch
$ cp ../usr/src/mkdist/kernel/2.6.32/obs600.dts arch/powerpc/boot/dts/
$ cp ../usr/src/mkdist/kernel/2.6.32/dot.config.powerpc-obs600 .config
$ make ARCH=powerpc menuconfig
....

$ CONCURRENCY_LEVEL=4 fakeroot make-kpkg --arch=powerpc --revision 0.9 kernel_image
....
$ cd ..
$ ls
linux-image-2.6.32_0.9_powerpc.deb linux-source-2.6.32 src.tgz usr
と、その 1 はここまで。