LoginSignup
15
14

More than 5 years have passed since last update.

NanoPi NEO を使って 3G ゲートウェイを作る

Last updated at Posted at 2016-08-15

概要

小型のシングルボードコンピュータ、NanoPi NEO が発売になりました。
256MB RAM のものは 7.99ドル(+送料)で手に入ります。Raspberry Pi Zero よりも若干高いものの複数個購入することが可能です。
また、Wi-Fi も Bluetooth も付いていませんが(技適の面では安心です)、Raspberry Pi Zero と違って Ethernet と USB-A のポートがあるので、3G USB ドングル AK-020 を使えるようにしてみました。

入手

以下から買えます。
NanoPi NEO

発送は迅速で、セールスの担当者も非常に親切です。NanoPi NEO が発売した当初は NanoPi NEO 用のヒートシンクが無かったので NanoPi M1 用のものを注文したら、これから NEO 用のものが発売されるとメールでフォローしてくれました。難点は、本体が安いので仕方の無いことですが、送料は割高感があります…
なお、このあたりの価格帯のシングルボードコンピュータが軒並み採用している Allwinner の SoC はどれも結構熱くなりますので、ヒートシンク等、放熱の準備をすることをお勧めします。

3G USB ドングルは以下を使っています。
3G USBドングル AK-020 SORACOMスターターキット

手順

セットアップ

オフィシャルのイメージが以下にありますので、ダウンロードして 4GB 以上の microSD に書き込んでおきます。
UbuntuCore with Qt-Embedded

なお、NanoPi NEO には HDMI のコネクタもありませんので、すべてリモートで作業します。
割当てられている IP アドレスを探して、今どき珍しく root でリモートから SSH でログインします。初期パスワードは fa です。(会社名の friendly arm からでしょうか。)

root@192.168.11.135's password: 
Welcome to Ubuntu 15.10 (GNU/Linux 3.4.39-h3 armv7l)

 * Documentation:  https://help.ubuntu.com/
root@FriendlyARM:~# uname -a      
Linux FriendlyARM 3.4.39-h3 #1 SMP PREEMPT Thu Aug 4 12:41:33 CST 2016 armv7l armv7l armv7l GNU/Linux

SD カードの容量を拡張したり、apt-get update, apt-get upgrade したりと一通りやることはあるでしょうが、ここでは割愛します。
なお、eject, wvdial だけは最低限、必要になりますのでインストールしておきます。

USBシリアルデバイスとして認識させる

AK-020 を NanoPi NEO に差して、lsusb をしてみます。

root@FriendlyARM:~# lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 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 002: ID 15eb:a403  
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

他の記事でも既出のとおり、VenderId/ProductId が 15eb/a403 であることを確認しました。

dmesg も見てみましょう。

root@FriendlyARM:~# dmesg
<snip>
[  611.524271] ehci_irq: highspeed device connect
[  611.540153] ehci_irq: highspeed device disconnect
[  618.910832] ehci_irq: highspeed device connect
[  619.180090] usb 4-1: new high-speed USB device number 2 using sunxi-ehci
[  619.335855] scsi0 : usb-storage 4-1:1.0
[  620.331582] scsi 0:0:0:0: CD-ROM            HSPA_USB SCSI CD-ROM       622 PQ: 0 ANSI: 0 CCS
[  620.334668] sr0: scsi3-mmc drive: 0x/0x caddy
[  620.334704] cdrom: Uniform CD-ROM driver Revision: 3.20
[  620.336110] sr 0:0:0:0: Attached scsi CD-ROM sr0
[  620.516685] sr 0:0:0:0: [sr0] Unhandled sense code
[  620.516709] sr 0:0:0:0: [sr0]  Result: hostbyte=0x07 driverbyte=0x08
[  620.516725] sr 0:0:0:0: [sr0]  Sense Key : 0x4 [current] 
[  620.516745] sr 0:0:0:0: [sr0]  ASC=0x0 ASCQ=0x0
[  620.516761] sr 0:0:0:0: [sr0] CDB: cdb[0]=0x28: 28 00 00 03 1f f8 00 00 08 00
[  620.516801] end_request: I/O error, dev sr0, sector 204792
[  620.522956] Buffer I/O error on device sr0, logical block 25599
[  620.591157] sr 0:0:0:0: [sr0] Unhandled sense code
[  620.591179] sr 0:0:0:0: [sr0]  Result: hostbyte=0x07 driverbyte=0x08
[  620.591195] sr 0:0:0:0: [sr0]  Sense Key : 0x4 [current] 
[  620.591214] sr 0:0:0:0: [sr0]  ASC=0x0 ASCQ=0x0
[  620.591230] sr 0:0:0:0: [sr0] CDB: cdb[0]=0x28: 28 00 00 03 1f f8 00 00 08 00
[  620.591269] end_request: I/O error, dev sr0, sector 204792
[  620.597370] Buffer I/O error on device sr0, logical block 25599
[  620.741152] sr 0:0:0:0: [sr0] Unhandled sense code
[  620.741172] sr 0:0:0:0: [sr0]  Result: hostbyte=0x07 driverbyte=0x08
[  620.741187] sr 0:0:0:0: [sr0]  Sense Key : 0x4 [current] 
[  620.741205] sr 0:0:0:0: [sr0]  ASC=0x0 ASCQ=0x0
[  620.741220] sr 0:0:0:0: [sr0] CDB: cdb[0]=0x28: 28 00 00 03 1f f8 00 00 08 00
[  620.741256] end_request: I/O error, dev sr0, sector 204792
[  620.747353] Buffer I/O error on device sr0, logical block 25599
[  620.816642] sr 0:0:0:0: [sr0] Unhandled sense code
[  620.816653] sr 0:0:0:0: [sr0]  Result: hostbyte=0x07 driverbyte=0x08
[  620.816666] sr 0:0:0:0: [sr0]  Sense Key : 0x4 [current] 
[  620.816681] sr 0:0:0:0: [sr0]  ASC=0x0 ASCQ=0x0
[  620.816695] sr 0:0:0:0: [sr0] CDB: cdb[0]=0x28: 28 00 00 03 1f f8 00 00 08 00
[  620.816728] end_request: I/O error, dev sr0, sector 204792
[  620.822832] Buffer I/O error on device sr0, logical block 25599

ということで、eject すると VenderId/ProductId が変わります。

root@FriendlyARM:~# eject /dev/sr0 
root@FriendlyARM:~# lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 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 003: ID 15eb:7d0e  
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

以下の内容をファイルに書き、実行権限を付けて実行します。

ak-020.sh
#!/bin/sh
modprobe -v option
echo '15eb 7d0e' > /sys/bus/usb-serial/drivers/option1/new_id
root@FriendlyARM:~# vi /home/fa/ak-020.sh
root@FriendlyARM:~# chmod 755 /home/fa/ak-020.sh 
root@FriendlyARM:~# /home/fa/ak-020.sh

無事、モデム が出現しました。

root@FriendlyARM:~# dmesg
<snip>
[  611.524271] ehci_irq: highspeed device connect
[  611.540153] ehci_irq: highspeed device disconnect
[  618.910832] ehci_irq: highspeed device connect
[  619.180090] usb 4-1: new high-speed USB device number 2 using sunxi-ehci
[  619.335855] scsi0 : usb-storage 4-1:1.0
[  620.331582] scsi 0:0:0:0: CD-ROM            HSPA_USB SCSI CD-ROM       622 PQ: 0 ANSI: 0 CCS
[  620.334668] sr0: scsi3-mmc drive: 0x/0x caddy
[  620.334704] cdrom: Uniform CD-ROM driver Revision: 3.20
[  620.336110] sr 0:0:0:0: Attached scsi CD-ROM sr0
[  620.516685] sr 0:0:0:0: [sr0] Unhandled sense code
[  620.516709] sr 0:0:0:0: [sr0]  Result: hostbyte=0x07 driverbyte=0x08
[  620.516725] sr 0:0:0:0: [sr0]  Sense Key : 0x4 [current] 
[  620.516745] sr 0:0:0:0: [sr0]  ASC=0x0 ASCQ=0x0
[  620.516761] sr 0:0:0:0: [sr0] CDB: cdb[0]=0x28: 28 00 00 03 1f f8 00 00 08 00
[  620.516801] end_request: I/O error, dev sr0, sector 204792
[  620.522956] Buffer I/O error on device sr0, logical block 25599
[  620.591157] sr 0:0:0:0: [sr0] Unhandled sense code
[  620.591179] sr 0:0:0:0: [sr0]  Result: hostbyte=0x07 driverbyte=0x08
[  620.591195] sr 0:0:0:0: [sr0]  Sense Key : 0x4 [current] 
[  620.591214] sr 0:0:0:0: [sr0]  ASC=0x0 ASCQ=0x0
[  620.591230] sr 0:0:0:0: [sr0] CDB: cdb[0]=0x28: 28 00 00 03 1f f8 00 00 08 00
[  620.591269] end_request: I/O error, dev sr0, sector 204792
[  620.597370] Buffer I/O error on device sr0, logical block 25599
[  620.741152] sr 0:0:0:0: [sr0] Unhandled sense code
[  620.741172] sr 0:0:0:0: [sr0]  Result: hostbyte=0x07 driverbyte=0x08
[  620.741187] sr 0:0:0:0: [sr0]  Sense Key : 0x4 [current] 
[  620.741205] sr 0:0:0:0: [sr0]  ASC=0x0 ASCQ=0x0
[  620.741220] sr 0:0:0:0: [sr0] CDB: cdb[0]=0x28: 28 00 00 03 1f f8 00 00 08 00
[  620.741256] end_request: I/O error, dev sr0, sector 204792
[  620.747353] Buffer I/O error on device sr0, logical block 25599
[  620.816642] sr 0:0:0:0: [sr0] Unhandled sense code
[  620.816653] sr 0:0:0:0: [sr0]  Result: hostbyte=0x07 driverbyte=0x08
[  620.816666] sr 0:0:0:0: [sr0]  Sense Key : 0x4 [current] 
[  620.816681] sr 0:0:0:0: [sr0]  ASC=0x0 ASCQ=0x0
[  620.816695] sr 0:0:0:0: [sr0] CDB: cdb[0]=0x28: 28 00 00 03 1f f8 00 00 08 00
[  620.816728] end_request: I/O error, dev sr0, sector 204792
[  620.822832] Buffer I/O error on device sr0, logical block 25599
[  764.775476] ehci_irq: highspeed device disconnect
[  764.775589] usb 4-1: USB disconnect, device number 2
[  764.795881] cdrom: issuing MRW background format suspend
[  765.318560] ehci_irq: highspeed device connect
[  765.590128] usb 4-1: new high-speed USB device number 3 using sunxi-ehci
[  765.756373] scsi1 : usb-storage 4-1:1.6
[  766.752355] scsi 1:0:0:0: Direct-Access     HSPA_USB SCSI CD-ROM       622 PQ: 0 ANSI: 0 CCS
[  766.782409] sd 1:0:0:0: [sda] Test WP failed, assume Write Enabled
[  766.783470] sd 1:0:0:0: [sda] Asking for cache data failed
[  766.789663] sd 1:0:0:0: [sda] Assuming drive cache: write through
[  766.799798] sd 1:0:0:0: [sda] Attached SCSI removable disk
[ 1302.041433] option 4-1:1.0: GSM modem (1-port) converter detected
[ 1302.043503] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB0
[ 1302.044076] option 4-1:1.1: GSM modem (1-port) converter detected
[ 1302.044969] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB1
[ 1302.045926] option 4-1:1.2: GSM modem (1-port) converter detected
[ 1302.055233] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB2
[ 1302.055818] option 4-1:1.3: GSM modem (1-port) converter detected
[ 1302.063015] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB3
[ 1302.063699] option 4-1:1.4: GSM modem (1-port) converter detected
[ 1302.067685] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB4
[ 1302.068430] option 4-1:1.5: GSM modem (1-port) converter detected
[ 1302.072084] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB5

接続

/etc/wvdail.confを下記のように編集し、保存します。

wvdial.conf
[Dialer Defaults]
Init1 = ATZ
Init2 = AT+CFUN=1
Init3 = AT+CGDCONT=1,"IP","soracom.io"
Dial Attempts = 3
Modem Type = Analog Modem
Dial Command = ATD
Stupid Mode = yes
Baud = 460800
New PPPD = yes
Modem = /dev/ttyUSB2
ISDN = 0
APN = soracom.io
Phone = *99***1#
Username = sora
Password = sora
Carrier Check = no
Auto DNS = 1
Check Def Route = 1

モデムがどれだか分からない場合は、cu をインストールして、若い番号から順番に AT コマンドで話しかけてみましょう。「当たり」なら、ATZ(リターン)で OK と返ってきます。

root@FriendlyARM:~# chmod 777 /dev/ttyUSB*
root@FriendlyARM:~# cu -l /dev/ttyUSB2
Connected.
atz
OK

wvdialを実行して接続します。

root@FriendlyARM:~# wvdial
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: AT+CFUN=1
AT+CFUN=1
OK
--> Sending: AT+CGDCONT=1,"IP","soracom.io"
AT+CGDCONT=1,"IP","soracom.io"
OK
--> Modem initialized.
--> Sending: ATD*99***1#
--> Waiting for carrier.
ATD*99***1#
CONNECT 21000000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Mon Aug 15 15:17:38 2016
--> Pid of pppd: 2712
--> Using interface ppp0
--> pppd: x?[02]
--> pppd: x?[02]
--> pppd: x?[02]
--> pppd: x?[02]
--> pppd: x?[02]
--> local  IP address 10.206.161.127
--> pppd: x?[02]
--> remote IP address 10.64.64.64
--> pppd: x?[02]
--> primary   DNS address 100.127.0.53
--> pppd: x?[02]
--> secondary DNS address 100.127.1.53
--> pppd: x?[02]

自分のIPアドレスやプライマリDNSのIPアドレスが表示され、正常に接続が完了していることが分かります。

かなり雑ですが、繋がるところまでは試してみました。
Ubuntu が動いて Ethernet のポートもあるので、ネットワークブリッジにしたり、(小さいのでハンダ付けは大変そうですが)GPIO も充実しているので色々と使えそうですね。
何より、7.99ドルなのに予想以上に高級感があって驚きました。

15
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
14