Using pppd dial-up Internet access (GPRS) process on ARM+LINUX

Publisher:RadiantGlowLatest update time:2016-06-20 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
My programming environment is vmware + fedora9, the ARM target board is ATMEL 9G45, LINUX kernel 2.6.30, the GPRS module is TELIT's GC864-DUAL-V2, and the 3-wire serial port connection is used (TXD RXD GND)


1. Modify the 2.6.30 kernel options,
 make menuconfig
Device drivers -> Networking device support -> PPP (point to point protocol) support.
 I selected the following modules (in M mode, i.e. module mode)
PPP support for async serial ports
PPP support for sync tty ports
PPP Deflate compression
PPP BSD-Compress compression
SLIP (serial line) support.
Then compile: make && make install && make modules && make modules_install.
I got several kernel library files in ko format, copied them to the ARM target board, and loaded them dynamically in /etc/init.d/rcS:
insmod /etc/ppp/slhc.ko                                        
insmod /etc/ppp/ppp_generic.ko                                 
insmod /etc/ppp/ppp_async.ko                                   
insmod /etc/ppp/ppp_synctty.ko                                 
insmod /etc/ppp/ppp_deflate.ko                                 
insmod /etc/ppp/bsd_comp.ko                                    
insmod /etc/ppp/slip.ko
Pay attention to the loading order. I remember that slhc.ko must be loaded first.

2. Porting ppp and connecting to the network process,  
1) ppp2.4.4 source code compilation process

#./configure

#make CC=arm-linux-gcc Pay attention to specify the path of arm-linux-gcc, or specify it directly with the absolute path

The files that need to be copied to the ARM target board are:
pppd
pppdump
pppstatus
chat
2) Script preparation
There are 4 scripts that need to be prepared, one is the rule file /etc/ppp/gprs-connect-chat, one is the parameter file /etc/ppp/peers/gprs, and the authentication files: pap-secret and chap-secret. (In fact, I only use pap-secret here, and not chap-secret. Anyhow, create them all)
(1) Script #gprs-connect-chat:
TIMEOUT 15
ABORT '\nBUSY\r'
ABORT '\nNO ANSWER\r'
ABORT '\nRINGING\r\n\r\nRINGING\r'
#'' AT
#'OK-+++\c-OK' ATH0
TIMEOUT 40
'' \rAT
OK AT+FLO=0 #This is a special setting for GC864-DUAL-V2, that is, to turn off flow control
OK ATS0=0
OK ATE0V1
OK AT+CGDCONT=1,"IP","CMNET" #Connect to China Mobile cmnet
OK ATDT*99*1#
CONNECT ''
(2) Script gprsoptions
#/etc/ppp/peers/gprsoptions
# Usage: root>pppd call gprsoptions
/dev/ttyS4
115200
nocrtscts
modem
#noauth
#auth
#-pap
#+chap
lock
debug
nodetach
#hide-password
usepeerdns
noipdefault
defaultroute
user cmnet
#user smsong
0.0.0.0:0.0.0.0
ipcp-accept-local
#ipcp-accept-remote
#lcp-e cho-failure 12
#lcp-echo-interval 3 
noccp                
#novj                
#novjccomp           
persist              
connect '/etc/ppp/chat -s -v -f /etc/ppp/gprs-connect-chat'
(3) Authentication file pap-secrets Change as needed
/etc/ppp # cat pap-secrets 
# Secrets for authentication using PAP
# client server secret IP addresses
cmnet * cmnet *
(4) Authentication file chap- secrets Modify as needed. It is not used now.
/etc/ppp # cat chap-secrets 
# Secrets for authentication using CHAP
# client server secret IP addresses
'' * '' *

3) Call process
ifconfig eth0 down // Turn off the wired network card first to avoid conflict with dial-up initialization
/etc/ppp/pppd call gprs& // Start the /etc/ppp/peers/gprs script
ifconfig eth0 up // Restart the wired network card
Let's take a look at the display log content of the connection:
/etc/ppp # ./pppd call gprs&
/etc/ppp # timeout set to 15 seconds
abort on (\nBUSY\r)
abort on (\nNO ANSWER\r)
abort on (\nRINGING\r\n\r\nRINGING\r)
timeout set to 40 seconds
send (^MAT^M)
expect (OK)
AT^M^M
OK
 -- got it

send (AT+FLO=0^M)
expect (OK)
^M
AT+FLO=0^M^M
OK
 -- got it

send (ATS0=0^M)
expect (OK)
^M
ATS0=0^M^M
OK
 -- got it

send (ATE0V1^M)
expect (OK)
^M
ATE0V1^M^M
OK
 -- got it

send (AT+CGDCONT=1,"IP","CMNET"^M)
expect (OK)
^M
^M
OK
 -- got it

send (ATDT*99*1#^M)
expect (CONNECT)
^M
^M
CONNECT
 -- got it

send (^M)
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyS4
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [LCP ConfReq id=0x1 ]
rcvd [LCP ConfAck id=0x1 ]
rcvd [LCP ConfReq id=0x1 ]
sent [LCP ConfAck id=0x1 ]
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
sent [PAP AuthReq id=0x1 user="cmnet" password=]
rcvd [PAP AuthAck id=0x1 "Welcome!"]
Remote message: Welcome!
PAP authentication succeeded
sent [IPCP ConfReq id=0x1 ]
rcvd [IPCP ConfReq id=0x1 ]
sent [IPCP ConfAck id=0x1 ]
rcvd [IPCP ConfRej id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [IPCP ConfNak id=0x2 ]
sent [IPCP ConfReq id=0x3 ]
rcvd [IPCP ConfAck id=0x3 ]
local  IP address 10.176.120.186
remote IP address 192.168.202.0
primary   DNS address 218.201.96.130
secondary DNS address 211.137.191.26

4)  查看网络设置与ping实验
/etc/ppp # ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:10.176.120.186 PtP:192.168.202.0 Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:64 (64.0 B) TX bytes:82 (82.0 B)
Let’s ping
/etc/ppp # ping www.163.com -c 3
PING www.163.com (221.204.240.161): 56 data bytes
64 bytes from 221.204.240.161: seq=0 ttl=46 time=466.873 ms
64 bytes from 221.204.240.161: seq=1 ttl=46 time=435.762 ms
64 bytes from 221.204.240.161: seq=2 ttl=46 time=414.000 ms

--- www.163.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 414.000/438.878/466.873 ms

3. Other issues

1) Set the DNS address
/etc/ppp to be automatically set by the dial-up A resolv.conf file is generated, but it is not the same file as /etc/resolv.conf, so DNS sometimes cannot be resolved.
A good way is to first ensure that /etc/resolv.conf exists, then create a soft link in /etc/ppp ln -s /etc/ppp/resolv.conf /etc/resolv.conf
so that after the dial-up is successful, /etc/resolv.conf will have the following content:
nameserver 218.201.96.130
nameserver 211.137.191.26
2) Only IP addresses can be pinged, but domain names cannot be pinged
There is a paragraph in the busybox command help page:
Quote:
LIBC NSS
When used with glibc, the BusyBox 'networking' applets will similarly require that you install at least some of the glibc NSS stuff (in particular, /etc/nsswitch.conf, /lib/libnss_dns*, /lib/libnss_files*, and /lib /libresolv*).
Then put libnss_dns* in the lib directory of the arm-linux tool chain, Copy libnss_files* and libresolv* to /lib of the ARM target board. You can ping the domain name 
/etc/ppp # ping www.163.com
PING www.163.com (221.204.240.161): 56 data bytes
64 bytes from 221.204.240.161: seq=0 ttl=46 time=641.269 ms
64 bytes from 221.204.240.161: seq=1 ttl=46 time=435.801 ms
64 bytes from 221.204.240.161: seq=2 ttl=46 time=446.776 ms
64 bytes from 221.204.240.161: seq=3 ttl=46 time=381 .381 ms
64 bytes from 221.204.240.161: seq=4 ttl=46 time=468.495 ms

--- www.163.com ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 381.381/ 474.744/641.269 ms


3) How to dial up and connect to China Unicom's 3G network?
Use TELIT's UC864-E and use USB connection. Specify the serial port as ttyUSB0.
For ppp, only a few changes need to be made in the four scripts.
a. Change the options script
  to rename gprsoptions to g3options, change the line parameter /dev/ttyS4 to /dev/ttyUSB0, and
change connect '/ etc/ppp/chat -s -v -f /etc/ppp/gprs-connect-chat'
to connect '/etc/ppp/chat -s -v -f /etc/ppp/g3-connect-chat'
b . Change chat script
TIMEOUT 15
ABORT '\nBUSY\r'
ABORT '\nNO ANSWER\r'
ABORT '\nRINGING\r\n\r\nRINGING\r'
#'' AT
#'OK-+++\c-OK' ATH0
TIMEOUT 40
'' \rAT
OK AT+FLO=0
OK ATS0=0
OK ATE0V1
OK AT+CGDCONT=1,"IP","UNINET" #UNINET stands for China Unicom. #OK AT+
CGDCONT=1,"IP","CMNET"
OK ATDT*99*1#
CONNECT    
c. Change pap-secrets
# Secrets for authentication using PAP
# client server secret IP addresses
#cmnet * cmnet * #If it is China Mobile GPRS, use cmnet
uninet * uninet * #If it is China Unicom 3G, use uninet

d. Change chap-secrets
to the same as above pap-secrets

Keywords:ARM Reference address:Using pppd dial-up Internet access (GPRS) process on ARM+LINUX

Previous article:Using USB touch screen on ARM Linux
Next article:Create nfs file system on arm linux

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号