Huawei E160 Linux

A friend of mine came to me with an interesting problem: connecting a 3G mobile broadband adapter to their Linux-powered computer via USB. The adapter in question, a Huawei E160G (as provided by 3 UK∞), was not recognised by the system as by default. After a significant amount of trial and error, I finally figured out what needs to be done to configure and connect the modem.

EDITOR’S CHOICE

The system in question here is Ubuntu 8.04 (x86). It’s assumed that you are logged into Gnome with apt/Synaptic package manager available, and root/superuser privileges on the system. You will not be able to continue without root privileges. It is also expected that you have a relative understanding of Linux terminal use including navigating directories, superuser privileges and software installation/compilation. It may be that certain parts of this tutorial will need to be adapted to suit your system, just as it may be that this will work for you step-by-step as-is. Note that I’m not responsible (and cannot be held responsible) for any problems that arise from following this tutorial. You are doing so at your own risk, and if you’re not sure what you’re doing, make sure you’ve backed up anything that is important before starting.

The Huawei E160 is interesting for a number of reasons, two of which being the built-in flash storage containing device drivers, and the addition of an optional microSD card slot (so that the device can double up as a USB memory stick, in theory). However, the fact that the internal flash containing drivers is present causes some problems, most notably because the USB device is first recognised as being flash storage before it is recognised as a modem. In fact, before the modem will be correctly recognised, the USB device must be “switched” so that it is in the correct mode.

1. Check that the adapter is recognised by the system. Upon connecting the device, wait for the signal to be found (normally signalled when the green light stops flashing and turns blue) and then a significant amount of activity should take place in the kernel debug messages. Check this using sudo dmesg in the terminal of your choice. Secondly, some new USB devices should appear in your /dev tree, notably /dev/ttyUSB0 and /dev/ttyUSB1.

There are two devices here for an interesting reason. One is the modem interface, and the other is the “PCUI” interface which feeds back data during connection about the current state of the connection. It is used by monitoring software without blocking the modem port. However, because of the lazy nature of Linux’s /dev tree (which may be fixed with udev) it is not clear which interface has been assigned to which /dev/ttyUSB node. It’s not important to worry about this, though, since the software will autodetect the correct modem port later on.

One thing that is certain, though, is that before the nodes will act properly, we need to switch the device so that it is no longer acting as a type of flash storage. To accomplish this, we use software called usb_modeswitch.

2. Start by ensuring that two vital prerequisites are installed: the “devel” libc++ and libusb. On Ubuntu, this is generally very easy, since you can simply install these using the Synaptic Package Manager interface. Search for “libusb” and “ilbc++-devel” and install both of them if they are not already installed. Alternatively use sudo apt-get install in terminal.

3. Next, pay a quick visit to the usb_modeswitch download page∞ and download the most recent .tar.bz2 archive. Once downloaded, extract the archive to a convenient location.

4. Once you’ve made sure that libc++ and libusb are installed, installing usb_modeswitch is generally very easy. Open up a terminal, navigate to your usb_modeswitch folder and execute the following command to build and install the program:

gcc -l usb -o usb_modeswitch usb_modeswitch.c
sudo cp usb_modeswitch /usr/local/bin/usb_modeswitch

This moves usb_modeswitch into your /usr/local/bin directory so that it can be used by the system.

5. Next up, we need to configure usb_modeswitch. Download a copy of the most recent configuration file∞ and then place it into /etc/usb_modeswitch.conf. This is a heavily commented file containing directives that apply to a wide number of adapters, so that you can edit the file uncommenting (removing the semi-colons from) the lines that apply to your modem. This file, upon first appearance, does not contain lines specific for the Huawei E160. However, the E160 is pretty much directly compatible with the E220 that the file does contain directives for. So, open the file in your favourite editor, search for “E220″ and uncomment the lines so they look like this:

########################################################
# Huawei E220 (aka “Vodafone EasyBox II”, aka “T-Mobile wnw Box Micro”)
# Huawei E270
# Huawei E870
# and probably most other Huawei devices (just adapt product ID)
#
# Two options: 1. removal of “usb-storage” 2. the special control
# message found by Miroslav Bobovsky
#
# Contributor: Hans Kurent, Denis Sutter

DefaultVendor= 0×12d1;
DefaultProduct= 0×1003

# choose one of these:
;DetachStorageOnly=1
HuaweiMode=1

Once done, you can save the file and exit the editor. You’ve set up usb_modeswitch.

6. Now, we’ve got the necessary software installed to initialise your modem, but we don’t have anything to actually create your connection. This is where the next and final piece of software becomes involved: wvdial. This is a program that creates modem connections, except it uses a relative amount of intelligence to configure itself. To install you can either return to Synaptic package manager and search “wvdial” and install, or run the following in terminal:

sudo apt-get install wvdial

You will be asked to type your password here to authenticate, so do so and then press Enter.

Complete the configuation by editing /etc/wvdial.conf so that the phone number is *99# by updating/placing the following line into the [Dialer Defaults] section:

Phone = *99#

7. Once wvdial has installed, it should be a relatively simple procedure to connect. Should everything have gone to plan, you should be able to type the following into your terminal to connect:

sudo usb_modeswitch
sudo wvdialconf
sudo wvdial

Enter your password if prompted, and with any luck, this should create a new ppp device and connect you to the Internet. If it doesn’t work, then check your /etc/wvdial.conf file and make sure it is set to dial *99#. The wvdialconf command there probes your USB devices and attempts to automatically configure your configuration file so that it automatically matches your current modem configuration. The wvdial command after it finally makes the connection.

Repeat this stage in the future to connect to the Internet again. The rest of the configuration will stay intact and will not need to be repeated.

This is a relatively simple tutorial explaining how a typical setup procedure should work with a Huawei E160G on a relatively clean install of Ubuntu 8.04, however, this may not cover all system configurations. Even on this configuration, I cannot guarantee it’ll work for everyone. If you experience trouble and you are not using Ubuntu 8.04, please do not leave comments on this page saying that these instructions are not working. You may well need to adapt any number of stages of this procedure in order to make it work.

Even having configured wvdial to connect correctly, I have still yet to find a suitable GUI method for connecting the modem to the Internet, especially as Network Manager did not detect or connect the device successfully, even after mode switching. This terminal method is functional but not necessarily user-friendly, so any suggestions on how to weave this into a user interface would be welcome.

Possibly Related Posts:


 

5 Responses to “Huawei E160 Linux”

  • pdc_2

    you mention a GUI for wvdial; as an alternative
    on this post (post #2 Montyzdog)
    http://forum.eeeuser.com/viewtopic.php?id=11376
    they suggested using X-ISP which has debian and rpm packages;
    http://xisp.hellug.gr/
    I am trying to help my daughter, who is overseas in Australia, get connected to the internet using her Xandros ASUS and a Huawei 160G stick;
    I too have an ASUS and as a trial I have successfully downloaded and installed X-ISP;
    now I need to try to understand how to configure X-ISP for a Huawei 160G

    [Reply]

  • daniel

    u can put those final commands that establish the connection in a shell script, and then create a shortcut on the desktop that would contain the path to that script as command to run

    [Reply]

  • Hi, you say you’re looking for a suitable way to do tjis connection rather than using console, which is the coolest and hackiest way to go.

    I found out that KPPP is a very nice solution, I’m using Fedora 11, I followed your guidelines and got it up’n'running in some minutes.

    Anyway I just opened kppp and clicked Configure and then created an account using default info provided vy Movistar my carrier and used *99# as phone number, went to Modem tab and looked for /dev/ttyUSB0, selected it, changed the DNS nameservers to OpenDNS’, and left the other setting pretty untouched, then put username/password and hit connect and there I go, “connected”.

    Tjhe only bad thing is that I cannot get pings lower than 280-450 ms and the connection is according to Movistar 1MBits, I’d like to know how to make Movistar Desktop work Under my distro but it’s off-topic here so…

    Anyway thanks for your tutorial, for those interested here’s my wvdial.conf

    [Dialer Defaults]
    Modem = /dev/ttyUSB0
    Baud = 460800
    Init1 = ATZ
    Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
    Init3 = AT+CGDCONT=1,”IP”,”internet.movistar.com.co”
    Modem Type = USB Modem
    Area Code =
    Phone = *99#
    ISDN = 0
    Password = movistar
    Username = movistar
    Modem = /dev/ttyUSB0
    Ask Password = 0
    Dial Command = ATD
    Stupid Mode = 1
    Compuserve = 0
    Force Address =
    DialMessage1 =
    DialMessage2 =
    ISDN = 0
    Auto DNS = 0

    [Reply]

  • Lex

    The original link to this article is http://frozenriver.net/HuaweiE160Linux, just so that it’s credited properly.

    [Reply]

    brooks Reply:

    That’s great !Welcome to Huawei!

    [Reply]

Trackbacks

  •