メッセージ欄

2013年1月の日記

一覧で表示する

USL-5Pとudlとwsconsとttys
2013/01/05(土) 16:38 NetBSD はてブ情報 はてブに登録 はてブ数

せっかくインストールしたUSL-5Pもシリアルやssh経由だけで使うのも何とも味気ないものですから、豊富なUSBポートを活用してディスプレイとキーボードをつないでみましょう。

ディスプレイはCentury LCD-8000U, キーボードはELECOM TK-UP84CPWHです。

もちろんX Window Systemを動かすのが見た目のインパクトも大きいのですが、kernelにもXにもパッチが必要で割と手間がかかります。ということで、まずはコンソールだけでもやってみようと思ったのであります。

2012年3月にもコンソールに挑戦して敗北していることもあって、いっちょう今回は逃げずに頑張ってみましょうと。

結論から言うと動きました。

pg92onUSL5P.jpg

landiskに関してはkernelに
options         WSEMUL_VT100            # VT100 / VT220 emulation
を定義して作り直す必要がありました。これをつけないと
wsconscfg: WSDISPLAYIO_ADDSCREEN: Device not configured
というエラーメッセージが出てしまいます。実は、これはwscons.confの
screen  1       -       vt100
に書かれているvt100をみて、wsconsが「vt100のエミュレーションないなー、デバイスコンフィグできませんなー」ということのようですね。

wsconscfgコマンドを使うとわかるのですが、
usl5p# wsconscfg -e dumb 1
usl5p# wsconscfg -e vt100 1
てな具合で、知っている端末エミュレーションだとエラーを出さずに成功し、
usl5p# wsconscfg -e sun 1
wsconscfg: WSDISPLAYIO_ADDSCREEN: Device not configured
てな具合で、知らない端末エミュレーションだと上のようなエラーを出すようです。知らない端末だと教えてくれるといいんですけど、wsdisplay.c#364あたりからすると、return ENXIO つまりDevice not configuredを返しているので、そこまでハンドリングできないようです。

そしてなぜか、screen 2, screen 3を作ろうとすると、メモリをアロケートできませんというエラーが出ます。
options        WSDISPLAY_DEFAULTSCREENS=4
をカーネルのコンフィグに足してみましたが、状況変わらず。これについてはちょっとあきらめることにしました。

先のwscons.confで作ったscreenに対応するttyがttysに書かれた/dev/ttyE1になるようですね。
ttyE1   "/usr/libexec/getty Pc"         vt220   on secure
よくわかっていないのですが、console = screen 0 = ttyE0と考えておけばよいのかなぁ。そいでもって、screen 1 = ttyE1で有効にしてやれば動くと。

/etc/ttyactionにもこういうの書いてあるし。ttyE0とconsoleは深い関係にありそうですなー。この辺の整合性が取れていないとconsoleでもrootでログインできなくなっちゃったりするんでしょうね。
ttyE0   *       chown ${USER}:tty /dev/console
と思ったらNetBSD/landiskにはなかったな。うーん。

さて、wsconsですが、黒字に白文字というのはいかにもパッとしません。
きっと色ぐらいは変えられるだろうと思い、wsconsctlなどといういかにもなコマンドを発見し、おー、オプションに-aを渡せば設定項目が全部表示されるんだねー。と思い。
usl5p# wsconsctl -a
type=usb
bell.pitch=1500
bell.period=100
bell.volume=50
bell.pitch.default=1500
bell.period.default=100
bell.volume.default=50
wsconsctl: "map" not shown with -a; use "wsconsctl map" to view.
repeat.del1=400
repeat.deln=100
repeat.del1.default=400
repeat.deln.default=100
ledstate=0
encoding=us
keyclick=0
scroll.mode=0
scroll.modifier=1
あれぇ? 色に関する項目がないですねぇ。
どうやら、オプションに-dを与えないとディスプレイ関連の設定値は出てこないんですね。
usl5p# wsconsctl -f /dev/ttyE1 -d -a
type=unknown_49
scroll.fastlines=25
scroll.slowlines=2
msg.default.attrs=color
msg.default.bg=black
msg.default.fg=white
msg.kernel.attrs=color
msg.kernel.bg=black
msg.kernel.fg=white
これで設定がわかりました。白背景に黒文字にしたければ次のようにします。
usl5p# wsconsctl -f /dev/ttyE1 -d -w msg.default.bg=white
msg.default.bg -> white
usl5p# wsconsctl -f /dev/ttyE1 -d -w msg.default.fg=black
msg.default.fg -> black
この設定をwscons.confのsetvarで書いてやればいいみたいですね。

起動時に試してみたら、確かに文字の所は設定が反映されて白背景に黒文字ですけれど、それ以外のスペースの部分は黒いままだったりして... まぁ、ログインしてCtrl-lで全面描画されるので良いんですけど。そもそもの背景色を設定する方法がほかにあるのかもしれません。

設定をまとめておきましょう。

カーネル (実際に必要なのは最後の一行だけですけど)
n601# diff -u GENERIC USL-5P.nfs
--- GENERIC     2013-01-05 18:03:35.000000000 +0000
+++ USL-5P.nfs  2013-01-05 18:06:35.000000000 +0000
@@ -175,8 +175,8 @@

 # Kernel root file system and dump configuration.
 #config                netbsd  root on ? type ?
-config         netbsd  root on wd0a type ffs
-#config                netbsd  root on ? type nfs
+#config                netbsd  root on wd0a type ffs
+config         netbsd  root on ? type nfs


 #
@@ -224,8 +224,8 @@
 # The 0x0001 flag force the driver to use DMA, even if the driver doesn't know
 # how to set up DMA modes for this chip. This may work, or may cause
 # a machine hang with some controllers.
-pciide*        at pci? dev ? function ? flags 0x0000   # GENERIC pciide driver
-acardide*      at pci? dev ? function ?        # Acard IDE controllers
+#pciide*       at pci? dev ? function ? flags 0x0000   # GENERIC pciide driver
+#acardide*     at pci? dev ? function ?        # Acard IDE controllers

 wdc0   at obio? port 0x14000000 irq 10         # CF
 #wdc1  at obio? port 0x18000000 irq 9          # iConnect
@@ -477,3 +477,14 @@
 # wscons pseudo-devices
 pseudo-device  wsmux                   # mouse & keyboard multiplexor
 #pseudo-device wsfont
+
+options        WSDISPLAY_CUSTOM_OUTPUT # color customization from wsconsctl(8)
+options        WSDISPLAY_CUSTOM_BORDER # custom border colors via wsconsctl(8)
+#options       WSDISPLAY_BORDER_COLOR=WSCOL_BLUE       # default color
+options        WSDISPLAY_COMPAT_PCVT           # emulate some ioctls
+options        WSDISPLAY_COMPAT_SYSCONS        # emulate some ioctls
+options        WSDISPLAY_COMPAT_USL            # wsconscfg VT handling
+options        WSDISPLAY_COMPAT_RAWKBD         # can get raw scancodes
+#options       WSDISPLAY_DEFAULTSCREENS=4
+options        WSDISPLAY_SCROLLSUPPORT
+options        WSEMUL_VT100            # VT100 / VT220 emulation
/etc/rc.conf
wscons=YES
/etc/ttys
console "/usr/libexec/getty std.9600"   vt220   on secure
constty "/usr/libexec/getty std.9600"   vt220   off secure
ttyE0   "/usr/libexec/getty Pc"         vt220   off secure
ttyE1   "/usr/libexec/getty Pc"         vt220   on secure
ttyE2   "/usr/libexec/getty Pc"         vt220   off secure
ttyE3   "/usr/libexec/getty Pc"         vt220   off secure
tty00   "/usr/libexec/getty std.9600"   unknown off secure
tty01   "/usr/libexec/getty std.9600"   unknown off secure
tty02   "/usr/libexec/getty std.9600"   unknown off secure
tty03   "/usr/libexec/getty std.9600"   unknown off secure
tty04   "/usr/libexec/getty std.9600"   unknown off secure
tty05   "/usr/libexec/getty std.9600"   unknown off secure
tty06   "/usr/libexec/getty std.9600"   unknown off secure
tty07   "/usr/libexec/getty std.9600"   unknown off secure

/etc/wscons.conf (screensの部分とsetvarの部分を抜粋)
#screen 0       -       vt100
screen  1       -       vt100
#screen 2       -       vt100
#screen 3       -       vt100
#screen 4       -       -

setvar ttyE1    msg.default.bg  white
setvar ttyE1    msg.default.fg  black

USL-5PにNetBSD/landiskをインストール (NetBSD 6.0.1)
2013/01/02(水) 17:39 NetBSD はてブ情報 はてブに登録 はてブ数

NetBSD/landiskをUSL-5Pで久しぶりに動かしました。
前回が2006年9月ですから、6年3か月ぶりですか。

あまりに久しぶりなのでメモしておきます。

なにはなくともシリアルコンソールを取らねばなりません。

そしてそのためにはプラスねじを一本外し、カバーを外す必要があります。
カバーは固く、少しの勇気をもってLANポート側からフロントのスイッチ側にカバーをスライドさせます。

シリアルポートはボード上のボタン電池の近所にある四つの穴ですね。
三角形のマーク(▲)が1番ポートです。
ピン番号内容
1番3.3V
2番TxD
3番RxD
4番GND
スルーホールなのでピンヘッダをはんだ付けする方法もありますが、LANTANK用のシリアルケーブルやサンハヤトのTTW-200のようなコンタクトピンになっているケーブルを使うと抜き差しが便利です。TTW-200だと少し太いかなぁ。今度買ってみよう。
今回はLANTANK用のシリアルケーブルを使いました。ただし、このケーブルだとTxD, RxDのピン配置が逆なので、一度ぜんぶピンごと抜いてさしなおす必要があります。

オリジナルのピン配置を書いておきます。グレーとイエローを入れ替えるんですね。
ピン番号内容
1番3.3Vオレンジ
2番RxDグレー
3番TxDイエロー
4番GNDホワイト
5番なし
ケーブルの準備ができたらテストしてみましょう。スピードは9600bpsです。

前回はどういうわけかUSL-5Pですべての作業をしていたみたいですが、作業効率も考えるとIntelマシンのパワーを使うのが何かと楽ちんです。今回はVMware Player上のNetBSD 6.0.1をThinkPadに接続したコンパクトフラッシュリーダライタを経由してコンパクトフラッシュにNetBSDをインストールしました。

以前のインストールメモです

使用したCFはSanDiskの256MB CFです。容量的にはkernel, base, etc, modulesを展開しておわりですね。compを入れたらあふれました...

準備として、VMwareに母艦のCFを見せる設定をVMware側に行っておきましょう。

NetBSD/landiskのリリース物を入手し、VMware側で展開しておきます。

最初は、CFのパーティションをつぶします。ddでゼロを書き込みます。
nb601# dd if=/dev/zero of=/dev/rsd0d bs=1k count=10
10+0 records in
10+0 records out
10240 bytes transferred in 0.125 secs (81920 bytes/sec)
次にMBRを書き込みます。先ほど展開しておいたNetBSD/landiskのmbrを書き込みます。landiskはi386ばりにMBRを解釈してくれて、MBR->ブートローダ->カーネルをFFSからブートします。MS-DOSパーティションやLinux ext3パーティションなどは不要です。
nb601# dd if=./usr/mdec/mbr of=/dev/rsd0d bs=512 count=1
1+0 records in
1+0 records out
512 bytes transferred in 0.019 secs (26947 bytes/sec)
fdiskでパーティションを切ります。パーティション0に対してシリンダの32番目から全体をNetBSD区画にしてしまいます。
nb601# fdisk -0 -u sd0
fdisk: Cannot determine the number of heads
Disk: /dev/rsd0d
NetBSD disklabel disk geometry:
cylinders: 245, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 501760

BIOS disk geometry:
cylinders: 245, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 501760

Partitions aligned to 2048 sector boundaries, offset 32

Do you want to change our idea of what BIOS thinks? [n]

Partition 0:
<UNUSED>
The data for partition 0 is:
<UNUSED>
sysid: [0..255 default: 169]
start: [0..245cyl default: 32, 0cyl, 0MB]
size: [0..245cyl default: 501728, 245cyl, 245MB]
bootmenu: [] NetBSD

Installed bootfile doesn't support required options.
Update the bootcode from /usr/mdec/mbr_bootsel? [n]

We haven't written the MBR back to disk yet.  This is your last chance.
Partition table:
0: NetBSD (sysid 169)
    bootmenu: NetBSD
    start 32, size 501728 (245 MB, Cyls 0-244)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Should we write new partition table? [n] y
アクティブ領域を設定します。当然ですがパーティション0をアクティブにします。
nb601# fdisk -a sd0
Disk: /dev/rsd0d
NetBSD disklabel disk geometry:
cylinders: 245, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 501760

BIOS disk geometry:
cylinders: 245, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 501760

Partitions aligned to 2048 sector boundaries, offset 32

Partition table:
0: NetBSD (sysid 169)
    bootmenu: NetBSD
    start 32, size 501728 (245 MB, Cyls 0-244)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
No active partition.
Do you want to change the active partition? [n] y
Choosing 4 will make no partition active.
active partition: [0..4 default: 4] 0
Are you happy with this choice? [n] y

We haven't written the MBR back to disk yet.  This is your last chance.
Should we write new partition table? [n] y
disklabelを書きます。お好みです。swapをどうしようかと思ったのですが、FFS上のファイルをスワップにしてもいいですし、いざとなったらNFS上にスワップを作っちゃえばいいや、ということで少しでも容量を稼ぎます。
nb601# disklabel sd0
# /dev/rsd0d:
type: SCSI
disk: MCR   HS-CF
label: fictitious
flags: removable
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 245
total sectors: 501760
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0

4 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:    501728        32     4.2BSD      0     0     0  # (Cyl.      0*-    244)
 c:    501728        32     unused      0     0        # (Cyl.      0*-    244)
 d:    501760         0     unused      0     0        # (Cyl.      0 -    244)
nb601# disklabel -i -I sd0
Enter '?' for help
partition> a
Filesystem type [?] [4.2BSD]:
Start offset ('x' to start after partition 'x') [0.015625c, 32s, 0.015625M]:
Partition size ('$' for all remaining) [244.984375c, 501728s, 244.984375M]:
partition> P
4 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:    501728        32     4.2BSD      0     0     0  # (Cyl.      0*-    244)
 d:    501760         0     unused      0     0        # (Cyl.      0 -    244)
partition> c
Filesystem type [?] [unused]:
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: 32
Partition size ('$' for all remaining) [0c, 0s, 0M]: $
 c:    501728        32     unused      0     0        # (Cyl.      0*-    244)
partition> P
4 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:    501728        32     4.2BSD      0     0     0  # (Cyl.      0*-    244)
 c:    501728        32     unused      0     0        # (Cyl.      0*-    244)
 d:    501760         0     unused      0     0        # (Cyl.      0 -    244)
partition> W
Label disk [n]? y
Label written
partition> Q
NetBSDパーティションをnewfsでフォーマットします。
(なぜか手順が残ってなかったなー)
nb601# newfs /dev/rsd0a
作成したsd0aにinstallbootでプライマリブートローダをぶち込みます。
nb601# installboot -m landisk -v /dev/rsd0a ./usr/mdec/bootxx_ffsv1
File system:         /dev/rsd0a
Primary bootstrap:   ./usr/mdec/bootxx_ffsv1
次にセカンダリブートローダです。こちらはファイルのコピーですからまずはsd0aをマウントします。
nb601# mount /dev/sd0a /mnt
セカンダリブートローダをコピーします。ちゃんとlandisk用のbootをつかいましょう。母艦のbootをコピーしないように。
nb601# cp ./usr/mdec/boot /mnt
次は配布物をインストールしていきます。
手元の環境ではGENERICカーネルも展開済みだったのでコピーしました。
ほんとうならpax -rzpe -f kern-GENERIC.tgzあたりですかね。
nb601# cp netbsd /mnt
base, etc, modulesを展開していきます。6系からmodulesを入れないといけませんねぇ。これを忘れると/sbin/initが起動しないんだったかな。
nb601# pax -rzpe -f /root/601/landisk/base.tgz; pax -rzpe -f /root/601/landisk/etc.tgz ; pax -rzpe -f /root/601/landisk/modules.tgz
MAKEDEVでデバイスを作っておきます。
nb601# cd dev
nb601# ./MAKEDEV all
/etc/fstabを書いておきます。起動するだけならtouch /etc/fstabでもいいかも。
nb601# cd ../etc
nb601# echo /dev/wd0a / ffs rw 1 1 > fstab
ここらへんまで来たらもう起動してもいいんですが、マルチユーザにしたければ/etc/rc.confにrc_configured=YESを書いてあげないといけません。
次の例ではラインエディタであるedを使っています。
nb601# ed rc.conf
515
/NO
# Use program=YES to enable program, NO to disable it. program_flags are
/
rc_configured=NO
s/NO/YES
rc_configured=YES
w
516
q
インストールは終わりです。
マウントポイントから離れて、アンマウントします。
nb601# cd /
nb601# umount /mnt
いざ、起動です。
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.

2002/09/09 Making.  2004/09/08 I-O DATA NSU Update.
266:133:33 on base clock 22.22MHz and SDRAM 4 burst. CF boot.

PCIC initialization done.
MASTER:48bit LBA mode non support
Disk drive detected: SanDisk SDCFB-256 HDX 3.19     111702D2206F0252
LBA: 0007A800
DiskSize: 256901120Byte
PIO MODE1
Set Transfer Mode result: 50
> b
Set Transfer Mode result: 50
Initialize Device Parameters result: 50
IDLE result: 50

NetBSD MBR boot

NetBSD/landisk ffsv1 Primary Bootstrap

>> NetBSD/landisk Boot, Revision 1.0
Press return to boot now, any other key for boot menu
booting hd0a:netbsd - starting in 0
3409060+135044 [268048+257712]=0x3e202c
Start @ 0x8c001000 [1=0x8c362428-0x8c3e302c]...
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 6.0.1 (GENERIC)
Model: I-O DATA LANDISK
total memory = 65536 KB
avail memory = 58416 KB
mainbus0 (root)
cpu0 at mainbus0: SH4 266.666 MHz PCLOCK 33.333 MHz
cpu0: 8KB/32B direct-mapped Instruction cache.
cpu0: 16KB/32B direct-mapped Data cache.
cpu0: U0, P0, P3 write-through; P1 write-through
cpu0: full-associative 4 ITLB, 64 UTLB entries
cpu0: multiple virtual storage mode, SQ access: kernel, wired 3
shpcic0 at mainbus0: Hitachi SH7751R PCI Controller (host bridge, revision 0x01)
pci0 at shpcic0
re0 at pci0 dev 0 function 0: RealTek 8139C+ 10/100BaseTX (rev. 0x20)
re0: interrupting at irq 5
re0: Ethernet address XX:XX:XX:XX:XX:XX
rlphy0 at re0 phy 0: Realtek internal PHY
rlphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
ohci0 at pci0 dev 2 function 0: NEC USB Host Controller (rev. 0x43)
ohci0: interrupting at irq 7
ohci0: OHCI version 1.0
usb0 at ohci0: USB revision 1.0
ohci1 at pci0 dev 2 function 1: NEC USB Host Controller (rev. 0x43)
ohci1: interrupting at irq 8
ohci1: OHCI version 1.0
usb1 at ohci1: USB revision 1.0
ehci0 at pci0 dev 2 function 2: NEC USB Host Controller (rev. 0x04)
ehci0: interrupting at irq 5
ehci0: companion controllers, 3 ports each: ohci0 ohci1
usb2 at ehci0: USB revision 2.0
shb0 at mainbus0
scif0 at shb0
scif0: console
rs5c313rtc0 at shb0: RICOH 5C313 real time clock
obio0 at mainbus0
wdc0 at obio0 port 0x14000000-0x1400000f irq 10
atabus0 at wdc0 channel 0
btn0 at obio0 irq 12: USL-5P buttons
pwrsw0 at obio0 irq 11: Power Switch
uhub0 at usb0: NEC OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1 at usb1: NEC OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub2 at usb2: NEC EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
wd0 at atabus0 drive 0
wd0: <SanDisk SDCFB-256>
wd0: 245 MB, 980 cyl, 16 head, 32 sec, 512 bytes/sect x 501760 sectors
boot device: wd0
root on wd0a dumps on wd0b
Wed Jan  2 19:38:48 UTC 2013
Starting root file system check:
/dev/rwd0a: file system is clean; not checking
Starting file system checks:
Setting tty flags.
Setting sysctl variables:
ddb.onpanic: 1 -> 0
Starting network.
/etc/rc: WARNING: $hostname not set.
IPv6 mode: host
Configuring network interfaces:.
Adding interface aliases:.
Building databases: dev, dev, utmp, utmpx, services.
Starting syslogd.
Mounting all filesystems...
Clearing temporary files.
Checking quotas: done.
Setting securelevel: kern.securelevel: 0 -> 1
/etc/rc: WARNING: No swap space configured!
/etc/rc.d/swap2 exited with code 1
Starting virecover.
Checking for core dump...
savecore: /dev/rwd0b: Device not configured
Jan  2 19:39:03  savecore: /dev/rwd0b: Device not configured
Starting local daemons:.
Updating motd.
postfix: rebuilding /etc/mail/aliases (missing /etc/mail/aliases.db)
newaliases: warning: valid_hostname: empty hostname
newaliases: fatal: unable to use my own hostname
Jan  2 19:39:06  postfix/sendmail[313]: fatal: unable to use my own hostname
/etc/rc.d/postfix exited with code 1
Starting inetd.
Starting cron.
The following components reported failures:
    /etc/rc.d/swap2 /etc/rc.d/postfix
See /var/run/rc.log for more information.
Wed Jan  2 19:39:07 UTC 2013

NetBSD/landisk (Amnesiac) (console)

login: root
Jan  2 19:39:13  login: ROOT LOGIN (root) on tty console
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 6.0.1 (GENERIC)

Welcome to NetBSD!

Terminal type? [unknown] xterm
Terminal type is xterm.
We recommend that you create a non-root account and use su(1) for root access.
# uname -a
NetBSD  6.0.1 NetBSD 6.0.1 (GENERIC) landisk
#
ここまでくれば、あとはボチボチと設定していけばいいでしょう。