トップ «前の日記(2011年02月15日) 最新 次の日記(2011年03月12日)» 編集

Masa's blog

検索キーワード:

2011年03月05日 ARMedslack 13.1 on zaurus [長年日記]

_ ARMedslack 13.1 on zaurus

ARMedslackの存在を知ってから約1年経った。

当時はAngstromのカーネルしか利用する術がなかったので、ARMedslackのユーザーランドとの整合性が合わずに、導入を断念した経緯があった。

その後、Debian lenny armelの導入に成功し、それはそれで十分満足できる環境を手にいれ、さらにカーネルをセルフビルド出来るようにもなった。

Debianを使い続けるという選択肢も有った。既にスケジュール管理等の実用環境に成っていたから。でも、最新カーネルをビルド出来るということは、ARMedslackを動かせる可能性が有るという事。

期は熟した。ついにSlackware-13.1ARMポートであるARMedslackzaurus(SL-C760 Husky)に導入した。

ポイントのみメモしておく。

前提条件

  • kexecbootが内蔵フラッシュにインストールされている。
  • Angstromが内蔵フラッシュにインストールされ、kexecbootから起動できるように設定されている(緊急時用OSとして利用)。

このあたりのお話しは、以前のブログに紹介しているので、詳細はそちらで。

母艦(Slackware-12.2 intel)にて

SDHC(32GB)のパーティション分けを行う。

# fdisk -l /dev/mmcblk0
        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1               1          34      273073+   c  W95 FAT32 (LBA)
/dev/mmcblk0p2              35          68      273105   82  Linux swap
/dev/mmcblk0p3              69        3927    30997417+  83  Linux
# mkdosfs /dev/mmcblk0p1
# mkswap /dev/mmcblk0p2
# mke2fs -j /dev/mmcblk0p3

先頭のFAT領域は必須ではない。ただなんとなく便利な場面もあるかと想像してのこと。

また、試してはいないが、最新のkexecbootであれば、rootパーティションを ext4で構築できるかもしれない。

ARMedslack-13.1を取得し、/dev/mmcblk0p3へ展開する。

# mount -t ext3 -o rw,noatime /dev/mmcblk0p3 /mnt/card
# cd (ARMedslack-13.1取得ディレクトリ)/slackware
# installpkg -root /mnt/card */*tgz

ARMedslack-13.1に含まれるカーネルはzaurusを対象とした物ではないので利用できない。なので、Debian lenny on SL-C760でビルドしたカーネルとモジュールをSDHC上に追加で展開する。

# cd /mnt/card
# tar xvzpif zImage-modules-2.6.36.3.tar.gz
# cd boot
# ln zImage-2.6.36.3 zImage

ちなみに、元々のARMedslack-13.1のカーネルは Ver. 2.6.33.5。当初 Ver. 2.6.33.7をセルフビルドしたもので動かそうとしたが、サスペンドからの復帰動作に若干難があったので、Ver. 2.6.36.3にバージョンアップした。

boot/boot.cfgを編集する。

# Show this label in kexecboot menu.
##LABEL=angstrom
LABEL=ARMedslack 13.1
#
# Specify full path to the kernel.
KERNEL=/boot/zImage
#
# Append this tags to the kernel cmdline.
APPEND=console=ttyS0,115200n8 console=tty1 noinitrd psplash=false debug
#
# Specify full path for a custom distro-icon for the menu-item.
# If not set, use device-icons as default (NAND, SD, CF, ...).
#ICON=/boot/icon.xpm
#
# Priority of item in kexecboot menu.
# Items with highest priority will be shown at top of menu.
# Default: 0 (lowest, ordered by device ordering)
#PRIORITY=10
#

etc/fstabを編集する。

/dev/mmcblk0p2  swap    swap    defaults                0       0
/dev/mmcblk0p3  /       ext3    rw,noatime,data=writeback       1       1
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0
tmpfs            /dev/shm         tmpfs       defaults         0   0

/dev/hda1       /media/cf       auto    rw,noatime,noauto       0       0
# SD/MMC in kernel 2.4
#/dev/mmcda1    /media/card     auto    rw,noatime,noauto       0       0
# SD/MMC in kernel 2.6
/dev/mmcblk0p1  /media/card     auto    rw,noatime,noauto       0       0

暫定的にAngstromのキーマップファイルをコピーする。そうしないと後々困ることになる。

# cp keymap-2.6.map /mnt/card/
# cp keymap-2.6.map /mnt/card/root/

etc/shadowのrootのパスワード欄に、母艦の/etc/shadowのrootのパスワード欄をコピペする。これも、そうしないと後々困ることに...。

SL-C760にて(1)

上記の設定を行ったSDHCをSL-C760に挿して電源を入れる。

kexecbootが起動したら、メニューにARMedslackを展開したパーティションが表示されるので、カーソルキーで選択し、エンターキーで起動する。

この時点のブートでは、母艦のSlackware(12.2)とARMedslack(13.1)の(fdiskの)バージョン違いによる影響か、

『ルートパーティションがおかしいので、rootのパスワードを入力してshを起動し、fsckをかけやがれ!』

との旨のメッセージが表示され、起動が途中で止まってしまう。

事前に母艦のrootパスワードを/etc/shadowに設定していたのは、パスワードが空白(エンターキーのみの入力)だと、shが起動できないため。

さて、rootのパスワードを入力してshを起動させても、今度はキーマップが部分的にSL-C760と合ってなくてfsckがかけれない(「/」が入力できない)ので、あらかじめコピーしておいたAngstromのキーマップをロードする。

# loadkeys keymap-2.6.map

その後、fsckをかける。

# e2fsck -f -y -v /dev/mmcblk0p3

で、リブート。

SL-C760にて(2)

今度は無事ログインできたので、粛々と設定作業を進めて行く。

タイムゾーンを設定する。

# cd /etc
# ln -s /usr/share/zoneinfo/Asia/Tokyo localtime

ホストネーム(/etc/HOSTNAME)を設定する。

# cat /etc/HOSTNAME
c7x0.hoge.org

参照するDNSサーバを設定する。

# cat /etc/resolv.conf
search foo.org
nameserver 192.168.0.100

ネットワーク関係の設定をする。

# cat /etc/rc.d/rc.inet1.conf

# Config information for eth0:
IPADDR[0]="192.168.0.76"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""

# Default gateway IP address:
GATEWAY="192.168.0.100"

IFNAME[4]="wlan0"
IPADDR[4]="192.168.0.76"
NETMASK[4]="255.255.255.0"
WLAN_ESSID[4]=MY_ESSID
WLAN_MODE[4]=Managed
WLAN_KEY[4]="WEPキー(16進)"

いまだにWEPなのは御愛嬌。

モジュール関係の設定をする。

サウンド関係と、無線LAN関係のモジュールが自動でロードされなかったのでスクリプトからロード。本来は、dbusとかhalあたりの設定を見直すべき(?)。

# cat /etc/rc.d/rc.modules
# sound support:
/sbin/modprobe snd_soc_corgi
# wireless card support:
/sbin/modprobe hostap_cs

SDHCのアクセスチューニングを行う。

# cat /etc/rc.d/rc.local
if [ -x /bin/echo ]
then
        echo 8192 >/sys/block/mmcblk0/queue/nr_requests
        echo deadline >/sys/block/mmcblk0/queue/scheduler
        echo 128 >/sys/block/mmcblk0/queue/iosched/fifo_batch
        echo 8 >/sys/block/mmcblk0/queue/iosched/writes_starved
        echo "setting mmcblk0."
fi

LED発行の設定をする。

# cat /etc/rc.d/rc.local
if [ -x /bin/echo ]
then
##      /bin/echo none >/sys/class/leds/corgi\:green\:mail/trigger
        /bin/echo mmc0 >/sys/class/leds/corgi\:green\:mail/trigger
        echo setting led.
fi

キーマップのカスタマイズを行う。

showkeyコマンドで各キーのキーコードを調べることができる。それを元にしてカスタマイズを行う。

# zcat /usr/share/kbd/keymaps/zaurus/zaurus-c760.map.gz
# Default kernel keymap. This uses 7 modifier combinations.
keymaps 0-2,4-5,8,12
# Change the above line into
#       keymaps 0-2,4-6,8,12
# in case you want the entries
#       altgr   control keycode  83 = Boot
#       altgr   control keycode 111 = Boot
# below.
#
keycode   1 =
keycode   2 = one              exclam
        control alt     keycode  2 = Console_1
        altgr keycode 2 = F1
keycode   3 = two              quotedbl
        control alt     keycode  3 = Console_2
        altgr keycode 3 = F2
keycode   4 = three            numbersign
        control alt     keycode  4 = Console_3
        altgr keycode 4 = F3
keycode   5 = four             dollar
        control alt     keycode  5 = Console_4
        altgr keycode 5 = F4
keycode   6 = five             percent
        control alt     keycode  6 = Console_5
        altgr keycode 6 = F5
keycode   7 = six              ampersand
        control alt     keycode  7 = Console_6
        altgr keycode 7 = F6
keycode   8 = seven            apostrophe
        altgr keycode 8 = F7
keycode   9 = eight            parenleft
        altgr keycode 9 = F8
keycode  10 = nine             parenright
        altgr keycode 10 = F9
keycode  11 = zero             asciitilde
        altgr keycode 11 = F10
keycode  12 = minus            grave
        altgr keycode 12 = at
keycode  14 = BackSpace
        altgr keycode 14 = Delete
keycode  15 = Tab
        altgr keycode 15 = Caps_Lock
keycode  16 = q
keycode  17 = w
        altgr keycode 17 = asciicircum
keycode  18 = e
        altgr keycode 18 = equal
keycode  19 = r
        altgr keycode 19 = plus
keycode  20 = t
        altgr keycode 20 = bracketleft
keycode  21 = y
        altgr keycode 21 = bracketright
keycode  22 = u
        altgr keycode 22 = braceleft
keycode  23 = i
        altgr keycode 23 = braceright
keycode  24 = o
keycode  25 = p
keycode  28 = Return          grave
keycode  29 = Control
keycode  30 = a
keycode  31 = s
keycode  32 = d
keycode  33 = f
        altgr keycode 33 = backslash
keycode  34 = g
        altgr keycode 34 = semicolon
keycode  35 = h
        altgr keycode 35 = colon
keycode  36 = j
        altgr keycode 36 = asterisk
keycode  37 = k
    altgr keycode 37 = backslash
keycode  38 = l
        altgr keycode 38 = bar
keycode  42 = Shift
keycode  44 = z
keycode  45 = x
keycode  46 = c
keycode  47 = v
keycode  48 = b
        altgr keycode 48 = underscore
keycode  49 = n
keycode  50 = m
keycode  51 = comma             slash
        altgr keycode 51 = less
keycode  52 = period           question
        altgr     keycode  52 = greater
keycode  54 = Shift
keycode  56 = Alt
keycode  57 = space            space
        control keycode  57 = nul
keycode 59 = Control
keycode 60 = Alt
keycode 61 = AltGr
keycode 62 = Escape
keycode 63 = Return
keycode 64 = Escape
keycode 65 = Down
keycode 66 = Up
keycode 68 = F14
keycode 87 = Return
keycode 88 = F12
keycode 99 = F13
keycode 103 = Up
        altgr     keycode 103 = PageUp
keycode 105 = Left
        altgr     keycode 105 = Decr_Console
keycode 106 = Right
        altgr     keycode 106 = Incr_Console
keycode 108 = Down
        altgr     keycode 108 = PageDown
keycode 205 = F11
string F1 = "\033[[A"
string F2 = "\033[[B"
string F3 = "\033[[C"
string F4 = "\033[[D"
string F5 = "\033[[E"
string F6 = "\033[17~"
string F7 = "\033[18~"
string F8 = "\033[19~"
string F9 = "\033[20~"
string F10 = "\033[21~"
string F11 = "\033[23~"
string F12 = "\033[24~"
string F13 = "\033[25~"
string F14 = "\033[26~"
string F15 = "\033[28~"
string F16 = "\033[29~"
string F17 = "\033[31~"
string F18 = "\033[32~"
string F19 = "\033[33~"
string F20 = "\033[34~"
string Find = "\033[1~"
string Insert = "\033[2~"
string Remove = "\033[3~"
string Select = "\033[4~"
string Prior = "\033[5~"
string Next = "\033[6~"
string Macro = "\033[M"
string Pause = "\033[P"
compose 文字化けするので以下省略

カスタマイズしたキーマップファイルを起動時にロードするように設定。

# cat /etc/rc.d/rc.local
if [ -x /usr/bin/loadkeys ]
then
        /usr/bin/loadkeys /usr/share/kbd/keymaps/zaurus/zaurus-c760.map.gz
        echo setting loadkeys.
fi
  • [Shift]+[-] = [`]
  • [Fn]+[1-9,0] = F1〜F10
  • [On/Off] = F11
  • [Menu] = F12
  • [Home] = F13
  • [Mail] = F14
  • [Address] = Alt
  • [Calendar] = Control

バックライトの調整。

#
# 0 <= brightness <= ${dir}/max_brightness
#
dir=/sys/devices/platform/pxa2xx-spi.1/spi1.1/backlight/corgi_bl
echo ${brightness} >${dir}/brightness

サスペンドの方法。

 echo mem >/sys/power/state

サスペンドからの復帰はキーボード上の、任意のキーを押せば行われる

X.Org X Server 1.7.7 (fbdev)

デフォルトのデスクトップ環境はKDEに設定されているが、当然SL-C760には重すぎるのでtwmに変更しておく。

# cd /usr/lib/X11/xinit
# rm xinitrc
# ln -s xinitrc.twm xinitrc

特に設定無しに(xorg.conf無し)、startxでXが起動する。ただし、キーマップは合っていない状態。

ぼちぼちと設定していく。

/etc/X11/xorg.confを設定する(xorg.conf-versatileをベースに)。

###################################################################
# File...: /etc/X11/xorg.conf-c760
# Purpose: Xorg config file for zaurus(sl-c760)
# Author : Masahiko Ito <m-ito@myh.no-ip.org>
# Date...: 27-Feb-2011
####################################################################

Section "ServerLayout"
    Identifier  "Simple Layout"
    Screen "Screen 1"
#    InputDevice "Mouse0" "CorePointer"
    InputDevice "touchscreen" "CorePointer"
    InputDevice "Keyboard1" "CoreKeyboard"
    # If HAL causes trouble, it can be disabled like this:
    #Option    "AutoAddDevices"  "off"
    # Allow the keyboard & mouse to work:
    # (I thought previously this was related to HAL being on or off
    # but unless this is set in Xorg 7.5, the mouse does not work)
    Option  "AllowEmptyInput" "off"
EndSection

Section "Files"
        ModulePath   "/usr/lib/xorg/modules"
        ModulePath   "/usr/local/lib/xorg/modules"
#        FontPath     "/usr/X11R6/lib/X11/fonts/local"
        FontPath     "/usr/X11R6/lib/X11/fonts/TTF"
        FontPath     "/usr/X11R6/lib/X11/fonts/OTF"
        FontPath     "/usr/X11R6/lib/X11/fonts/Type1"
        FontPath     "/usr/X11R6/lib/X11/fonts/misc"
#        FontPath     "/usr/X11R6/lib/X11/fonts/CID"
        FontPath     "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
        FontPath     "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
        FontPath     "/usr/X11R6/lib/X11/fonts/75dpi"
        FontPath     "/usr/X11R6/lib/X11/fonts/100dpi"
        FontPath     "/usr/X11R6/lib/X11/fonts/cyrillic"
EndSection

Section "Module"
    Load        "dbe"  	# Double buffer extension
    SubSection  "extmod"
    Option    "omit xfree86-dga"   # don't initialise the DGA extension
    EndSubSection
    Load       "freetype"
    Load       "glx"
    Load       "dri"
EndSection

Section "InputDevice"
    Identifier	"Keyboard1"
##    Driver	"kbd"
    Driver	"evdev"
  # Option     "AutoRepeat" "500 30"
    Option     "XkbRules"      "xorg"
    Option     "XkbModel"      "pc105"
  # UK keyboard mapping:
    Option     "XkbLayout"     "gb"
  # US keyboard mapping:
  # Option     "XkbLayout"     "us"
EndSection

Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        Option      "Protocol" "auto"
        Option      "Device" "/dev/mouse"
        Option      "ZAxisMapping" "4 5 6 7"
EndSection

Section "InputDevice"
	Identifier "touchscreen"
	Driver "tslib"
	Option "Device" "/dev/input/event1"
	Option "DeviceName" "tslib"
EndSection

Section "Monitor"
        UseModes "Forced Monitor Modes"
        Identifier   "Monitor0"
EndSection

# Make X check our modes first rather than deciding for itself:
Section "Modes"
        Identifier "Forced Monitor Modes"
        # 800x600 @ 56Hz (VESA) hsync: 35.2kHz
        ModeLine "800x600"    36.0  800  824  896 1024    600  601  603  625 +hsync +vsync
        # 1024x768 @ 70Hz (VESA) hsync: 56.5kHz
        ModeLine "1024x768"   75.0 1024 1048 1184 1328    768  771  777  806 -hsync -vsync
        # 1280x1024 @ 75Hz (VESA) hsync: 80.0kHz
        ModeLine "1280x1024" 135.0 1280 1296 1440 1688   1024 1025 1028 1066 +hsync +vsync
EndSection

Section "Device"
    Identifier  "VESA Framebuffer"
    Driver      "fbdev"
#    Option	"Rotate" "CCW"
EndSection

Section "Screen"
    Identifier  "Screen 1"
    Device      "VESA Framebuffer"
    Monitor     "Monitor0"

    DefaultDepth 16
    SubSection "Display"
        Depth           16
        Modes           "640x480"
    EndSubSection
EndSection

Section "DRI"
    Mode 0666
EndSection
  • Section "ServerLayout" の InputDevice "touchscreen" "CorePointer" → タッチスクリーンを利用する際の設定。
  • Section "Files" に ModulePath "/usr/local/lib/xorg/modules" を追加 → tslib関連モジュールをインストールする場所。
  • Section "Files" から FontPath "/usr/X11R6/lib/X11/fonts/local"、FontPath "/usr/X11R6/lib/X11/fonts/CID" をコメントアウト → 最初、rxvtでk12等のごく当り前の漢字フォントが表示できなくて困った。どうやら存在しないディレクトリを指定していると、フォントのロードに失敗するみたい。
  • Section "InputDevice" の Identifier "Keyboard1" の Driver "kbd" を Driver "evdev" に変更 → キーのオートリピートを止める機能が "kbd" では利用できなかった。(何故か)マウスカーソルのブルブルが劇的に治まる(これはかなり嬉しい副作用)。
  • Section "InputDevice" の Identifier "touchscreen" の Driver "tslib" 等 → タッチスクリーン関連ドライバの指定。他にも選択肢として "evtouch", "evdev" が有るが、"evtouch"は画面が暗転して表示されなかった。"evdev"はこれから主流になっていくと思われるのだが、キャリブレーションの設定が良く分からず今回は見送った。

タッチスクリーンドライバとしてtslibを利用する為のもろもろをインストールする。

...のだが、tslibのビルドにautomake-1.6が要求されるので、あえて古いautomakeをインストールする。

# tar xvzf automake-1.6.3.tar.gz
# cd automake-1.6.3
# ./configure --prefix=/usr/local/automake-1.6
# make
# make install

次にtslib-1.0をインストール。ソースはDebianから拝借

# tar xvzf tslib_1.0.orig.tar.gz
# cd tslib-1.0
# zcat tslib_1.0-7.diff.gz | patch -p1
# cat debian/patches/*patch | patch -p1
# PATH="/usr/local/automake-1.6/bin:${PATH}" ./autogen.sh
# ./configure
# make
# make install

キャリブレーションを行う(コンソールから)。

# TSLIB_TSDEVICE=/dev/input/event1 ts_calibrate

/etc/pointercal に結果が書き込まれる。設定ファイルは /usr/local/etc/ts.conf。特に編集する必要は無し。

xf86-input-tslib-0.0.6をインストール。ソースはDebianから拝借

# tar xvzf xf86-input-tslib_0.0.6.orig.tar.gz
# cd xf86-input-tslib-0.0.6
# tar xvzf xf86-input-tslib_0.0.6-5.debian.tar.gz
# cat debian/patches/95_update-manpage.diff | patch -p1
# cat debian/patches/0001-fix-segfault.patch | patch -p1
# ./configure
# make
# make install

xevでキーコードを確認し、.Xmodmapを作成する。

本当は、コンソールでの設定をそのまま引き継いでくれれば楽なのだが、xorg-1.7から XkbDisableの設定が廃止になったとの事である。かと言って、zaurus用の"XkbModel"や"XkbLayout"定義が用意されている分けではないので、全てのキーをxmodmapで再定義してやる。

# xmodmap -pke >.Xmodmap

でベースを作成し、それをカスタマイズする。

# cat .Xmodmap
keycode   8 =
keycode   9 =
keycode  10 = 1 exclam F1
keycode  11 = 2 quotedbl F2
keycode  12 = 3 numbersign F3
keycode  13 = 4 dollar F4
keycode  14 = 5 percent F5
keycode  15 = 6 ampersand F6
keycode  16 = 7 apostrophe F7
keycode  17 = 8 parenleft F8
keycode  18 = 9 parenright F9
keycode  19 = 0 asciitilde F10
keycode  20 = minus grave at
keycode  21 =
keycode  22 = BackSpace NoSymbol Delete
keycode  23 = Tab
keycode  24 = q Q
keycode  25 = w W asciicircum
keycode  26 = e E equal
keycode  27 = r R plus
keycode  28 = t T bracketleft
keycode  29 = y Y bracketright
keycode  30 = u U braceleft
keycode  31 = i I braceright
keycode  32 = o O
keycode  33 = p P
keycode  34 =
keycode  35 =
keycode  36 = Return
keycode  37 = Control_L
keycode  38 = a A
keycode  39 = s S
keycode  40 = d D
keycode  41 = f F backslash
keycode  42 = g G semicolon
keycode  43 = h H colon
keycode  44 = j J asterisk
keycode  45 = k K backslash
keycode  46 = l L bar
keycode  47 =
keycode  48 =
keycode  49 =
keycode  50 = Shift_L
keycode  51 =
keycode  52 = z Z
keycode  53 = x X
keycode  54 = c C
keycode  55 = v V
keycode  56 = b B underscore
keycode  57 = n N
keycode  58 = m M
keycode  59 = comma slash less
keycode  60 = period question greater
keycode  61 =
keycode  62 = Shift_R
keycode  63 =
keycode  64 = Kanji
keycode  65 = space
keycode  66 =
keycode  67 = Control_L
keycode  68 = Alt_L
keycode  69 = Mode_switch
keycode  70 = Escape
keycode  71 = Return
keycode  72 = Escape
keycode  73 = Down
keycode  74 = Up
keycode  75 =
keycode  76 = F14
keycode  77 =
keycode  78 =
keycode  79 =
keycode  80 =
keycode  81 =
keycode  82 =
keycode  83 =
keycode  84 =
keycode  85 =
keycode  86 =
keycode  87 =
keycode  88 =
keycode  89 =
keycode  90 =
keycode  91 =
keycode  92 =
keycode  93 =
keycode  94 =
keycode  95 = Return
keycode  96 = F12
keycode  97 =
keycode  98 =
keycode  99 =
keycode 100 =
keycode 101 =
keycode 102 =
keycode 103 =
keycode 104 =
keycode 105 =
keycode 106 =
keycode 107 = F13
keycode 108 =
keycode 109 =
keycode 110 =
keycode 111 = Up NoSymbol Prior
keycode 112 =
keycode 113 = Left
keycode 114 = Right
keycode 115 =
keycode 116 = Down NoSymbol Next
keycode 117 =
keycode 118 =
keycode 119 =
keycode 120 =
keycode 121 =
keycode 122 =
keycode 123 =
keycode 124 =
keycode 125 =
keycode 126 =
keycode 127 =
keycode 128 =
keycode 129 =
keycode 130 =
keycode 131 =
keycode 132 =
keycode 133 =
keycode 134 =
keycode 135 =
keycode 136 =
keycode 137 =
keycode 138 =
keycode 139 =
keycode 140 =
keycode 141 =
keycode 142 =
keycode 143 =
keycode 144 =
keycode 145 =
keycode 146 =
keycode 147 =
keycode 148 =
keycode 149 =
keycode 150 =
keycode 151 =
keycode 152 =
keycode 153 =
keycode 154 =
keycode 155 =
keycode 156 =
keycode 157 =
keycode 158 =
keycode 159 =
keycode 160 =
keycode 161 =
keycode 162 =
keycode 163 =
keycode 164 =
keycode 165 =
keycode 166 =
keycode 167 =
keycode 168 =
keycode 169 =
keycode 170 =
keycode 171 =
keycode 172 =
keycode 173 =
keycode 174 =
keycode 175 =
keycode 176 =
keycode 177 =
keycode 178 =
keycode 179 =
keycode 180 =
keycode 181 =
keycode 182 =
keycode 183 =
keycode 184 =
keycode 185 =
keycode 186 =
keycode 187 =
keycode 188 =
keycode 189 =
keycode 190 =
keycode 191 =
keycode 192 =
keycode 193 =
keycode 194 =
keycode 195 =
keycode 196 =
keycode 197 =
keycode 198 =
keycode 199 =
keycode 200 =
keycode 201 =
keycode 202 =
keycode 203 =
keycode 204 =
keycode 205 =
keycode 206 =
keycode 207 =
keycode 208 =
keycode 209 =
keycode 210 =
keycode 211 =
keycode 212 =
keycode 213 = F11
keycode 214 =
keycode 215 =
keycode 216 =
keycode 217 =
keycode 218 =
keycode 219 =
keycode 220 =
keycode 221 =
keycode 222 =
keycode 223 =
keycode 224 =
keycode 225 =
keycode 226 =
keycode 227 =
keycode 228 =
keycode 229 =
keycode 230 =
keycode 231 =
keycode 232 =
keycode 233 =
keycode 234 =
keycode 235 =
keycode 236 =
keycode 237 =
keycode 238 =
keycode 239 =
keycode 240 =
keycode 241 =
keycode 242 =
keycode 243 =
keycode 244 =
keycode 245 =
keycode 246 =
keycode 247 =
keycode 248 =
keycode 249 =
keycode 250 =
keycode 251 =
keycode 252 =
keycode 253 =
keycode 254 =
clear Shift
add Shift = Shift_L Shift_R
clear Lock
clear Control
add Control = Control_L
clear Mod1
add Mod1 = Alt_L
clear Mod2
add Mod2 = Mode_switch
clear Mod3
clear Mod4
clear Mod5

[Fn],[Calendar],[Address],[Mail],[Home],[Menu]キーはモディファイヤキーとして使うことを考慮してオートリピートを止めたい。

# xset -r

だと全てのキーのオートリピートが停止するのでまずい。なので、次のコマンドを作った。

/*
 * setxkbrepeat by Masahiko Ito <m-ito@myh.no-ip.org>
 *
 * 2011.03.01 Ver. 0.1 First release
 * 2011.03.18 Ver. 0.2 Some update (Special Thanks to nn)
 *
 * Build    : cc -o setxkbrepeat setxkbrepeat.c -L/usr/X11R6/lib -lX11
 * Function : set key repeat on/off
 * Usage    : setxkbrepeat keycode [on|off]
 */
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>

main(argc, argv)
	int	argc;
	char	*argv[];
{
	Display* display;
	XKeyboardControl values;

	if ((display = XOpenDisplay (NULL)) == (Display *)NULL){
		fprintf(stderr, "%s: unable to open display\n", argv[0]);
		exit(1);
	}

	if ((argc != 3) ||
	    (atoi(argv[1]) < 8 || atoi(argv[1]) > 254) ||
	    (strncmp(argv[2], "on", 2) != 0 && strncmp(argv[2], "off", 3) != 0)){
		fprintf(stderr, "Usage : setxkbrepeat keycode [on|off]\n");
		fprintf(stderr, "  keycode must be 8 to 254.\n");
		exit(1);
	}

	values.key = atoi(argv[1]);
	if (strncmp(argv[2], "on", 2) == 0){
		values.auto_repeat_mode = AutoRepeatModeOn;
	}else if (strncmp(argv[2], "off", 3) == 0){
		values.auto_repeat_mode = AutoRepeatModeOff;
	}
	XChangeKeyboardControl(
		display,
		(KBKey | KBAutoRepeatMode),
		&values
	);

	XCloseDisplay (display);
}

このコマンドを .xinitrc から、

setxkbrepeat 69 off     # Fn
setxkbrepeat 67 off     # Calendar
setxkbrepeat 68 off     # Address
setxkbrepeat 76 off     # Mail
setxkbrepeat 107 off    # Home
setxkbrepeat 96 off     # Menu

と実行する。...と効くはずだったのだが、Xの実装に依存した問題なのか、なぜか効かない(xset -rも)。仕方がないので、この部分だけ別スクリプトにしておいて、ログイン後に手動で実行している。

fvwm-1.24との連係。

# cat .fvwmrc
Key Left        A       M       CursorMove -1 0
Key Right       A       M       CursorMove  1 0
Key Up          A       M       CursorMove  0 -1
Key Down        A       M       CursorMove  0 1
Key Left        A       MC      CursorMove -5 0
Key Right       A       MC      CursorMove  5 0
Key Up          A       MC      CursorMove   0 -5
Key Down        A       MC      CursorMove   0 5
Key F14         A       N       Exec "click1" exec /usr/local/bin/key2mouse 1
Key F14         A       C       Exec "click2" exec /usr/local/bin/key2mouse 2
Key F14         A       M       Exec "click3" exec /usr/local/bin/key2mouse 3
Key F13         A       N       Exec "suspend" exec sudo /home/m-ito/bin/zzz.sh
Key F11         A       N       Exec "suspend" exec sudo /home/m-ito/bin/zzz.sh
Key F12         A       N       PopUp "Utilities"
Key 3           A       C       Exec "lcdoff"     exec sudo /home/m-ito/bin/loff.sh
Key 4           A       C       Exec "lcdon"      exec sudo /home/m-ito/bin/lon.sh
Key 3           A       M       Exec "brightdown" exec sudo /home/m-ito/bin/bd.sh
Key 4           A       M       Exec "brightup"   exec sudo /home/m-ito/bin/bu.sh
  • [ALT]+[←] : マウスカーソルを左へ1ドット移動
  • [ALT]+[→] : マウスカーソルを右へ1ドット移動
  • [ALT]+[↑] : マウスカーソルを上へ1ドット移動
  • [ALT]+[↓] : マウスカーソルを下へ1ドット移動
  • [Ctrl]+[ALT]+[←] : マウスカーソルを左へ5ドット移動
  • [Ctrl]+[ALT]+[→] : マウスカーソルを右へ5ドット移動
  • [Ctrl]+[ALT]+[↑] : マウスカーソルを上へ5ドット移動
  • [Ctrl]+[ALT]+[↓] : マウスカーソルを下へ5ドット移動
  • [Mail] : 左クリック
  • [Ctrl]+[Mail] : 中クリック
  • [ALT]+[Mail] : 右クリック
  • [On/Off] : サスペンド
  • [Home] : サスペンド
  • [Menu] : fvwmメニュー表示
  • [Ctrl]+[3] : LCD off
  • [Ctrl]+[4] : LCD on
  • [ALT]+[3] : LCD 輝度UP
  • [ALT]+[4] : LCD 輝度DOWN

一部のスクリプトをsudoで実行しているので、そのスクリプトに関してはNOPASSWDで実行できるように/etc/sudoersを設定しておく事。

key2mouse.c(マウスボタンイベント発生プログラム)

/*
 * 2004.06.10 create Masahiko Ito (Special Thanks to nn)
 *
 * Build : cc -o key2mouse key2mouse.c -lXtst -lX11
 *
 * Usage : key2mouse [1|2|3]
 *
 */
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>

int
main(argc, argv)
int argc;
char** argv;
{
    Display* display;
    int screen;
    Window root;

    if (argc < 2 ||
        strncmp(argv[1], "-h", strlen("-h")) == 0 ||
        strncmp(argv[1], "--help", strlen("--help")) == 0){
        printf("Usage : %-s [1|2|3]\n\n", argv[0]);
        exit(0);
    }

    display = XOpenDisplay (NULL);
    screen = DefaultScreen (display);
    root = DefaultRootWindow(display);
    if (strncmp(argv[1], "1", 1) == 0){
        XTestFakeButtonEvent (display, Button1, True, 0);
        XTestFakeButtonEvent (display, Button1, False, 0);
    }else if (strncmp(argv[1], "2", 1) == 0){
        XTestFakeButtonEvent (display, Button2, True, 0);
        XTestFakeButtonEvent (display, Button2, False, 0);
    }else if (strncmp(argv[1], "3", 1) == 0){
        XTestFakeButtonEvent (display, Button3, True, 0);
        XTestFakeButtonEvent (display, Button3, False, 0);
    }
    XCloseDisplay (display);

}

zzz.sh(サスペンド実行スクリプト)

#! /bin/sh
echo mem >/sys/power/state

loff.sh(LCD消灯スクリプト)

#! /bin/sh
dir=/sys/devices/platform/pxa2xx-spi.1/spi1.1/backlight/corgi_bl
#dir=/sys/class/backlight/corgi-bl
min_brightness=0
brightness=${min_brightness}
#
echo ${brightness} >${dir}/brightness

lon.sh(LCD点灯スクリプト)

#! /bin/sh
dir=/sys/devices/platform/pxa2xx-spi.1/spi1.1/backlight/corgi_bl
#dir=/sys/class/backlight/corgi-bl
max_brightness=`cat ${dir}/max_brightness`
brightness=${max_brightness}
#
echo ${brightness} >${dir}/brightness

bd.sh(LCD輝度ダウンスクリプト)

#! /bin/sh
dir=/sys/devices/platform/pxa2xx-spi.1/spi1.1/backlight/corgi_bl
#dir=/sys/class/backlight/corgi-bl
diff=5
min_brightness=1
##max_brightness=`cat ${dir}/max_brightness`
brightness=`cat ${dir}/brightness`
#
brightness=`expr ${brightness} - ${diff}`
if [ ${brightness} -lt ${min_brightness} ]
then
	brightness=${min_brightness}
fi
#
echo ${brightness} >${dir}/brightness

bu.sh(LCD輝度アップスクリプト)

#! /bin/sh
dir=/sys/devices/platform/pxa2xx-spi.1/spi1.1/backlight/corgi_bl
#dir=/sys/class/backlight/corgi-bl
diff=5
min_brightness=1
##max_brightness=`cat ${dir}/max_brightness`
brightness=`cat ${dir}/brightness`
#
brightness=`expr ${brightness} - ${diff}`
if [ ${brightness} -lt ${min_brightness} ]
then
	brightness=${min_brightness}
fi
#
echo ${brightness} >${dir}/brightness

top

topコマンドでメモリーの消費順で表示したもの。

top - 02:02:51 up  7:50,  4 users,  load average: 0.08, 0.13, 0.17
Tasks:  80 total,   1 running,  79 sleeping,   0 stopped,   0 zombie
Cpu(s): 26.5%us, 17.7%sy,  0.0%ni, 55.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:     61704k total,    48704k used,    13000k free,      656k buffers
Swap:   273100k total,    16744k used,   256356k free,    13676k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  929 m-ito     20   0 31404  10m 2896 S  0.0 16.8   1:20.96 emacs
  873 root      20   0 22652 6108 1240 S  0.3  9.9   4:12.42 X
  835 bin       20   0  6852 3928  572 S  0.0  6.4   0:03.00 cannaserver
  884 m-ito     20   0  6952 1868 1060 S  0.0  3.0   0:53.34 urxvt
  883 m-ito     20   0  6036 1716 1152 S  0.0  2.8   0:22.95 kinput2
  915 m-ito     20   0  4692 1652 1060 S  0.0  2.7   0:00.71 bash
  961 m-ito     20   0  4684 1632 1080 S  0.0  2.6   0:00.73 bash
  914 m-ito     20   0  4320 1260  796 S  0.0  2.0   0:28.42 screen
  930 m-ito     20   0  4684 1244  904 S  0.0  2.0   0:00.79 bash
 7477 m-ito     20   0  2720 1180  944 R  2.9  1.9   0:01.98 top

常用している emacs と Xが群を抜いてでかい。

emacsに関しては不要な機能は外してビルドし直すか、懐かしの nemacs に入れ換えるかすればまだ小さくできる。

X に関しても kdriveをビルドできれば良いのだが...(今回はAngstromからXimageonのバイナリを拝借するのは避けたい)。

そして...

後は、Slackwareの精神に則り、必要なものはソースからどんどんビルドして放り込めばよいかと...。

ともかく、これで念願のDebian lenny armelからSlackware arm(ARMedslack)への鞍替えが完了した。

非常に満足している。