«

»

Aug 19 2009

Getting a USB Modem to work on Linux

Recently I had to get a Huawei USB modem to work on Linux. It was a Tata Indicom Photon+ modem and it is detected as a flash drive in windows and automatically installs its drivers in windows. First I tried it on Ubuntu, and the experience was what I had expected. Plug n Play! Just brilliant. But my project requirement was to get it to work on Fedora 9 and that was no easy task. When I plugged in my modem, Fedora recognized it as a flash drive , then as a cd rom but never a modem.

Now in Windows, while the same thing happened but the modem drivers present on the flash drive made sure that the the device was switched from flash drive mode to the modem mode. No such  things seemed to be present in Fedora. So after an hour or so of searching on the net, trying out various options, this is what I came up with.

Plug in your modem. Let it be recognized as a flash drive. Once that is done do lsusb. The out put will be something like this:

Bus 001 Device 001: ID 1d6b:0002
Bus 003 Device 001: ID 1d6b:0001
Bus 002 Device 002: ID 12d1:140b Huawei USB Device
Bus 002 Device 001: ID 1d6b:0001

Now the first number here is the vendor id (0x12d1) and the second one (0x0140b) is product id. These numbers will differ depending on the make and model of your modem.

Now do an su, and then:

modprobe usbserial vendor=0x12d1 product=0x140b

Now you need to install a software known as usb_modeswitch. You can get it here. Installation is a breeze. Once installed:

usb_modeswitch -v 0x12d1 -p 0x140b -H -W

My modem was a Huawei Modem, so I chose -H for huawei mode. You could look into the /etc/usb_modeswitch.conf to try out various permutations for your modem. Now this command inevitably gives an error for the first time. So give it again and then it works :)

Now try an ls /dev/ttyU* and you should be able to see at least one device, or may be more.

Now its time to configure the settings. Do wvdialconf and a file would be generated (/etc/wvidal.conf). Open it and modify the phone number (usually #777 for CDMA networks) and then username and password.

Now just do a wvdial and you should be connected within seconds.

24 comments

1 ping

  1. Ajay

    This works. But my problem is when I disconnect (killall pppd) , next time it doesn’t connect to server(I mean it doesn’t create ppp0 interface). I need to restart my machine to connect.

    1. Abhishek

      Which Linux distribution are you on? In my opinion, you can try two things. First, not to kill the daemon with the kill command but properly disconnect it with Ctrl+C signal. Second, If it still does not work, you could take out the card and put it back in, instead of rebooting the system.

  2. balaji

    hi i am able no connect tata photon using these steps. i need to connect two tata photons using the above steps.but when i do it its dialing through ttyusb0 only and not through other one. and am not able to get two ips….
    please help me out…

    through my observation i found that we use the vendor id and product id so when we use two tata photons the both ahs the same vendor and product id.so is there anyother way?

    1. Abhishek

      Even if you are using more than one modems on the same system, the usb modeswitch software should take care of all of them, if they are from the same vendor. What you need to do is to configure the file /etc/wvdial.conf accordingly. For example :
      [Dialer Defaults]
      Modem = /dev/ttyUSB0
      Baud = 230400
      Phone = #777

      [Dialer card2]
      Modem = /dev/ttyUSB3

      This is just a scratch configuration. Please add the desired data from your wvdial.conf. Then you can use “wvdial” command for connecting with /dev/ttyUSB0 and “wvdial card2” for conecting with /dev/ttyUSB3 or whatever your card number might be.

      1. balaji

        hi do need to add the two dialer cards in the same wvdial.conf?

        the problem that i faced while using the two tata photons of same vendor and product ids is that when follow the steps mentioned by and then try getting two different ip for two tata photons am not able to get the two ips for two modems..

        1. Abhishek

          Yes, u need to add two cards in the same wvdial.conf with different names. Then when u connect, you can use “wvdial name1″ and “wvdial name2″ for getting two ip addresses.

          1. balaji

            ok i will try and post the result.Thanks for your support

  3. Sofia

    Hi,

    I need to connect tata photon in blackfin processor in uclinux environment.
    Is there any software for that like usb_modeswitch to detect the modem.
    Please post if there is any..

    1. Abhishek

      I have not worked on uclinux. But as you have the source code for usb_modeswitch, so you can use it to build an executable for uclinux too. You might need to modify the code to a small extent though.

  4. balaji

    hi one more help….
    can we use the usb_modemswitch fin uclinux too?

    1. Abhishek

      theoretically yes. if we have a proper build environment for uclinux, we should be able to compile it and use the executable just like fedora or any other distribution.

      1. balaji

        hi i added two cards in tthe wvdial.conf file but i am getting only one device and not able to dial the new added devicea nd neither getting two ips for the two tata photons….what shall i do?

  5. balaji

    *for uclinux.

  6. balaji

    thanks for ur support..

    hi i have dialed one tat photon perfectly.now i am trying to dial two tata photons at the same time, as per your suggestion i have modified the wvdial.conf file . But i am able to connect to only one device at a time.
    i hav pasted the config file below
    [Dialer Defaults]
    Modem = /dev/ttyUSB0
    Baud = 460800
    Init1 = ATZ
    Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
    Init3 = AT+CRM=1
    Stupid Mode = 1
    ISDN = 0
    Modem Type = Analog Modem
    Phone = #777
    Username = internet
    Password = internet
    then for the 2nd device i followed the same procedure, but it fails
    error message Voice line detected..
    i hope that im gettin this error due to same Vendor and Product ID to dial.
    help me is there anything i should work on USB_MODESWITCH.c code.

    give me some suggestions..

    thanks

    1. balaji

      its working fine with two usb devices and able to dial two devices,got two different ip address…

  7. loans

    Very good post. You write verry good, keep up the good work and I will keep on visiting!

  8. Sukanya

    Hi,

    I need to connect tata photon on blackfin in uclinux platform.
    but i am facing difficulties when i try to cross compile usb_modeswitch with bfin-uclinux-gcc compiler. And tell me how to cross compile wvdial also..
    need ur suggestion.

    Sukanya

  9. Mulch Hockessin de

    outstanding post! great advice, will take on board!

  10. ravi

    Thx abhisek singh for ur wonderful post. I point out one small error(not sure I am a beginner in ubuntu) the line U had posted is
    usb_modeswitch -v 0×12d1 -p -x140b -H -W, I had corrected as
    usb_modeswitch -v 0×12d1 -p -0x140b -H -W U just missed one zero I think so

    1. Abhishek

      thanks. corrected!

  11. neil dsouza

    HI Abhishek,

    excellent post. I have just got my photon working on ubuntu linux 9.10

    Just some notes – which you may edit or delete

    1. when the guy came for the demo he used his modem which was an epi valley or something. at that time it created a device /dev/ttyACM0
    however when i was given my own device it was a huawei. and created a /dev/ttyUSB0
    2. when I ran wvdialconf , it did not detect the baud rate correctly -
    partial output below
    ————————————————-
    WvModem: Cannot get information for serial port.
    ttyUSB0: ATQ0 V1 E1 — OK
    ttyUSB0: ATQ0 V1 E1 Z — OK
    ttyUSB0: ATQ0 V1 E1 S0=0 — OK
    ttyUSB0: ATQ0 V1 E1 S0=0 &C1 — OK
    ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
    ttyUSB0: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 — OK
    ttyUSB0: Modem Identifier: ATI — Manufacturer: +GMI: HUAWEI TECHNOLOGIES CO., LTD
    ttyUSB0: Speed 9600: AT — OK
    ttyUSB0: Max speed is 9600; that should be safe.
    ———————————————–
    I was a bit discouraged, however there is a tata document on their website for getting this to work on linux. so I put those settings – including “stupid mode=1″ , changed the baud rate to 230400 and it worked.

    Thanks again

  12. NEIL SEQ

    I use UBUNTU 9.1.0 sugggest some help. i am Newbie in Linux

  13. hcg diet tips

    I haven¡¦t checked in here for a while since I thought it was getting boring, but the last several posts are great quality so I guess I will add you back to my daily bloglist. You deserve it my friend :)

  14. Jill Langous

    Greetings from New Farm. Thanks for the useful content. I’m doing a project at school and your stuff was quite useful. Thanks for sharing :)

  1. Tataphoton+ and Linux « Suresh Kanzariya

    [...] is very straight forward Article about getting usb modem to work on linux. The most annoying part is usb_modeswith utility. Download [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>