1. EC20 module connection
For embedded Linux, 4G network connection is an easy function to realize. Most 4G module interfaces are MiniPCIE interfaces. After a deep understanding, it will be found that the communication interface of 4G module is USB, so the driver of 4G module often uses USB driver. As long as the USB driver is normal, the 4G module can communicate normally in hardware. However, in this paper, the USB driver is not used, but the serial port driver. The pin of the chip NUC980DK61Y in the NUC980 main control board and the RX TX of EC20 R2.1 module are connected through the level conversion chip, as well as the powerkey pin of EC20. Refer to EC20 hardware design manual for details.
Linux kernel configuration
Source directory, enter the command make linux menuconfig on the linux terminal for configuration.
-
Select the following options for serial port multiplexing.
The configuration path is as follows:
Device Drivers —> Character devices —>
<*> GSM MUX line discipline support(EXPERIMENTAL)
-
Select the following options to support PPP dialing.
The configuration path is as follows:
Device Drivers —> Network device support —>
<> PPP (point-to-point protocol) support
<> PPP BSD-Compress compression
<> PPP Deflate compression
[] PPP filtering
<> PPP MPPE compression (encryption)
[] PPP multilink support
<> PPP over Ethernet
<> PPP support for async serial ports
<> PPP support for sync tty ports
<> SLIP(serial line) support
-
Save, exit, execute make, get the uImage file, and burn it to the development board.
Cross compile PPP
Copy the ppp-2.4.7 compressed package to ubuntu and unzip it.
ppp-2.4.7 compressed package download link: https://pan.baidu.com/s/1dhyhfghJspcT0mfn1bH6ww
Extraction code: y5bs
- Generate Makefile file:. / configure --prefix = /... (specify folder)
- compile
The compiler consistent with the development board must be used. NUC980 uses arm Nuvoton Linux uclibcgnueabi
- Install: make install
- Copy part of the compiled executable files to the ARM development board:
After making the above, find the following four executable files in the directory: chat, pppd, pppdump, pppstats
Copy the four files to the / usr/sbin directory of the ARM development board. - Following the above steps, you can use the pppd command and the chat command after the copy is completed.
Chat Script
Create a new ppp folder in the / etc directory of the development board, where Putty is used for interaction.
- Copy the files from the corresponding directory of ppp-2.4.7 and establish the following directory structure:
/etc/ppp/chap-secrets
/etc/ppp/pap-secrets
/etc/ppp/ip-up
/etc/ppp/ip-down
/etc/ppp/peers/ - Dial up script: put the following three scripts in the directory: / etc/ppp/peers
a. Dial up script quectel PPP
# /etc/ppp/peers/quectel-pppd # Usage:root>pppd call quectel-pppd #Modem path, like /dev/ttyS3,/dev/ttyACM0, depend on your module, default path is /dev/ttyS3 /dev/ttyS3 115200 #Insert the username and password for authentication, default user and password are test user "test" password "test" # The chat script, customize your APN in this file connect 'chat -s -v -f /etc/ppp/peers/quectel-chat-connect' # The close script disconnect 'chat -s -v -f /etc/ppp/peers/quectel-chat-disconnect' # Hide password in debug messages hide-password # The phone is not required to authenticate noauth # Debug info from pppd debug # If you want to use the HSDPA link as your gateway defaultroute # pppd must not propose any IP address to the peer noipdefault # No ppp compression novj novjccomp noccp ipcp-accept-local ipcp-accept-remote local # For sanity, keep a lock on the serial line lock modem dump nodetach # Hardware flow control nocrtscts remotename 3gppp ipparam 3gppp ipcp-max-failure 30 # Ask the peer for up to 2 DNS server addresses usepeerdns
b. chat script (quercetel chat connect)
# /etc/ppp/peers/quectel-chat-connect ABORT "BUSY" ABORT "NO CARRIER" ABORT "NO DIALTONE" ABORT "ERROR" ABORT "NO ANSWER" TIMEOUT 30 "" AT OK ATE0 OK ATI;+CSUB;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2 # Insert the APN provided by your network operator, default apn is 3gnet OK AT+CGDCONT=1,"IP","3gnet",,0,0 OK ATD*99# CONNECT
c. Quexel chat disconnect
# /etc/ppp/peers/quectel-chat-disconnect ABORT "ERROR" ABORT "NO DIALTONE" SAY "\nSending break to the modem\n" "" +++ "" +++ "" +++ SAY "\nGoodbay\n"
Dialing
- Input the command PPPD call quectel PPP &, and the following description appears, indicating that the dialing is successful (not all listed).
- View module operation status
Input ifconfig at the PUTTY terminal to view the network. ppp0 appears as follows, indicating that the 4G module determines that the dialing is successful.
- After dialing successfully, ppp0 can be set as a static route.
Set ppp0 as the default route: delete the original route first, route del default; Then set ppp0 as the default route, and route add default dev ppp0.