====== LTE Cat.1 拡張ボード(OB-L1)の利用 ======
XG-50 に、NTT docomo LTE Cat.1 回線用オプションボード [[https://www.centurysys.co.jp/products/industrial/xgb50.html|FutureNet OB-L1]] を搭載し、
LTE Cat.1 回線を利用してみます。
{{:xg_series_devel:ublox_lara:lara-r220_00.jpg?600|OB-L1 オプションボード}}
\\
===== ファームウェアのビルド =====
==== ソースコードの準備 ====
=== リポジトリから clone ===
[[https://gitlab.com/centurysystems/XG-50|GitLab]] のリポジトリを clone します。
まずは、NuttX 本体部分を clone します。
kikuchi@develop:~/src/OB-L1$ git clone https://gitlab.com/centurysystems/XG-50/nuttx.git
Cloning into 'nuttx'...
remote: Enumerating objects: 9256, done.
remote: Counting objects: 100% (9256/9256), done.
remote: Compressing objects: 100% (3942/3942), done.
remote: Total 380868 (delta 6493), reused 7046 (delta 4865)
Receiving objects: 100% (380868/380868), 91.79 MiB | 2.15 MiB/s, done.
Resolving deltas: 100% (296680/296680), done.
Checking connectivity... done.
kikuchi@develop:~/src/OB-L1$
アプリケーション部分も clone します。
kikuchi@develop:~/src/OB-L1$ git clone https://gitlab.com/centurysystems/XG-50/apps.git
Cloning into 'apps'...
remote: Enumerating objects: 992, done.
remote: Counting objects: 100% (992/992), done.
remote: Compressing objects: 100% (734/734), done.
remote: Total 36554 (delta 577), reused 400 (delta 252)
Receiving objects: 100% (36554/36554), 9.03 MiB | 1.95 MiB/s, done.
Resolving deltas: 100% (29223/29223), done.
Checking connectivity... done.
kikuchi@develop:~/src/OB-L1$
clone された結果です。
kikuchi@develop:~/src/OB-L1$ ls -l
total 8
drwxrwxr-x 21 kikuchi kikuchi 4096 8月 17 15:56 apps
drwxrwxr-x 21 kikuchi kikuchi 4096 8月 17 15:55 nuttx
kikuchi@develop:~/src/OB-L1$
\\
=== ブランチの確認 ===
それぞれブランチはデフォルト(XG-50/master) のままで OK です。
kikuchi@develop:~/src/OB-L1$ cd nuttx/
kikuchi@develop:~/src/OB-L1/nuttx$ git branch
* XG-50/master
kikuchi@develop:~/src/OB-L1/nuttx$ cd ../apps/
kikuchi@develop:~/src/OB-L1/apps$ git branch
* XG-50/master
kikuchi@develop:~/src/OB-L1/apps$
\\
==== コンフィグレーション ====
コンフィグレーションを行います。''"centurysys-xg50/nsh_tickless"'' を使用します。
kikuchi@develop:~/src/OB-L1/apps$ cd ../nuttx/
kikuchi@develop:~/src/OB-L1/nuttx$ cd tools/
kikuchi@develop:~/src/OB-L1/nuttx/tools$ ./configure.sh centurysys-xg50/nsh_tickless
Copy files
Refreshing...
kikuchi@develop:~/src/OB-L1/nuttx/tools$
\\
追加のアプリケーションなどを使う場合は、''make menuconfig'' でコンフィグレーションを変更して追加することもできます。
{{:xg_series_devel:ublox_lara:make_menuconfig.png?600|make menuconfig}}
\\
==== ビルド ====
''make'' でバイナリをビルドします。
kikuchi@develop:~/src/OB-L1/nuttx/tools$ cd ..
kikuchi@develop:~/src/OB-L1/nuttx$ make
make[1]: Entering directory '/home/kikuchi/src/OB-L1/nuttx/tools'
make[1]: Leaving directory '/home/kikuchi/src/OB-L1/nuttx/tools'
No .version file found, creating one
make[1]: Entering directory '/home/kikuchi/src/OB-L1/nuttx/tools'
make[1]: Leaving directory '/home/kikuchi/src/OB-L1/nuttx/tools'
LN: include/arch to arch/arm/include
LN: include/arch/board to /home/kikuchi/src/OB-L1/nuttx/configs/centurysys-xg50/include
LN: include/arch/chip to arch/arm/include/stm32l4
LN: arch/arm/src/board to /home/kikuchi/src/OB-L1/nuttx/configs/centurysys-xg50/src
LN: arch/arm/src/chip to arch/arm/src/stm32l4
make[1]: Entering directory '/home/kikuchi/src/OB-L1/nuttx/configs'
make[1]: Leaving directory '/home/kikuchi/src/OB-L1/nuttx/configs'
....
CC: stm32_adc.c
CC: stm32_timer.c
CC: stm32_appinit.c
AR: stm32_boot.o stm32_clockconfig.o stm32_autoleds.o stm32_userleds.o stm32_adc.o stm32_timer.o stm32_appinit.o
make[2]: Leaving directory '/home/kikuchi/src/OB-L1/nuttx/configs/centurysys-xg50/src'
LD: nuttx
make[1]: Leaving directory '/home/kikuchi/src/OB-L1/nuttx/arch/arm/src'
CP: nuttx.hex
CP: nuttx.bin
kikuchi@develop:~/src/OB-L1/nuttx$
\\
ファームウェアのバイナリができました。
kikuchi@develop:~/src/OB-L1/nuttx$ ls -l nuttx*
-rwxrwxr-x 1 kikuchi kikuchi 2866548 8月 17 16:00 nuttx
-rwxrwxr-x 1 kikuchi kikuchi 172432 8月 17 16:00 nuttx.bin
-rw-rw-r-- 1 kikuchi kikuchi 485063 8月 17 16:00 nuttx.hex
kikuchi@develop:~/src/OB-L1/nuttx$
\\
===== XG-50 への書き込み =====
''OpenOCD'' + ''gdb'' を使用してファームウェアを書き込みます。
\\
===== 動作確認 =====
''gdb'' から ''"c"''(continue) で実行します。
��ABCDFboot
NuttShell (NSH)
nsh>
\\
==== PPP 接続 ====
''pppd'' コマンドにより接続を行います。APN / user / password はコマンドラインから指定します。\\
実際に接続する際には ''"&"'' をつけてバックグラウンドで起動((フォアグラウンドで起動すると何もできなくなります。))します。
nsh> pppd
Usage: pppd -a APN -u UserName -p Password
nsh> pppd -a dream.jp -u user@dream.jp -p dti &
pppd [4:100]
nsh>
\\
しばらくすると接続が完了します。dmesg でログを確認することができます。
nsh> dmesg
[ 0.000000] stm32l4_rng_initialize: Initializing RNG
[ 0.000000] registered UART4 as /dev/console.
[ 0.000000] registered UART4 as /dev/ttyS0.
[ 0.000000] registered UART1 as /dev/ttyS1.
[ 0.000000] registered USART2 as /dev/ttyS2.
[ 0.000000] registered USART3 as /dev/ttyS3.
[ 0.001500] Mounting procfs to /proc
[ 0.003000] TCA9534 registered.
[ 0.006500] board_ioctl: BIOC_ENABLE_B2B
[ 21.210500] chat: expect ()
[ 21.210500] chat:
[ 21.211000] chat: -- got it
[ 21.211000] chat: send ATE0
[ 21.211000] chat: expect (OK)
[ 21.217500] chat: ^M
[ 21.220000] chat: OK^M
[ 21.220000] chat: -- got it
[ 21.220000] chat: send AT+COPS?
[ 21.220500] chat: expect (OK)
[ 21.228500] chat: ^M
[ 21.234000] chat: +COPS: 2^M
[ 21.235500] chat: ^M
[ 21.237500] chat: OK^M
[ 21.238000] chat: -- got it
[ 21.238000] chat: send AT+CGACT?
[ 21.238000] chat: expect (OK)
[ 21.247500] chat: ^M
[ 21.255000] chat: +CGACT: 1,0^M
[ 21.256000] chat: ^M
[ 21.258500] chat: OK^M
[ 21.258500] chat: -- got it
[ 21.259500] chat: abort on (BUSY)
[ 21.259500] chat: abort on (NO CARRIER)
[ 21.259500] chat: abort on (ERROR)
[ 21.260000] chat: timeout is 10 s
[ 21.260000] chat: expect ()
[ 21.260000] chat:
[ 21.260000] chat: -- got it
[ 21.260500] chat: send ATE0
[ 21.260500] chat: expect (OK)
[ 21.266500] chat: ^M
[ 21.269000] chat: OK^M
[ 21.269000] chat: -- got it
[ 21.269000] chat: send AT+COPS=2
[ 21.269500] chat: expect (OK)
[ 21.296500] chat: ^M
[ 21.298500] chat: OK^M
[ 21.299000] chat: -- got it
[ 21.299000] chat: send AT+CGDCONT=1,"IP","dream.jp"
[ 21.299000] chat: expect (OK)
[ 21.320000] chat: ^M
[ 21.322000] chat: OK^M
[ 21.322500] chat: -- got it
[ 21.322500] chat: send AT+UAUTHREQ=1,1,"user@dream.jp","dti"
[ 21.322500] chat: expect (OK)
[ 21.347500] chat: ^M
[ 21.350000] chat: OK^M
[ 21.350000] chat: -- got it
[ 21.350000] chat: send AT+COPS?
[ 21.350000] chat: expect (OK)
[ 21.358500] chat: ^M
[ 21.364000] chat: +COPS: 2^M
[ 21.365500] chat: ^M
[ 21.367500] chat: OK^M
[ 21.367500] chat: -- got it
[ 21.368000] chat: send ATD*99***1#
[ 21.368000] chat: expect (CONNECT)
[ 21.939500] chat: ^M
[ 21.944500] chat: CONNECT^M
[ 21.944500] chat: -- got it
[ 22.938500] pppd: sent [LCP ConfReq ]
[ 22.968000] pppd: rcvd [LCP ConfReq id=0x1 ]
[ 22.968500] pppd: sent [LCP ConfAck id=0x1]
[ 22.984500] pppd: rcvd [LCP ConfAck id=0x0]
[ 22.985000] pppd: sent [PAP AuthReq id=0x0 user="user@dream.jp" password=]
[ 23.032500] pppd: rcvd [PAP AuthAck id=0x0 ""]
[ 23.033000] pppd: PAP authentication succeeded
[ 23.033000] pppd: sent [IPCP ConfReq id=0x0 ]
[ 29.037000] pppd: sent [IPCP ConfReq id=0x0 ]
[ 29.082500] pppd: rcvd [IPCP ConfReq id=0x1]
[ 29.082500] pppd: sent [IPCP ConfAck id=0x1]
[ 29.099500] pppd: rcvd [IPCP ConfNak id=0x0 ]
[ 35.076500] pppd: sent [IPCP ConfReq id=0x1 ]
[ 35.082500] pppd: rcvd [IPCP ConfReq id=0x1]
[ 35.083000] pppd: sent [IPCP ConfAck id=0x1]
[ 35.134500] pppd: rcvd [IPCP ConfAck id=0x1 ]
[ 35.134500] pppd: local IP address 100.71.39.158
[ 35.135000] pppd: remote IP address 10.64.64.64
[ 35.135000] pppd: primary DNS address 202.231.208.71
[ 35.135500] pppd: secondary DNS address 202.231.208.72
[ 35.135500] pppd: DNS server added.
ifconfig で確認ができます。
nsh> ifconfig
ppp0 Link encap:TUN at UP
inet addr:100.71.39.158 DRaddr:0.0.0.0 Mask:0.0.0.0
lo Link encap:Local Loopback at UP
inet addr:127.0.0.1 DRaddr:127.0.0.1 Mask:255.0.0.0
IPv4 TCP UDP ICMP
Received 0000 0000 0000 0000
Dropped 0000 0000 0000 0000
IPv4 VHL: 0000 Frg: 0000
Checksum 0000 0000 0000 ----
TCP ACK: 0000 SYN: 0000
RST: 0000 0000
Type 0000 ---- ---- 0000
Sent 0000 0000 0000 0000
Rexmit ---- 0000 ---- ----
nsh>
\\
ping で通信の確認もできます。
nsh> ping -c 5 www.yahoo.co.jp
PING 183.79.250.123 56 bytes of data
56 bytes from 183.79.250.123: icmp_seq=0 time=193 ms
56 bytes from 183.79.250.123: icmp_seq=1 time=192 ms
56 bytes from 183.79.250.123: icmp_seq=2 time=192 ms
56 bytes from 183.79.250.123: icmp_seq=3 time=190 ms
56 bytes from 183.79.250.123: icmp_seq=4 time=189 ms
5 packets transmitted, 5 received, 0% packet loss, time 5005 ms
nsh>
\\
切断するときには、pppd のプロセスを KILL します。
nsh> ps
PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
0 0 0 FIFO Kthread N-- Ready 00000000 000000 Idle Task
1 1 224 FIFO Kthread --- Waiting Signal 00000000 002028 hpwork
2 1 50 FIFO Kthread --- Waiting Signal 00000000 002028 lpwork
3 1 100 FIFO Task --- Running 00000000 004076 init
4 4 100 RR Task --- Waiting Semaphore 00000000 001964 pppd -a dream.jp -u user@dream.jp -p dti
nsh> kill -15 4
nsh>
nsh> dmesg
[ 174.989000] pppd: Connection Terminated.
[ 178.991000] chat: expect ()
[ 178.991000] chat:
[ 178.991500] chat: -- got it
[ 178.992500] chat: send ATE0
[ 178.992500] chat: expect (OK)
[ 178.998500] chat: ^M
[ 179.001000] chat: OK^M
[ 179.001000] chat: -- got it
[ 179.001000] chat: send AT+COPS?
[ 179.001000] chat: expect (OK)
[ 179.008500] chat: ^M
[ 179.024000] chat: +COPS: 2,0,"NTT DOCOMO",7^M
[ 179.025500] chat: ^M
[ 179.027500] chat: OK^M
[ 179.027500] chat: -- got it
[ 179.028000] chat: send AT+CGACT?
[ 179.028000] chat: expect (OK)
[ 179.036000] chat: ^M
[ 179.043500] chat: +CGACT: 1,1^M
[ 179.045000] chat: ^M
[ 179.047000] chat: OK^M
[ 179.047000] chat: -- got it
[ 179.047500] TIOCMBIC(TIOCM_DTR) -> 0
nsh> ifconfig
lo Link encap:Local Loopback at UP
inet addr:127.0.0.1 DRaddr:127.0.0.1 Mask:255.0.0.0
IPv4 TCP UDP ICMP
Received 0006 0000 0001 0005
Dropped 0000 0000 0000 0000
IPv4 VHL: 0000 Frg: 0000
Checksum 0000 0000 0000 ----
TCP ACK: 0000 SYN: 0000
RST: 0000 0000
Type 0000 ---- ---- 0000
Sent 0006 0000 0001 0005
Rexmit ---- 0000 ---- ----
nsh>
\\
===== アプリケーションに組み込む場合 =====
''apps/examples/pppd/pppd_main.c'' を参考に、アプリケーションに組み込んでください。
\\