This article was reproduced from: http://blog.csdn.net/hanmengaidudu/article/details/17028383
Introduction to a development environment
ubutun 10.04
Content & nbsp , &NB SP; |
|
3G module |
em820w ( WCDMA) |
3G SIM card |
China Unicom 3G card |
Embedded Linux version |
&nbs P linux-2.6.37 |
Host development environment |
Two main steps
1 |
Support for adding 3G module drivers (option drivers for USB to serial ports) and PPP network protocols to the Linux kernel |
&NBS P , &NB Sp 2 &N Bsp , &NB Sp , &NB Sp , &NB Sp |
Cross-compiling ppp-2.4.4 source code Copy the two applications PPPD and chat required for dial-up Internet to the Development Board/usr/sbin folder, Write PPP dial scripts WCDMA, Wcdma-chat-connect, wcdma-chat-disconnect and stored in the/etc/ppp/peers directory. Writes DNS to the/etc/resolv.conf file |
3 |
Perform the "PPPD call WCDMA" command to Dial |
Three configuration 3G module driver and PPP network protocol stack
First go to make Menuconfig interface
1 Configuring 3G Module drivers
Figure 1
1 First select Device Drivers
Figure 2
2 Entering USB support
Figure 3
Go down to USB support until you find Figure 3 and select USB to serial port
Figure 4
Finally select USB driver for GSM and CDMA modems to this 3G card driver has been added complete
The main additions are driver/usb/serial/option.c and driver/usb/serial/usb_wwan.c.
Two files, although the driver has been added, but this is only a USB-to-serial driver, and can not be used as a network device directly, at this time need to support the PPP network protocol, he will ttyusb* and other devices to simulate the use of network equipment (/dev/ttyusb0<----> PPP0)
2 Adding PPP protocols
Also enter make Menuconfig interface
Figure 5
The first is also to enter the driver configuration Interface Device Drivers
Figure 6
6 Select Network Device Support
Figure 7
7 Choosing PPP
Both drivers and protocols have been configured successfully. The next step is to compile and download to the board.
Log in to Linux, DMESG view kernel printing information
Figure 8
While viewing the/dev/directory, you have created
/dev/ttyusb0,/dev/ttyusb1,/dev/ttyusb2,/dev/ttyusb3,/dev/ttyusb4,/dev/ttyusb5
7 device files such as/DEV/PPP indicate that the kernel correctly identifies the EM820W3G module
Four writing PPP dialing scripts
Because the dial-up script needs to use CHAT,PPPD, such as commands, you need to download ppp-2.4.4
After the download is successful, the first is compile
1 Compiling ppp-2.4.4
./configure
Make CC=ARM-NONE-LINUX-GNUEABI-GCC
After the compilation is successful, the compiled generated chat,pppd,pppdump and other commands are copied to the/usr/sbin directory of the board file system.
2 Writing a dial-up script
Create three files below the/etc/ppp/peers directory of the board file system below
Wcdma,chat-wcdma-connect,chat-wcdma-disconnect
WCDMA Configuration file Contents
Debug
Nodetach
/dev/ttyusb0
115200
Usepeerdns
Noauth
Noipdefault
Novj
Novjccomp
Noccp
Defaultroute
Ipcp-accept-local
Ipcp-accept-remote
Connect '/usr/sbin/chat-s-v-f/etc/ppp/peers/chat-wcdma-connect '
Disconnect '/usr/sbin/chat-s-v-f/etc/ppp/peers/chat-wcdma-disconnect '
Wcdma-chat-connect Configuration file Contents
TIMEOUT 5
ABORT ' NO CARRIER '
ABORT ' ERROR '
ABORT ' Nodialtone '
ABORT ' BUSY '
ABORT ' NO ANSWER '
"' \rat
OK \ratz
Ok \rat+cgdcont=1, "IP", "3GNET", 0,0
Ok-at-ok atdt*99#
CONNECT \d\c
Wcdma-chat-disconnect Configuration file Contents
ABORT "ERROR"
ABORT "Nodialtone"
SAY "\nsending break to the modem\n"
"\k"
"+++ath"
SAY "\ngoodbay\n"
After the dial script is created, it's officially dialed.
PPPD Call wcdma&
(plus the & symbol is mainly because after the successful dial, the program will continue to do not quit, so the use of the background to run, if there are multiple 3G cards may produce multiple ttyusb* device files, and will require multiple WCDMA files at this time can use PPPD call WCDMA1 to PPP dialing for 3G Module 1), PPPD call WCDMA is the role of establishing protocols and generating network interfaces Ppp0
The dial success will appear as shown in printing
Figure 9
After 9 printing appears, add the DNS address vi/etc/resolv.conf in the middle of the/etc/resocv.conf, adding content:
NameServer 202.99.160.68
NameServer 202.99.166.4
Use Ifconfig–a to see if there are ppp0 network devices
Finally, test whether the PPP0 network device can be used
Ping–i ppp0 www.baidu.com
The ability to ping means that the 3G card transplant driver is successful
At this stage the 3G card driver has been ported
Five commissioning
There have been many problems when porting the drive
1 PPPD call WCDMA invocation failed
[Email protected]:~# pppd Call wcdma&
Timeout set to 5 seconds
Abort on (NO CARRIER)
Abort on (ERROR)
Abort on (NO dialtone)
Abort on (BUSY)
Abort on (NO ANSWER)
Send (^MAT^M)
Expect (OK)
At^m^m
Ok
--Got It
Send (^MATZ^M)
Expect (OK)
^m
Atz^m^m
Ok
--Got It
Send (^mat+cgdcont=1, "IP", "3GNET",, 0,0^m)
Expect (OK)
^m
At+cgdcont=1, "IP", "3GNET", 0,0^m^m
ERROR
--Failed
Failed (ERROR)
Connect script failed
Call At+cgdcont=1, "IP", "3GNET", 0,0^m^m
This command failed, in order to test the serial port (command send channel) whether the normal use
Add several other at commands in the middle of the Chat-wcdma-connect
such as OK \rat+cgmi (manufacturer certification request, return module manufacturer information)
OK \RAT+CGSN (view product IMEI serial number)
Then the PPPD call wcdma& Discovery plus the few at commands that are going to execute normally
This means that it is possible that the em820w module does not correctly identify the SIM card
Later I added the OK \rat+csq instruction (view network signal quality) discovery will fail
The preliminary conclusion is that all the at instructions involved in the SIM card will fail, and the other can be executed successfully, which means that the data between the board and the em820w module can be correctly interacted with.
Also due to the failure of the em820w to identify the SIM card, the execution of the instructions failed
Later consulted the relevant personnel, said that my test method is not correct, I use the PPPD program to determine whether certain commands can be executed properly, so that can not be ruled out the PPPD program can resolve the interference caused by the command, so instead of using a more pure method to test
cat/dev/ttyusb0&
echo "AT+CGSN" >/dev/ttyusb0
echo "At+cgmi" >/dev/ttyusb0
echo "AT+CSQ" >/dev/ttyusb0
Observe the response of the serial port and PPPD call WCDMA
So I still think that em820w did not correctly identify the SIM card (but in the future testing still need to choose the right method)
Test the SIM card circuit 5 signal lines regardless of whether there is a SIM card, 5 lines each performance is the same, this means that the SIM card is not recognized, and SIM_VCC and sim_reset the timing of the same, this is not the same as the time series posted on the web, it is obvious that the reset signal is slower than VCC half beat
Figure 10
Figure 10
The hardware engineer modifies the circuit at this time, adding a large capacitor to the sim_reset line, adding a little delay
The PPD call wcdma& is then called
The dial was found to be successful, and a PPP0 network device was present with the Ifconfig–a command
Then test using Ping–i ppp0 www.baidu.com to find that the network is not
Oh, that's a lot.
2 Network not through
Network is not the problem from the beginning to feel sure with the card is not related, it is possible that the network itself, in order to exclude Ethernet port eth0 Interference I conducted the following test
Ifconfig eth0 Down
PPPD Call wcdma&
Ifconfig eth0 up
Ping–i www.baidu.com
After the above toss incredibly network also pass, magical.
Internet query says it is a routing problem caused by dual NIC
Sure enough, when the ppp0 doesn't work, the route command finds the routing table as follows
# route
Kernel IP Routing Table
Destination Gateway genmask Flags Metric Ref useiface
10.64.64.64 * 255.255.255.255 UH 0 0 0 ppp0
192.168.7.0 * 255.255.255.0 U 0 0 0 eth0
Default 192.168.7.1 0.0.0.0 UG 0 0 0 eth0
The routing table is as follows when the Ppp0 pass
# route
Kernel iprouting Table
Destination Gateway genmask Flags Metric Ref use Iface
10.64.64.64 * 255.255.255.255 UH 0 0 0ppp0
192.168.7.0 * 255.255.255.0 U 0 0 0 eth0
Default * 0.0.0.0 U 0 0 0 ppp0
From above can know ppp0 not pass because the default route is eth0, this certainly does not make sense
Six notes
Android 3G porting "Go"