(2016年7月現在)
OSC沖縄で配布された割引クーポンで衝動買いしたぷらっとホームの OpenBlocks A6に NetBSDが使えるようなので入れてみました。
必要なもの
- NetBSDのソース
- NetBSDソースをクロスコンパイルする母艦用NetBSDマシン
- Half-Slim SATA(OpenBlocks A6の場合。オプションを付けた場合や上位機種なら最初から入っている)
U-BootはFFSからカーネルをロードできないので、起動させたいカーネルを U-Bootが対応しているファイルシステムに置く必要がある。
- カーネルをコピーする小さいFAT16パーティション
- NetBSDシステムをインストールするためのFFSパーティション
が必要。
U-Bootはext2からの起動もサポートしているが、NetBSDのnewfs_ext2fs(8)
で作成した
パーティションではうまく起動できなかったので、FAT16パーティションを作成した。
FDISK パーティションを情報を作成する。
# fdisk -u sd0
fdisk: primary partition table invalid, no magic in sector 0
fdisk: Cannot determine the number of heads
Disk: /dev/rsd0d
NetBSD disklabel disk geometry:
cylinders: 16383, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
total sectors: 62533296, bytes/sector: 512
BIOS disk geometry:
cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 62533296
Partitions aligned to 16065 sector boundaries, offset 63
Do you want to change our idea of what BIOS thinks? [n]
Partition table:
0: <UNUSED>
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Drive serial number: 0 (0x00000000)
第0パーティションにカーネル設置用FAT16パーティションを作成する。
Which partition do you want to change?: [none] 0
The data for partition 0 is:
<UNUSED>
sysid: [0..255 default: 169] 4
start: [0..3893cyl default: 63, 0cyl, 0MB]
size: [0..3893cyl default: 62533233, 3893cyl, 30534MB] 63504
bootmenu: []
Partition table:
0: Primary DOS with 16 bit FAT <32M (sysid 4)
start 63, size 63504 (31 MB, Cyls 0-3/243/63)
PBR is not bootable: All bytes are identical (0x00)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Drive serial number: 0 (0x00000000)
第1パーティションにシステム用NetBSDパーティションを作成する。
Which partition do you want to change?: [none] 1
The data for partition 1 is:
<UNUSED>
sysid: [0..255 default: 169]
start: [0..3893cyl default: 63567, 4cyl, 31MB]
size: [0..3889cyl default: 62469729, 3889cyl, 30503MB]
bootmenu: []
Partition table:
0: Primary DOS with 16 bit FAT <32M (sysid 4)
start 63, size 63504 (31 MB, Cyls 0-3/243/63)
PBR is not bootable: All bytes are identical (0x00)
1: NetBSD (sysid 169)
start 63567, size 62469729 (30503 MB, Cyls 3/244/1-3892/131/63)
PBR is not bootable: All bytes are identical (0x00)
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Drive serial number: 0 (0x00000000)
FDISK パーティション情報を保存する。
Which partition do you want to change?: [none] <<Enter>>
We haven't written the MBR back to disk yet. This is your last chance.
Partition table:
0: Primary DOS with 16 bit FAT <32M (sysid 4)
start 63, size 63504 (31 MB, Cyls 0-3/243/63)
PBR is not bootable: All bytes are identical (0x00)
1: NetBSD (sysid 169)
start 63567, size 62469729 (30503 MB, Cyls 3/244/1-3892/131/63)
PBR is not bootable: All bytes are identical (0x00)
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Drive serial number: 0 (0x00000000)
Should we write new partition table? [n] y
NetBSD disklabelを作成する。
注意: a-dパーティションはNetBSDが予約しているので、 FAT16パーティションのdisklabelは"e"以降に作成すること。
# disklabel -i sd0
Enter '?' for help
partition> P
4 partitions:
# size offset fstype [fsize bsize cpg/sgs]
a: 61440000 63567 4.2BSD 0 0 0 # (Cyl. 63*- 61015*)
b: 1029728 61503568 swap # (Cyl. 61015*- 62036)
c: 62469729 63567 unused # (Cyl. 63*- 62036)
d: 62533296 0 unused 0 0 # (Cyl. 0 - 62036)
カーネル設置用パーティションを作成する。
partition>e
Filesystem type [unused]: MSDOS
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: 63s
Partition size ('$' for all remaining) [0c, 0s, 0M]: 63504s
e: 63504 63 MSDOS # (Cyl. 0*- 63*)
partition>P
5 partitions:
# size offset fstype [fsize bsize cpg/sgs]
a: 61440000 63567 4.2BSD 0 0 0 # (Cyl. 63*- 61015*)
b: 1029728 61503568 swap # (Cyl. 61015*- 62036)
c: 62469729 63567 unused # (Cyl. 63*- 62036)
d: 62533296 0 unused 0 0 # (Cyl. 0 - 62036)
e: 63504 63 MSDOS # (Cyl. 0*- 63*)
ディスクにパーティション情報を書き込む。
partition>W
Label disk [n]?y
Label written
partition>Q
細かい説明は/usr/src/BUILDING読んで!
ARM アーキテクチャーはカーネルの数が多すぎるので、 カーネルを指定してコンパイルしないと面倒なことになる。
# cd /usr/src
# ./build.sh -m evbarm -O /home/yamajun/tmp/obj kernel=OPENBLOCKS_A6
OS全体をビルドする。 ALL_KERNELS 変数を指定すると、不必要なカーネル(evbarm では特に多い!)をビルドしなくて済む。
# ./build.sh -V ALL_KERNELS=OPENBLOCKS_A6 -uUm evbarm -O /home/yamajun/tmp/obj release
カーネルのコピー
# mkdir /mnt/md
# newfs_msdos -F 16 /dev/rsd0e
# mount_msdos /dev/sd0e /mnt/md
# cp -i ~yamajun/tmp/obj/sys/arch/evbarm/compile/OPENBLOCKS_A6/netbsd.ub /mnt/md
# umount /mnt/md
NetBSDシステムのコピー
# newfs /dev/rsd0a
# mount /dev/sd0a /mnt/md
# pushd /mnt/md
# tar zxpvf ~yamajun/tmp/obj/releasedir/evbarm/binary/sets/base.tgz
# tar zxpvf ~yamajun/tmp/obj/releasedir/evbarm/binary/sets/etc.tgz
# tar zxpvf ~yamajun/tmp/obj/releasedir/evbarm/binary/sets/games.tgz
# tar zxpvf ~yamajun/tmp/obj/releasedir/evbarm/binary/sets/misc.tgz
# tar zxpvf ~yamajun/tmp/obj/releasedir/evbarm/binary/sets/modules.tgz
# tar zxpvf ~yamajun/tmp/obj/releasedir/evbarm/binary/sets/text.tgz
システムを動かすには必須ではないが、必要なら下記のパッケージを入れる。
# tar zxpvf ~yamajun/tmp/obj/releasedir/evbarm/binary/sets/comp.tgz
# tar zxpvf ~yamajun/tmp/obj/releasedir/evbarm/binary/sets/man.tgz
マウントするためのディレクトリーを作成する。/boot
は好みで別の名前に変えてもOK。
# mkdir boot kern proc
デバイスファイルを作成。
# pushd dev
# ./MAKEDEV all
# cd /mnt/md
# vi etc/fstab
/dev/wd0a / ffs rw 1 1
/dev/wd0b none swap sw 0 0
/dev/wd0e /boot msdos rw,noauto 0 0
kernfs /kern kernfs rw
procfs /proc procfs rw
ptyfs /dev/pts ptyfs rw
# vi etc/rc.conf
rc_configured=YES
hostname="openblocks"
ifconfig_mvgbe0="inet 192.168.24.15/24"
defaultroute="192.168.24.1"
#dhcpcd=YES
sshd=YES
mdnsd=YES
# vi etc/nsswitch.conf
#hosts: files dns
hosts: files dns mdnsd
# rm etc/localtime
# ln -s /usr/share/zoneinfo/Asia/Tokyo etc/localtime
Half-Slim SATA ドライブをインストールし、ディップスイッチ1をonにして、U-Bootの プロンプトで停止するように設定してから起動し、シリアルコンソールから接続する。 ディップスイッチ1がoffの場合には、OpenBlocks起動時にコンソールで
NAND:
が見えているあたりでEnterキーを連打してU-Bootプロンプトに入るようにする。
USB 0: host mode
Net: egiga0
Hit any key to stop autoboot: 0
openblocks>>
OpenBlocksとシリアル接続を行い、電源を投入します。
NetBSD上でUSBシリアル変換アダプターから接続する例
# cu -l /dev/ttyU0 -s 115200
カーネルが正しく起動できるか「だけ」を確認するためには、 TFTP経由でカーネルをロードします。
母艦側でTFTPサーバーを構築
# vi /etc/inetd.conf
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot
tftp dgram udp6 wait root /usr/libexec/tftpd tftpd -l -s /tftpboot
# mkdir /tftproot
# cp /path/to/netbsd.ub /tftproot
# /etc/rc.d/inetd reload
OpenBlocks側では、ネットワーク情報を設定してブートします。
openblocks>> setenv ipaddr 192.0.2.15
openblocks>> setenv tftpserver 192.0.2.57
openblocks>> tftpboot 2000000 netbsd.ub
Using egiga0 device
TFTP from server 192.0.2.57; our IP address is 192.0.2.15
Filename 'netbsd.ub'.
Load address: 0x900000
Loading: #################################################################
#############################T ####################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#########T ########################################################
#################################################################T
#################################################################
#################################################################
#################################################################
#######################################T ##########################
#################################################################
###################################################
done
Bytes transferred = 5248960 (5017c0 hex)
openblocks>> bootm
## Booting image at 02000000 ...
Image Name: NetBSD/openblocks_a6 6.99.40
Created: 2014-05-11 12:40:31 UTC
Image Type: ARM NetBSD Kernel Image (uncompressed)
Data Size: 5282752 Bytes = 5 MB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OK
OK
## Transferring control to NetBSD stage-2 loader (at address 00008000) ...
NetBSD/evbarm (openblocks_a6) booting ...
(以下起動が止まるところまで略)
OpenBlocksにSATAを取り付けてから、システムが起動するところまで行います。
(SATAドライブの初期化)
openblocks>> ide reset
Reset IDE:
Marvell Serial ATA Adapter
Integrated Sata device found
[0 0 0]: Enable DMA mode (5)
Device 0 @ 0 0:
Model: SATA SSD Firm: S5FAM030 Ser#: 839F0729141700000685
Type: Hard Disk
Supports 48-bit addressing
Capacity: 30533.8 MB = 29.8 GB (62533296 x 512)
(ファイルの確認)
openblocks>> fatls ide 0
5282816 netbsd.ub
1 file(s), 0 dir(s)
(カーネルのロード)
openblocks>> fatload ide 0 0x2000000 netbsd.ub
reading netbsd.ub
5282816 bytes read
(カーネルの起動)
openblocks>> bootm
## Booting image at 02000000 ...
Image Name: NetBSD/openblocks_a6 6.99.40
Created: 2014-05-11 12:40:31 UTC
Image Type: ARM NetBSD Kernel Image (uncompressed)
Data Size: 5282752 Bytes = 5 MB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OK
OK
## Transferring control to NetBSD stage-2 loader (at address 00008000) ...
NetBSD/evbarm (openblocks_a6) booting ...
(プロンプトで止まるまで以下略)
root device: wd0a<<Enter>>
dump device (default wd0b):
file system (default generic):
root on wd0a dumps on wd0b
mountroot: trying nfs...
mountroot: trying msdos...
mountroot: trying ext2fs...
mountroot: trying ffs...
root file system type: ffs
init path (default /sbin/init): <<Enter>>
init: copying out path `/sbin/init' 11
/etc/rc.conf is not configured. Multiuser boot aborted.
Enter pathname of shell or RETURN for /bin/sh: <<Enter>>
WARNING: module error: vfs load failed for `compat', error 78
Terminal type is vt100.
We recommend that you create a non-root account and use su(1) for root access.
# exit
(シングルユーザーモードを抜けてマルチユーザーモードに突入)
NetBSD/evbarm (openblocks) (console)
login: root
(rootでログインしたらアカウント設定を行う)
openblocks# passwd
openblocks# useradd -m -g wheel -G operator yamajun
openblocks# passwd yamajun
(停止)
openblocks# shutdown -h now
...略...
unmounting done
The operating system has halted.
Please press any key to reboot.
起動を確認したら、wd0a をルートパーティションにしたり 使いたいデバイスのドライバーを組み込むためにカーネルを設定する。
# vi /usr/src/sys/arch/evbarm/conf/OPENBLOCKS_A6_YAMAJUN
include "arch/evbarm/conf/OPENBLOCKS_A6"
no config netbsd
config netbsd root on wd0a type ?
カーネル設定ファイルの全体はGistに置いた。
# cd /usr/src
# ./build.sh -uUm evbarm -O /home/yamajun/tmp/obj kernel=OPENBLOCKS_A6_YAMAJUN
コンパイルしてできた
/home/yamajun/tmp/obj/sys/arch/evbarm/compile/OPENBLOCKS_A6_YAMAJUN/netbsd.ub
を /boot (/dev/wd0c)に置く。 ここまでやると、
openblocks>> ide reset
openblocks>> fatload ide 0 0x2000000 netbsd.ub
openblocks>> bootm
を入力するだけでマルチユーザーブートできるようになる。
OpenBlocks A6デフォルトのprintenv
の結果はこの通り。
ディップスイッチ1のon/offは内容に関係ない。
openblocks>> printenv
bootcmd=echo;echo Run Boot Selection Script;echo;run _phase_0
bootdelay=0
baudrate=115200
loads_echo=0
ipaddr=192.168.254.254
tftpserver=192.168.254.1
preboot=
netmask=255.255.255.0
run_diag=yes
ethaddr=00:0a:85:05:01:0c
mtdids=nand0=nand_mtd
console=ttyS0
MALLOC_len=1
disaMvPnp=no
ethmtu=1500
usb0Mode=host
nandEcc=1bit
netretry=no
loadaddr=0x02000000
autoload=no
root=/dev/ram
satadev=0:1
rootdelay=7
sata_fs=ext2
mtd_user=0x1dec000
mtdparts=nand_mtd:0x90000(uboot)ro,0x44000(env),0x20000(test)ro,0x400000(conf),0x1d20000(linux),0x1dec000(user)
os_load_boot=run _os_load;run _ramargs;run _addtty;run _show_bootargs; bootm ${_kernel_addr_r}
os_load_prog=setenv target os;run _load_prog
upd=bubt
clr_env=resetenv
allupd=bubt && run _tp_load_prog && run os_load_prog
update_linux=run _linux_usb_load;run _os_program
update_uboot=run _uboot_usb_load;run _uboot_program
update_tp=led 0;run _tp_usb_load;run _tp_program;led 7
run_tp=nand read.e ${_tp_addr_r} ${_tp_offset} 0x10000;go ${_tp_entry}
stdin=serial
stdout=serial
stderr=serial
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
mtd_linux=ttyS0
pcieTune=no
pcieTune1=no
ethact=egiga0
Environment size: 4450/65531 bytes
自動起動を行うbootcmd
変数のデフォルト値は以下の通り。
openblocks>> printenv bootcmd
bootcmd=echo;echo Run Boot Selection Script;echo;run _phase_0
bootcmd
変数を変更し、電源を入れるとSATA内のNetBSDが起動するように変更する。
openblocks>> setenv bootcmd 'ide reset; fatload ide 0 0x2000000 netbsd.ub; bootm'
openblocks>> saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand...
done
openblocks>> boot
このマシンでコンパイルすると熱暴走しやすいので、バイナリーパッケージをインストールする。
# vi /etc/pkg_install.conf
PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/earm/7.0/All/
# pkg_add lv rsync sudo zsh
udl(4)
ドライバーを使えるようにすると、DisplayLink系のUSBサブディスプレイを
モニターとして使用できるようになる。
(ただし、デバイスIDが src/sys/dev/usb/udl.c に登録されている必要がある)
カーネル設定ファイルに書き足す内容 (OPENBLOCKS_A6 にない USB デバイスドライバーはいっぱいあるので、必要なら書き足す必要がある。 ただし、6.4MByteを越えると起動しなくなるので注意すること)
options WSEMUL_VT100 # VT100 / VT220 emulation
options WSDISPLAY_COMPAT_USL # wsconscfg VT handling
# console scrolling support.
options WSDISPLAY_SCROLLSUPPORT
# USB Mice
ums* at uhidev? reportid ?
wsmouse* at ums? mux 0
# USB Keyboards
ukbd* at uhidev? reportid ?
wskbd* at ukbd? console ? mux 1
# USB LCDs and USB-VGA adaptors
udl* at uhub? port ? # DisplayLink DL-1x0/1x5
wsdisplay* at udl?
# wscons pseudo-devices
pseudo-device wsmux # mouse & keyboard multiplexor
pseudo-device wsfont
デバイスファイルを作成
openblocks# cd /dev
openblocks# mknod -m 600 wsdisplay0 c wsdisplay 256
openblocks# mknod -m 600 wsdisplay0cfg c wsdisplay 511
openblocks# wsconscfg -f /dev/wsdisplay0cfg 0
端末の設定
openblocks# vi /etc/ttys
(略)
# for udl(4) on wsdisplay0
#ttyE1 "/usr/libexec/getty Pc" wsvt25 off secure
ttyE1 "/usr/libexec/getty Pc" wsvt25 on secure
- NetBSDのドキュメント類
- NetBSD@LinkStationでPlan9portを動かす(その1) - Plan9日記
- PC以外で動くFreeBSD の30ページ以降
- U-BOOT ユーザーズマニュアル@メディアラボ / u-boot.jp のwiki から入手
- USL-5Pとudlとwsconsとttys - BSD小僧の日記
- USBディスプレイ LCD-8000Uをudl(4)で使う (X Window System編) - BSD小僧の日記
- OpenBlocks A6 各種ドキュメント - OpenBlocks
- Cookbook - OBDN - 開発者向け情報 | OpenBlocks
- OpenBlocks A6 リリース情報 - ソフトウェア - OBDN - 開発者向け情報 | OpenBlocks のOS 更新情報
- パフォーマンス向上でナニに使える? OpenBlocks Aファミリによるサーバ実力診断
- OpenBlocks A6 リリース情報 - ソフトウェア - OBDN - 開発者向け情報 | OpenBlocks すでにファームウェアアップデートがあるので、アップデートすること。
- OBDNマガジン: Debian 7 (wheezy)ベースのOpenBlocks Aファミリ用 β版ファームウェア公開 (4/26 A6版追記, 5/23 ファームウェア更新)