先日イーモバイルのデータカード、D21LCを購入したのですが、 UbuntuでD21LCの使用例がWeb上では見つからず、利用出来るようになるまでに随分と苦労しました。
そこで今回は、Linuxでモデムに認識されないUSBモデムの設定方法と、UbuntuでD21LCを利用する方法を書いていきます。 同じようにすれば、他のUSBモデムの設定の参考になるかと思います。
単純にD21LCが繋がるようになればよいという方は、「usb_modeswitchのインストール」からお読み下さい。
問題になった部分を先に書いておきます
今回の環境です。
今回の環境を例に、ストレージと認識されたUSBモデムを、モデムとして認識出来るようにしていきます。
1は3のステップに必要で、USBモデムとして動作しているベンダーIDとプロダクトIDを調べる為に必要です。 XPで同様の事が出来るかどうかは、環境がない為不明です。
2と3は4の設定ファイルを書く為に必要な値になります。
USB機器には通常、ベンダーIDとプロダクトIDが振られているのですが、
D21LCの場合は、ストレージとしてのIDと、モデムとしてのID両方が存在します。この値が両方必要です。
4はusbで接続された機器の認識を変更する、Linuxのソフトウェアです。設定ファイルに沿って、USBのモードを変更してくれます。
Ubuntu上でターミナルを使った作業です。
まず接続されているUSB機器の一覧を出します
lsusb
(今回の例での結果)
Bus 001 Device 004: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader Bus 001 Device 003: ID 0a5c:2110 Broadcom Corp. Bluetooth Controller Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 007 Device 002: ID 1c9e:9401 Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
USBモデムの行を見つけます。 分からなければ、USBモデムを抜き差しして、増えた行がUSBモデムです。
USBモデムの詳細を確認します。詳細を見るには以下のようなコマンドを打ちます。
lsusb -v -s [Bus]:[Device]
今回の場合は以下のようにします。
sudo lsusb -v -s 007:002
(今回の例での結果)
Bus 007 Device 002: ID 1c9e:9401
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1c9e
idProduct 0x9401
bcdDevice 0.00
iManufacturer 2 USB Modem
iProduct 1 USB Modem
iSerial 3 358061021009527
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk (Zip)
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
(Bus Powered)
ここで出てきた、ベンダーIDとプロダクトIDをメモします。 これでUSBモデムがUSBストレージとして認識されている時の情報を取得出来ました。
今回の場合はベンダーIDが「0x1c9e」、プロダクトIDが「0x9401」です。
ここはWindows Vistaで作業します。
先ずはVista上でUSBモデムが使える状態にしておきます
デバイスマネージャーから、USBモデムを選びプロパティを開きます。 分からなければ、USBモデムを抜き差しして、確認して下さい。
「詳細」タブから「ハードウェアID」を選び、表示されているVIDとPIDをメモします。 これがUSBモデムがモデムとして認識されている状態のIDです。
「VID_[値]&PID_[値]」となっているので、この値をメモします。
今回の場合はベンダーIDが「1c9e」、プロダクトIDが「9404」です。設定に書き込むのはそれぞれ「0x1c9e」「0x9404」になります。
ここから先は全てUbuntu上での作業になります。
基本的にターミナルからの作業です。
USBの認識状態を変更してくれる、usb_modeswitchをインストールします。
usb_modeswitchが依存しているlibusb-devを入れておく (ディストリビューションによっては、libusb-develかも知れません)
apt-get install libusb-dev
Draisberghof - Software - USB_ModeSwitchより最新バージョンを確認します
ファイルのダウンロード(今回は0.5をインストールします)
wget http://www.draisberghof.de/usb_modeswitch/usb_modeswitch-0.9.5.tar.bz2
展開します
bzcat usb_modeswitch-0.9.5.tar.bz2 | tar xvf -
ディレクトリの移動
cd usb_modeswitch-0.9.5
コンパイルします(gccが入ってなければ、入れておく必要があります)
gcc -l usb -o usb_modeswitch usb_modeswitch.c
プログラム本体をコピー(パスが通っている所ならどこでも良いと思います)
sudo cp usb_modeswitch /usr/local/sbin/
設定ファイルのコピー
sudo cp usb_modeswitch.conf /etc
これでusb_modeswitchがインストール出来ました。
ここまで調べた情報を使い、Ubuntuにインストールしたusb_modeswitchを設定していきます。
現在のUSBを確認
lsusb
(今回の例での結果)
Bus 001 Device 004: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader Bus 001 Device 003: ID 0a5c:2110 Broadcom Corp. Bluetooth Controller Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 007 Device 002: ID 1c9e:9401 Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
以降のステップで、9401となっている箇所を9404になるように設定していきます。
設定ファイルの編集
sudo vi /etc/usb_modeswitch.conf
(/etc/usb_modeswitch.conf) デフォルトの設定をコメントアウトします。
####################################################### # Option GlobeSurfer Icon (aka "Vodafone EasyBox") # # The message SHOULD be the same for all Option devices ;DefaultVendor= 0x05c6 ;DefaultProduct= 0x1000 ;TargetVendor= 0x0af0 ;TargetProduct= 0x6600 ;MessageEndpoint=0x05 ;MessageContent="55534243123456780000000000000601000000000000000000000000000000"
先ほど調べたベンダーIDとプロダクトIDを含めた設定を書き加えます。
####################################################### ## Emobile D21LC ## # DefaultVendor= 0x1c9e DefaultProduct= 0x9401 TargetVendor= 0x1c9e TargetProduct= 0x9404 MessageEndpoint=0x01 MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
DefaultにはUSBストレージの時のID、TargetにはVistaで取得したモデム状態の時のIDを指定します。
それぞれは、「0x」から始まるようにします。
MessageEndpointとMessageContentについてですが、詳細は分かっていないものの、他のemobileの設定を参考にしました。
保存してviを終了
以下のような形で、ドライバを指定します。
modprobe usbserial vendor=[USBモデム状態のベンダーID] product=[USBモデム状態のプロダクトID]
今回の例
sudo modprobe usbserial vendor=0x1c9e product=0x9404
usbmodeの切り替え
sudo usb_modeswitch
(今回の例での結果)
* usb_modeswitch: tool for controlling "flip flop" mode USB devices
* Version 0.9.5 (C) Josua Dietze 2008
* Works with libusb 0.1.12 and probably other versions
Looking for target devices
No target device found
Looking for default devices
Found default devices (1)
Prepare switching, accessing latest device
Looking for active default driver to detach it
OK, driver found ("usb-storage")
OK, Driver "usb-storage" successfully detached
Setting up communication with device
Trying to send the message
OK, message successfully sent.
-> See /proc/bus/usb/devices (or call lsusb) for changes. Bye
変更されたか確認する
lsusb
(今回の例での結果)
Bus 001 Device 004: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader Bus 001 Device 003: ID 0a5c:2110 Broadcom Corp. Bluetooth Controller Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 007 Device 003: ID 1c9e:9404 Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
プロダクトIDが9401から9404に変わっているので、無事にモデムとして認識出来ているようです。
詳細を確認する
sudo lsusb -v -s 007:003
(今回の例での結果)
Bus 007 Device 003: ID 1c9e:9404
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1c9e
idProduct 0x9404
bcdDevice 0.00
iManufacturer 2 USB Modem
iProduct 1 USB Modem
iSerial 3 358061021009527
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 108
bNumInterfaces 4
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk (Zip)
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 5
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
(Bus Powered)
中身はさっぱり分かりませんが、USBストレージとして認識されていた時と比べて、結果が変わっています。
USBモデムのデバイスを確認
ls /dev/ | grep ttyUSB
(今回の例での結果)
ttyUSB0 ttyUSB1 ttyUSB2 ttyUSB3
USBモデムのデバイスが確認出来ました。
今のままでは再起動時に認識されないので、次回起動以降も認識出来るようにします。
ここではrc.localに書いていますが、起動時にrootからフック出来るところに書けばよいかと思います。
sudo vi /etc/rc.local
「exit」の上辺りにドライバーの指定を追記します。
(今回の例での編集)
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. #emobile modprobe usbserial vendor=0x1c9e product=0x9404 #script end exit 0
USBモデムを指している状態で再起動
sudo reboot
再起動後に再度確認
lsusb
(今回の例での結果)
Bus 007 Device 002: ID 1c9e:9404 Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 004: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader Bus 001 Device 003: ID 0a5c:2110 Broadcom Corp. Bluetooth Controller Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
プロダクトIDが9404なので、無事にモデムとして認識出来ています。
起動時にはUSBモデムを指している必要があります
起動後にモデムを指したり、起動時にモデムとして認識されていない時は、再度usb_modeswitchを動かして下さい。
sudo usb_modeswitch
ここまでで、ようやくUSBモデムをストレージではなく、モデムとして認識させる事が出来ました。 参考リンクを張っておきます。
無事にUSBモデムとして認識してくれた所で、次はD21LCの接続設定を行っていきます。
今回はgnome-pppを利用します。
gnome-pppのインストール
下記のようにコマンドを打つか、synaptic等のGUIを使ってインストール
apt-get install gnome-ppp
接続先の設定
emem*99***1#*99***2#「Setup」をクリックして設定を開く
「Setup」>「Modem」タブ
/dev/ttyUSB2「Setup」>「Networking」タブ
デフォルトのままにします(DHCPを使って自動取得の状態)。
「Setup」>「Options」タブ
「Close」をクリックして設定を閉じる
「Connect」をクリックして接続
今回の場合は以下のようなログが出ます。
/var/log/messages
PPP generic driver version 2.4.2 pppd 2.4.4 started by username, uid 1000 Using interface ppp0 Connect: ppp0 <--> /dev/ttyUSB2 CHAP authentication succeeded CHAP authentication succeeded PPP BSD Compression module registered PPP Deflate Compression module registered type=1503 audit(1231858866.596:6): operation="inode_permission" requested_mask="w::" denied_mask="w::" fsuid=0 name="/dev/ttyUSB0" pid=7067 profile="/usr/sbin/cupsd" type=1503 audit(1231858866.596:7): operation="inode_permission" requested_mask="w::" denied_mask="w::" fsuid=0 name="/dev/ttyUSB1" pid=7067 profile="/usr/sbin/cupsd" type=1503 audit(1231858866.600:8): operation="inode_permission" requested_mask="w::" denied_mask="w::" fsuid=0 name="/dev/ttyUSB2" pid=7067 profile="/usr/sbin/cupsd" Could not determine remote IP address: defaulting to xxx.xxx.xxx.xxx local IP address xxx.xxx.xxx.xxx remote IP address xxx.xxx.xxx.xxx primary DNS address xxx.xxx.xxx.xxx secondary DNS address xxx.xxx.xxx.xxx
gnome-pppのログ
--> Ignoring malformed input line: ";Do NOT edit this file by hand!" --> WvDial: Internet dialer version 1.60 --> Cannot get information for serial port. --> Initializing modem. --> Sending: ATZ ATZ OK --> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 OK --> Modem initialized. --> Sending: ATM0L0DT*99***1# --> Waiting for carrier. ATM0L0DT*99***1# CONNECT --> Carrier detected. Starting PPP immediately. --> Starting pppd at --> Warning: Could not modify /etc/ppp/pap-secrets: Permission denied --> --> PAP (Password Authentication Protocol) may be flaky. --> Warning: Could not modify /etc/ppp/chap-secrets: Permission denied --> --> CHAP (Challenge Handshake) may be flaky. --> Pid of pppd: 7378 --> Using interface ppp0 --> local IP address xxx.xxx.xxx.xxx --> remote IP address xxx.xxx.xxx.xxx --> primary DNS address xxx.xxx.xxx.xxx --> secondary DNS address xxx.xxx.xxx.xxx
パーミッションのワーニングが出てますが、ルート権限で動かせば消えると思います。 今回はとりあえず接続出来ているので、省きます。
無事に接続出来れば成功です。お疲れ様でした。
設定は再起動後も保存されていると思いますので、次回以降はgnome-pppを立ち上げてConnectするだけで繋がると思います。
複数の設定を保存したい場合は「KPPP」の方が便利かも知れません
pppd 2.4.4 started by root, uid 0 Using interface ppp0 Connect: ppp0 <--> /dev/ttyUSB1 LCP: timeout sending Config-Requests Connection terminated. Modem hangup
Posted at 37to : commetns(0) : trackbacks(0)
本エントリへのトラックバックURL
http://blog.37to.net/mt/mt-tb.cgi/110