Use of USB modem in embedded Linux

Source: Internet
Author: User
I. ARM-LinuxARM-Linux-2.6.173GUSBModem: huaweiE220 (WCDMA), huaweiEC156 (EVDO) arm-linux at least need to support USB host, USB storage, usb fs, USB serial II. linux driver option. option in clinux. c is. ARM-Linux
ARM-Linux-2.6.17
3g usb Modem: huaweiE220 (WCDMA), huaweiEC156 (EVDO)
Arm-linux must support at least usb host, usb storage, usb Fs, and usb serial
 
II. Linux driver
Option. c
In linux, option. c is the driver for 3G modem. you can modify it to support most of the 3G usb modem.
Currently, the USB Option PCMCIA serial driver of my current version depends on USB_SERIAL & USB_OHCI_HCD & PCCARD. therefore, make sure you have selected these three options. if the host is different, you can modify the dependency of USB_OHCI_HCD on your own. I have modified this dependency because I currently use the isp chip. In short, usb host is required.
Add the following sub-item to the option_ids array:

1. # define wei_product_e220 0x1003
2. # define wei_product_ec156 0x140c
1. {USB_DEVICE (required wei_vendor_id, required wei_product_e220 )},
2. {USB_DEVICE (incluwei_vendor_id, incluwei_product_ec156 )},
III. tools
Usb_switchmode-1.2.4
This is the latest version. This tool is used to convert the 3g usb modem identified as a storage device by default to multiple serial devices that can communicate with each other for ppp dial-up connections.
This tool depends on linusb, all of which are cross-compiled ,.
1. download and cross-compile libusb-0.1.12:


./Configure -- build = i686-linux -- host = arm-linux -- prefix = $ PWD/install


Make


Make-n install (confirm the installation directory)


Make install
Now, libusb compilation is complete.
2. cross-compile usb_switchmode
Modify makefile:


Cc = arm-linux-gcc


Export dedir =/home/jay/tools/3G/libusb-0.1.12/install/include


LIBDIR =/home/jay/tools/3G/libusb-0.1.12/install/lib





$ (CC)-I $ (INCLUDEDIR)-L $ (LIBDIR)-o $ (PROG) $ (OBJS) $ (CFLAGS) $ (LIBS) $ (LDFLAGS)-static


Make


Successful, so far the static compiled usb_switchmode is obtained
 
3. move usb_switchmode to the arm linux file system, and copy the usb_switchmode.conf folder to the/etc/directory in arm linux. There are many configuration files for 3g usb modem.



4. pppd dialing software
Port pppd2.4.5


./Configure


Make CC = arm-linux-gcc


What is needed is: pppd chat pppdump pppstats executable programs pppd, chat, pppdump, pppstats
Create the/etc/ppp/peers folder in the embedded file system.
 
4. use
When a 3g usb modem is inserted, it is identified as a usb flash drive by default. in this case, the usb _ switchmode tool is used for conversion and is bound to multiple serial ports,
Usb_modeswitch-W-c/etc/usb_modeswitch.d/12d00001505
Among them,-W only displays detailed configuration information.-c refers to the specified configuration file. the configuration file that comes with usb_switchmode seems to be more or less problematic to be used in embedded systems. you must specify
DefaultVendor and defaproduct product parameters.
Usb 1-1: new full speed USB device using isp1362-hcd and address 8


Usb 1-1: configuration #1 chosen from 1 choice


Option 1-1:1. 0: Option 3G data card converter detected


Usb 1-1: Option 3G data card converter now attached to ttyUSB0


Option 1-1:1. 1: Option 3G data card converter detected


Usb 1-1: Option 3G data card converter now attached to ttyUSB1


Option 1-1:1. 2: Option 3G data card converter detected


Usb 1-1: Option 3G data card converter now attached to ttyUSB2


Option 1-1:1. 3: Option 3G data card converter detected


Usb 1-1: Option 3G data card converter now attached to ttyUSB3


Scsi6: SCSI emulation for USB Mass Storage devices
If you do not have a device node such as ttyUSB0, you can manually create it,
Mknod/dev/ttyUSB0 c 188 0
Mknod/dev/ttyUSB0 c 188 1
....
You can
Echo ATZ>/dev/ttyUSB0. if there is no error, the conversion is basically OK.
 
The last step is ppp dialing.
Currently, I use e220 in wcdma and ec156 in evdo. the dialing script is rarely different (the driver is just a bit different from the device number)
1. wcdma:

1. debug
2. nodetach
3. lock
4./dev/ttyUSB0
5. 115200
6. the user "14522023288"
7. password "******"
8. crtscts
9. show-password
10. usepeerdns
11. noauth
12. noipdefault
13. novj
14. novjccomp
15. noccp
16. defaultroute
17. ipcp-accept-local
18. ipcp-accept-remote
19. connect '/usr/sbin/chat-s-v-f chat-wcdma-connect'
20. disconnect '/usr/sbin/chat-s-v-f chat-wcdma-disconnect'


Chat-wcdma-connect:

1. TIMEOUT 5
2. ABORT 'no carrier'
3. ABORT 'error'
4. ABORT 'no dialtone'
5. ABORT 'busy'
6. ABORT 'no ancer'
7. ''/rAT
8. OK/rATZ
9. OK/rAT + CGDCONT = 1, "IP", "3 gnet", 0, 0
10. OK-AT-OK ATDT * 99 #
11. CONNECT/d/c


Chat-wcdma-disconnect:
[Html]View plaincopy
1. ABORT "BUSY"
2. ABORT "ERROR"
3. ABORT "no dialtone"
4. SAY "/nSending break to the modem/n"
5. ''"/K"
6. ''" ++ ATH"
7. SAY "/nGoodbay/n"
2. evdo

1. debug
2. nodetach
3. lock
4./dev/ttyUSB0
5. 115200
6. user "ctnet@mycdma.cn"
7. password "vnet.mobi"
8. crtscts
9. show-password
10. usepeerdns
11. noauth
12. noipdefault
13. novj
14. novjccomp
15. noccp
16. defaultroute
17. ipcp-accept-local
18. ipcp-accept-remote
19. connect '/usr/sbin/chat-s-v-f/etc/ppp/peers/chat-evdo-connect'
20. disconnect '/usr/sbin/chat-s-v-f/etc/ppp/peers/chat-evdo-disconnect'


Chat-evdo-connect:

1. TIMEOUT 60
2. ABORT 'no carrier'
3. ABORT 'error'
4. ABORT 'no dialtone'
5. ABORT 'busy'
6. ABORT 'no ancer'
7. ''/rATZ
8. OK-AT-OK ATD #777
9. CONNECT/d/c


Chat-evdo-disconnect:

1. ABORT 'no carrier'
2. ABORT 'error'
3. ABORT 'no dialtone'
4. ABORT 'busy'
5. ABORT 'no ancer'
6. SAY "/nSending break to the modem/n"
7. ''"/K"
8. ''" ++ ATH"
9. SAY "/nGoodbay/n"
Background dialing:
Pppd call wcdma &
Pppd call evdo &
Telecom ecdo looks like the account password must use ctnet@mycdma.cn vnet.mobi, not the phone number and the given password.
If the dial is successful, ifconfig shows ppp0.
Ppp0 Link encap: Point-to-Point Protocol


Inet addr: 183.43.180.134 P-t-P: 113.115.0.1 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: 70 (70.0 B) TX bytes: 64 (64.0 B)
Test network:
# Ping www.baidu.com


PING www.a.shifen.com (220.181.111.148): 56 data bytes


64 bytes from 220.181.111.148: icmp_seq = 0 ttl = 55 time = 91.3 MS


64 bytes from 220.181.111.148: icmp_seq = 1 ttl = 55 time = 105.3 MS


64 bytes from 220.181.111.148: icmp_seq = 2 ttl = 55 time = 93.9 MS


64 bytes from 220.181.111.148: icmp_seq = 3 ttl = 55 time = 98.9 MS


64 bytes from 220.181.111.148: icmp_seq = 4 ttl = 55 time = 95.4 MS
During ping, block other network nodes such as eth0: ifconfig eth0 down.
If the domain name cannot be resolved, most of them should be a dns problem. Originally, the ppp dns was automatically obtained, but the saved path is/etc/ppp/resolv. conf, but linux uses/etc/resolv. conf, so we can establish a soft connection:
Ln-s/etc/ppp/resolv. conf/etc/resolv. conf
So far, the use of 3G usb modem in embedded systems has come to an end.
 

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.