The first task is to drive the 3G Nic of China Telecom on a small board. The new thing is to run the network card on the PC first. The driver with the card is not available in Linux, so there are two ways to do that: Google: Is there a Linux open-source driver with the card; the other is to check whether the kernel itself can be supported. Later, it was confirmed that the USB-serial part of the kernel could be driven.
This is a CDMA card, so I searched for something related to the CDMA MODEM under Drivers/USB/serial. Actually, there is a file named option. C. In fact, this is the general driver of the usb cdma gsm Modem, but with such a popular name, the two IDs of this card are directly added to this file. Re-compile the kernel and restart the machine. Then plug the card, there is the/dev/ttyUSB0-2 three modem.
The next step is simple. wvdialconf is automatically configured, and then wvdial dialing is performed.
$ Sudo wvdialconf
$ Sudo VI/etc/wvdial. conf
$ Sudo wvdial
Sudo is necessary because you need to automatically modify some configuration files under/etc, and you need high permissions to run pppd. The call was successful. Both wvdial and RP-pppoe are the frontend of pppd.Program. The division of labor is different. wvdial is responsible for connecting to the Internet through MODEM dialing, and RP-pppoe is responsible for dialing the connection through the network cable. In fact, the core is pppd, but the configuration of pppd is complicated, so many frontend with it as the back segment appear.
The next step is to get it on the Small board. First, modify the kernel re-compilation, which is very smooth (only one line is added, and it is not bad ). Then insert the card to the board. No response, embedded systems generally do not have devices that automatically add such things .. Therefore, you can only manually add device files.
$ Mknod/dev/ttyusb0 C 188 0
$ Mknod/dev/ttyusb1 C 188 1
$ Mknod/dev/ttyusb2 C 188 2
It's easy to test whether these devices actually exist.
$ Echo atz>/dev/ttyusb0
$ Echo atz>/dev/ttyusb1
$ Echo atz>/dev/ttyusb2
If there is no error output, it is correct. If no such device is displayed, the kernel is not correct.
Next, we need to transplant the batch of Dial software. The first step is pppd(ppp-2.x.x.tar.gz). Previously, the configure of this package is a fake configure script and only responsible for copying makefile. Therefore, you need to manually modify the makefile. Instead of compiling all modules, you only need to compile the pppd directory and chat directory. Basically, it is OK to add the CC definition in makefile.
After compilation of pppd, we started to transplant wvdial, which made me stuck in the shell-we can see that C ++ was the top developer. Not only that, but not complex wvdial relies on a fairly complex C ++ class library wvstreams. Wvstreams is an automake project, but even so, a bunch of things need to be changed to shield dozens of lines.CodeOr help implement the dot-null function to compile and pass. In this way, the estimation is not quite available. It turns out that although wvdial can run, it turns a blind eye to several modem devices.
To prove that the modem is OK, I wrote a serial port test program to test the modem. By sending atz, OK is returned. ati0 returns a bunch of device information. atdt #888 returns connect, which ensures that the device is in good condition and wvdial is not running properly. Give up wvdial, switch to the dial-up script that comes with the ppp-2.x.x, did not succeed, did not succeed in the PC, not to mention the Small board.
In the past, pppd was working normally during pppoe. It should be noted that pppd is OK. The key is how to use pppd for dialing. I feel it is a good idea to use scripts. I have referenced some of them and they are not easy to use. Suddenly, since wvdial can run, I copied its pppd parameter. Wvdial initializes the modem by myself. I use chat to initialize the modem. The following is my dialing script:
#! /Bin/sh
Modem = $1
Speed = $2
Telnumber = $3
User = $4
Pwd = $5
If [-Z $ modem];
Then
Modem =/dev/ttyusb1
Fi
If [-Z $ speed];
Then
Speed = 115200
Fi
If [-Z $ telnumber];
Then
Telnumber = #777
Fi
If [-Z $ user];
Then
User = card
Fi
If [-Z $ PWD];
Then
Pwd = card
Fi
Chatfile =/etc/PPP/mychat
Optfile =/etc/PPP/options
Papfile =/etc/PPP/PAP-secrets
# Make chat script/etc/PPP/mychat
Echo abort \ "busy \"> $ chatfile
Echo abort \ "no carrier \"> $ chatfile
Echo abort \ "No dialtone \"> $ chatfile
Echo timeout 30 >>$ chatfile
Echo \ "\"> $ chatfile
Echo atz OK> $ chatfile
Echo \ "atq0 V1 E1 S0 = 0 \ & C1 \ & D2 + fclass = 0 \" OK> $ chatfile
Echo \ "atdt $ telnumber \" Connect >>$ chatfile
Chmod + x $ chatfile
# Update options file
MV $ optfile. Bak
Echo lock> $ optfile
Echo modem> $ optfile
Echo crtscts> $ optfile
Echo defaultroute> $ optfile
Echo UseHostName> $ optfile
Echo \-Detach> $ optfile
Echo user $ user >>$ optfile
Echo noipdefault> $ optfile
# Echo remotename ppp0> $ optfile
Echo debug> $ optfile
Echo idle 0 >>$ optfile
Echo connect \ "chat-v-S-F $ chatfile \"> $ optfile
# Echo demand> $ optfile
Echo usepeerdns> $ optfile
# Echo persist> $ optfile
Echo kdebug 1> $ optfile
Echo $ speed> $ optfile
# Update pap-secrets
MV $ papfile. Bak
Cat $ papfile | grep-V "^ $ {user}"> $ papfile. New
Echo "$ {user} * $ {PWD}"> $ papfile. New
MV $ papfile. New $ papfile
# Dialup
Killall-9 pppd
Killall-9 chat
Mkdir-P/var/lock
Mkdir-P/var/log
Pppd $ modem $ speed
Disconnect kill pppd directly, but note that it is kill-15 to send the sigterm signal.
$ Killall-15 pppd
The problem still exists: you cannot dial again after disconnection. You must unplug the card and re-plug it.