Article Directory
1 PPP package compilation
First copy ppp-2.4.4.tar.gz to Ubuntu, and then execute the following command to decompress: After
tar -xvf ppp-2.4.4.tar.gz
decompression, you will get the ppp-2.4.4 directory, and enter the ppp-2.4.4 directory as shown in Figure 1.1:
Use configure to configure, the command is as follows: the
./configure
result is shown in Figure 1.2:
After the configuration is complete, use the following command to compile:
make CC=arm-linux-gnueabihf-gcc
"CC=arm-linux-gnueabihf-gcc" specifies the compiler, which uses the same compiler as the Linux kernel of the development board.
Compilation is completed as shown in Figure 1.3:
After the compilation is complete, generate chat, pppd, pppdump, and pppstats executable files in the four directories of chat, pppd, pppdump, and pppstats for the subsequent 4G module networking test.
2 EC20 4G module networking test
First install the EC20 4G module, antenna and SIM card, as shown in Figure 2.1:
After the development board is ready, start the Linux system. After the system starts, enter the /etc directory, and then create the ppp directory. The specific commands are as follows:
cd /etc //进入etc目录
mkdir ppp //创建ppp目录
After the directory is created, use the U disk to copy the four executable files of chat, pppd, pppdump, and pppstats compiled in the previous section to the /etc/ppp directory, as shown in Figure 2.2:
Then create the pap-secrets file in the /etc/ppp directory, use the following command:
touch pap-secrets //创建pap-secrets文件
vi pap-secrets //打开pap-secrets文件
Enter the following:
# Secrets for authentication using PAP
# client server secret IP addresses
card * card *
In the 4G signal, there is a password comparison during communication, and the communication can be done if the password is correct. The above shows that the user is card and the password is card.
Then create a new folder peers and command "mkdir peers".
Enter the peers folder and create a wcdma file, the command is as follows:
touch wcdma
vi wcdma
Enter the following:
# /etc/ppp/peers/wcdma
# This is pppd script for China liantong
# Usage: root>pppd call wcdma
hide-password
noauth
connect '/etc/ppp/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect'
disconnect '/etc/ppp/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect'
debug
/dev/ttyUSB2
115200
defaultroute
noipdefault
novj
novjccomp
noccp
ipcp-accept-local
ipcp-accept-remote
local
lock
dump
nodetach
user "card"
password "card"
crtscts
remotename 3gppp
ipparam 3gppp
usepeerdns
Note that the /dev/ttyUSB2 device node file is used.
"User "card"" and "password "card"" correspond to the username and password in the pap-secrets file.
Create wcdma-chat-connect file:
touch wcdma-chat-connect
vi wcdma-chat-connect
内容如下:
ABORT "BUSY"
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT "ERROR"
ABORT "NO ANSWER"
TIMEOUT 120
"" AT
OK \rATZ
OK \rAT+CGDCONT=1,"IP","3gnet",,0,0
OK-AT-OK ATDT*99#
CONNECT \d\c
Here OK \rAT+CGDCONT=1,"IP","3gnet",0,0
OK-AT-OK ATDT*99#
These two sentences will change according to China Mobile Unicom or Telecom, here is mobile 4G.
Create wcdma-chat-disconnect file:
touch wcdma-chat-disconnect
vi wcdma-chat-disconnect
The content is as follows:
ABORT "ERROR"
ABORT "NO DIALTONE"
SAY "INSending break to the modem\n"
""\k"
""+++ATH"
SAY "\nGood bye\n"
After the required files are created, the network test can be carried out.
Turn off the eth0 device first, because there is a conflict with the EC20 4G module, and only one device can be used at the same time. The command is as follows:
ifconfig eth0 down
Then enter the command in the /etc/ppp directory: the
./pppd call wcdma &
result is shown in Figure 2.3:
The above figure shows that the IP address after successful networking is 10.47.135.182. Use the ifconfig command to view the result as shown in Figure 2.4:
At this time, use the ping command to check that the external network can be pinged. The command is as follows: The
ping 202.108.22.5 -c 4
"-c" option specifies the number of times to ping the network. "202.108.22.5" is Baidu's IP address, the result is shown in Figure 2.5:
I found that I can't ping the external network. I am willing because the DNS is not set correctly. There is a file resolv.conf under etc. This file is used to put DNS. The domain name in this is not set correctly. However, it is mandatory to copy this file to 192.168.1.1 in the running script of eth0. This results in that even if the correct DNS is set in this file, you will find that the file is already 192.168.1.1 after booting. This is because eth0 is self-starting.
We create a new file resolv.conf_back in the /etc directory:
touch resolv.conf_back
vi resolv.conf_back
Enter the following:
nameserver 202.99.160.68
nameserver 221.130.33.52
nameserver 221.130.33.60
nameserver 192.168.1.1
Then create a new script file ppp0:
touch ppp0
vi ppp0
Enter the following:
#!/bin/sh
ifconfig eth0 down
cp /etc/resolv.conf_back /etc/resolv.conf
/etc/ppp/pppd call wcdma&
Modify the execution permissions of the ppp0 file:
chmod 777 ppp0
The first step here is to turn off eth0, the second step is to overwrite our DNS file on resolv.conf, and the third step is to run. Then reboot and execute the ppp0 script. The command is as follows: After the
/etc/ppp0
script is successfully executed, use the ping command again, and the result is shown in Figure 2.6:
The picture shows that Baidu's IP address can be pinged normally. So far, the EC20 4G module can be used normally.