How to interface 3G usb modem to any ARM (Android / linux ported) Board.
Hi I am now going to provide quick steps to interface the 3G usb modem to linux/ Android SBC which i have tried during my try which is successful one.
More and more USB devices when plugged in for the first time they act like a flash storage and start installing the driver from there. After installation (and on every consecutive plugging) the driver switches the mode internally, the storage device vanishes (in most cases), and a new device (like an USB modem) shows up.
Few modems (Huawie) most of time they do not need to switch from mass storage to usb modem mode. When you connect that modem to USB port then it will be detected as ttyUSB (3 ttyUSB ports are detected). Otherwise you need to switch the mode of usb modem by using usb_modeswitch utility (I am giving examples of idea modem / reliance modem which are from Huawei and a dlink 3G modem which requires usb modeswitch).
Follow the steps to make it successful.
1. Get the usb_modeswitch binary for your board. Or if it is not available then get the source code and cross compile it and then put the binary in /bin directory.
2.While compiling the kernel for board confirm that you have enabled as below
use make menuconfig to enable these drivers
Device Drivers ---> USB Support ---> [*] USB Serial Converter support ---> [M] USB driver for GSM and CDMA modems Device Drivers ---> Network device support ---> [*] PPP (point-to-point protocol) support [*] PPP support for async serial ports
Device Drivers --> USB Support --->
[*] usb modem (CDC ACM )support
You can make them modular also if you want [M]
3. Compile your kernel for the board and put newly generated uImage on board.
4. Also copy the usb_modeswitch into /bin directory.
5. Now time to make the modem work
For the modems that directly gets detected as ttyUSB devices create the following chat script
vi /etc/ppp/peers/idea-grps
TIMEOUT 10 ECHO ON ABORT '\nBUSY\r' ABORT '\nERROR\r' ABORT '\nNO ANSWER\r' ABORT '\nNO CARRIER\r' ABORT '\nNO DIALTONE\r' ABORT '\nRINGING\r\n\r\nRINGING\r' '' \rAT TIMEOUT 12 OK ATE1 OK 'AT+cgdcont=1,"IP","internet","",0,0' OK ATDT*99#\ CONNECT
or for reliance
vi /etc/ppp/peers/reliance-grps TIMEOUT 10 ECHO ON ABORT '\nBUSY\r' ABORT '\nERROR\r' ABORT '\nNO ANSWER\r' ABORT '\nNO CARRIER\r' ABORT '\nNO DIALTONE\r' ABORT '\nRINGING\r\n\r\nRINGING\r' '' \rAT TIMEOUT 12 OK AT OK ATD#777 CONNECT
save these above scripts on board at the specified locations.
Now in order to make it work we need to issue these commands to the usb modem which is now detected as /dev/ttyUSBx.
6. Now run the following pppd command to make them work for internet connection
for idea-gprs
$pppd /dev/ttyUSB0 460800 modem connect "/system/bin/chat -v -f /etc/ppp/peers/idea-grps" defaultroute nodetach ipcp-accept-remote novj mru 1500 mtu 1500 noipdefault usepeerdns user "" password "" &
for reliance
pppd /dev/ttyUSB0 115200 modem connect "/system/bin/chat -v -f /etc/ppp/peers/reliance_gprs" defaultroute nodetach ipcp-accept-remote novj mru 1500 mtu 1500 noipdefault usepeerdns user "<your username>" password "<your password>" &This will give commands over ttyUSB port and after success you are ready to browse the internet.
7. Now the case in which the modem gets detected as mass storage device you need to first use usb_modeswitch to switch it to modem mode.
8. I have tried Dlink 3 G modem for this.
Insert the 3G modem into board.
make this script
#!/bin/sh
mount -t usbfs usbfs /proc/bus/usb
usb_modeswitch -v <vid of modem>-p <pid of modem> -M "5553424312345678000000000000061b000000020000000000000000000000"
echo "<vid pid>" > /sys/bus/usb-serial/drivers/option1/new_id
sleep 10
pppd /dev/ttyUSB 115200 modem connect "/system/bin/chat -v -f /etc/ppp/peers/grps" defaultroute nodetach ipcp-accept-remote novj mru 1500 mtu 1500 noipdefault usepeerdns user "<if any >" password "<if any>" &
9. Execute this script by making changes as per vid and pid and service provide (for chat script).
10. Now you will be able to browse the internet.
I have tested this procedure on devkit and pandaboard. Hope these are brief but important steps for you. If anything remained kindly have suggestions over it.
Thanks ,
Shrenik.
Comments
Post a Comment