Write PPP and PPP-ON scripts in Linux Embedded Systems

Source: Internet
Author: User
Tags nameserver

In Linux embedded systems, we can write GPRS scripts. The content involves PPP. In this article, we will explain how to perform ppp dialing on the Liod platform to implement GPRS internet access. First, let's take a look at the hardware platform: yidao Liod platform is based on PXA270 ). Operating System: Embedded Linux.

Step 1: If the kernel does not support ppp dialing, recompile the kernel and add support for ppp.

 
 
  1. <*> PPP (point-to-point protocol) support                 
  2. [*]    PPP multilink support (EXPERIMENTAL)                  
  3. <*>    PPP support for async serial ports                    
  4. <*>    PPP support for sync tty ports                       
  5. <*>    PPP Deflate compression                               
  6. <*>    PPP BSD-Compress compression  

Then re-burn the new kernel image!

Step 2: DownloadPpp-2.4.1 source code package: generate the pppd and chat programs required for dialing.

Source code download URL: ftp://ftp.samba.org/pub/ppp/ decompress the source code package, enter the directory, cross compilation, the cross compiler used here is arm-linux-gcc (version 3.3.2)

 
 
  1. #cd /root/gprs/ppp-2.4.1  
  2. #./configure  
  3. #make CC=arm-linux-gcc  

The dialing program is/root/gprs/ppp-2.4.1/pppd, And/root/gprs/ppp-2.4.1/chat program for debugging convenience, I create a new directory named pppdial on the CF card and copy the pppd and chat programs to this directory!

Step 3: configure the dialing script:

Copy the ppp-on, ppp-on-dialer, ppp-off scripts under/root/gprs/ppp-2.4.1/scripts/to/mnt/cf/pppdial, then modify the script:

1. The content of the ppp-on script to be modified is as follows:

 
 
  1.      TELEPHONE=*99***1#      # The telephone number for the connection  
  2.      ACCOUNT=                       # The account name for logon (as in 'George   
  3. Burns')  
  4.      PASSWORD=                    # The password for this account (and 'Gracie A  
  5. llen')  
  6.      LOCAL_IP=0.0.0.0             # Local IP address if known. Dynamic = 0.0.0.0  
  7.  
  8.      REMOTE_IP=0.0.0.0          # Remote IP address if desired. Normally 0.0.0.0  
  9.  
  10.      NETMASK=255.255.255.0 # The proper netmask if needed  
  11.  
  12. # Export them so that they will be available at 'ppp-on-dialer' time.  
  13. export TELEPHONE ACCOUNT     
  14. DIALER_SCRIPT=/mnt/cf/pppdial/ppp-on-dialer  
  15.  
  16. # Initiate the connection  
  17.  
  18. exec /mnt/cf/pppdial/pppd debug lock nocrtscts   /dev/ttyS1 19200 \  
  19. asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \  
  20. noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT usepeerdns 

2. Modify the ppp-on-dialer script:

 
 
  1. #!/bin/sh  
  2. #  
  3. # This is part 2 of the ppp-on script. It will perform the connection  
  4. # protocol for the desired connection.  
  5. #  
  6. exec /sbin/chat -v       \  
  7. TIMEOUT   5     \  
  8. ABORT   '\nBUSY\r'    \  
  9. ABORT   '\nNO ANSWER\r'    \  
  10. ABORT   '\nRINGING\r\n\r\nRINGING\r' \  
  11.          ''   AT+CGDCONT=1,IP,CMNET          \  
  12.          'OK'             AT     \  
  13. 'OK-+++\c-OK' ATH0     \  
  14. TIMEOUT   30     \  
  15. OK   ATDT$TELEPHONE    \  
  16. CONNECT   

3. Add the/etc/ppp/resolv. conf file to the Liod board.

 
 
  1. nameserver 211.136.20.203  
  2. nameserver 211.136.18.171 

Step 4: connect to gprs

The gprs module connects to the Bluetooth serial port (/dev/ttyS1) on the Board through the serial port, because the ffuart of the Liod board is used for debugging the serial port, even if you log on to the Liod through telnet, however, if the serial port 0 is used to connect to the GPRS module, dialing will fail. this is because debugging information is output from serial port 0, which may interfere with the dialing process.

Disable the default network device: ifconfig eth0 down

Pppd Dialing:./ppp-on

(Note: Disable eth0 before dialing. Otherwise, even if the IP address can be obtained through dialing, the Internet cannot be accessed due to a route error)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.