Search:  
Gentoo Wiki

Huawei_E220

Link title

Contents

Introduction

In what follows I will explain how to have the HUAWEI E220 HSDPA USB modem working on your gentoo system.

The following instructions are based on several documents I have found browsing the internet ( in particular, see [1], [2] and [3]) and on personal experimentation.

Hardware configuration

In order to have the modem functioning you need to have all necessary modules compiled in the Linux kernel. Moreover, you need to have the card properly recognized by these modules. This is not trivial because the HUAWEI E220 modem is in fact a device with a twofold nature: it is a modem but, at the same time, it is a USB storage device. The storage device contains the Windows drivers, so it's pretty useless for our purposes, but the dual nature can generate some trouble. We will deal with this in a later section

Kernel

In recent kernel (at least since version 2.6.23), the HUAWEI E220 modem is supported by the USB serial 'option' driver (option module). To use it, you also need the support for the PPP protocol and for asynchronous serial ports. To check if these drivers are compiled in the kernel, use

zgrep "CONFIG_USB_SERIAL_GENERIC" /proc/config.gz 
zgrep "CONFIG_USB_SERIAL_OPTION" /proc/config.gz

and

zgrep "CONFIG_PPP" /proc/config.gz 
zgrep "CONFIG_PPP_ASYNC" /proc/config.gz 

or check your kernel configuration (if you use genkernel it can be found in /etc/kernels/).

If the options are not set as a module (m) recompile your kernel with the following options activated:

Linux Kernel Configuration: Configuring
 Device Drivers  ---> USB Support ---> [M] USB Serial Converter support ---> [*] USB Generic Serial Driver
                                                                             [M] USB driver for GSM and CDMA modems
 
 Device Drivers  ---> Network device support  ---> [M] PPP (point-to-point protocol) support
                                                   [M] PPP support for async serial ports

If you say [M] for "USB Serial Converter support" and [*] for "USB Generic Serial Driver", you get the usbserial module.

[Comment not from original author] The USB Generic Serial Driver should be disabled altogether. When disabled, the modem will yield download speeds of above 64kb/s -- provided your ISP gives you the bandwidth (with the generic driver enabled, the download speeds are capped at 64kb/s). Without the Generic driver, there is no struggle to get the device into modem mode (see below) and no reboots are required when pppd dies or when the device is unplugged. Therefore, it is recommended to only use USB driver for GSM and CDMA modems as a module. Note: only /dev/ttyUSB[0,1] show (see below as well), which suggests that /dev/ttyUSB2 is not needed at all.

udev rules

Once these drivers are available, plug the USB cable and use

lsusb -v

to see if the modem has been properly recognized. You should see something like

File: lsusb output
  ... 
  idVendor           0x12d1
  idProduct          0x1003
  bcdDevice            0.00
  iManufacturer           1 HUAWEI Technologies
  iProduct                2 HUAWEI Mobile
  ...

In principle one can automatically load the option at boot time by inserting a line in /etc/modules.autoload.d/kernel-2.6). We will follow a more sophisticated approach: we create an explicit rule for udev. Create the file /etc/udev/rules.d/50-huawei.rules inserting the line

File: /etc/udev/rules.d/50-huawei.rules
  SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/sbin/modprobe option"
  SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/sbin/modprobe ppp_async"

In this way the module is loaded with the proper settings when the device is inserted, together with the proper ppp modules.

udevcontrol reload_rules

Then you need to unplug and plug again the USB cable. You should find at the end of your /var/log/messages something like

File: /var/log/messages
 
  ... option 5-1.2:1.0: GSM modem (1-port) converter detected
  ... usb 5-1.2: GSM modem (1-port) converter now attached to ttyUSB0
  ... option 5-1.2:1.1: GSM modem (1-port) converter detected
  ... usb 5-1.2: GSM modem (1-port) converter now attached to ttyUSB1

If this is the case, that is if three devices /dev/ttyUSB[0,1,2] have been created, your modem is ready to be used. You can jump to the software configuration section below. If instead you get only the /dev/ttyUSB0, you need some further hacking. Be aware, you may have /dev/sg[0,1,2] instead. See the next section. There is also a case in which you get two devices /dev/ttyUSB[0,1], this one is perfectly fine, and you can continue to use the modem.

Switching to modem mode

(WARNING: this is totally unneeded when using the option driver)

As mentioned before, the E220 modem has a dual nature: it is both a communication and a storage device. For some reason, sometimes under Linux the communication part is not fully recognized and the device is activated in its "storage" status. Luckily, however, somebody did already work out the solution. Here [4] you can find a little program by Miroslav Bobovsk√Ĺ called huaweiAktBbo. This program can be used to switch the E220 from "storage" to "modem" status.

HEADS UP: you may alternatively want to use sys-apps/usb_modeswitch from the official Portage tree instead. Please be aware it's currently marked ~arch (08/2008).

Download the source code, compile it and save the executable in the /usr/local/sbin/ directory

gcc huaweiAktBbo.c -lusb -o huaweiAktBbo
mv huaweiAktBbo /usr/local/sbin/

Now add a couple of lines to the previously prepared udev rule

File: /etc/udev/rules.d/50-huawei.rules
  SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/sbin/modprobe usbserial vendor=0x12d1 product=0x1003"
  SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/sbin/modprobe ppp_generic"
  SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/bin/sleep 10"
  SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/usr/local/sbin/huaweiAktBbo"

In this way the udev system automatically run the program huaweiAktBbo (after a suitable delay) to set the modem.

By unplugging and plugging again the device you can check that all three ttyUSB devices are now created.

Huawei E220 Installer for linux Refer to: http://greasy.com/mustakim/huawei_e220_linux_new_installer.html

This installer calls he220rc2 just for linux user that using Vodafon and Huawei E220 Usb Modem. It is the updates from previous e220rc1 version List of linux x86 that has been successfully tested:

OpenSuSE 10.2, 10.3, 11 Alpha 0-1-2 Fedora 7, 8, 9 Alpha Mandriva 2008.0 Sabayon Mini 2007 Ubuntu 7.10 (64bit), 8.04 Alpha 1-4 Kubuntu 7.10 Mint Daryna PclinuxOS 2007, 2008

What's news?

Fixed:

Get it free at:

Software Configuration

The HUAWEI E220 adapter works as a modem and relies on PPP to establish a connection. One can use any PPP management program. Several GUI programs are available for both KDE and Gnome. In what follows I stick with a bare-bone approach.

PPP

Just emerge the relevant software

emerge net-dialup/ppp

and create the following file which defines the connection parameters

File: /etc/ppp/peers/E220
 /dev/ttyUSB0
 460800
 crtscts
 modem
 noauth
 usepeerdns
 defaultroute
 noipdefault
 debug
 noccp
 nobsdcomp
 novj
 user "irrelevant"
 password "irrelevant"
 connect '/usr/sbin/chat -f /etc/ppp/chat-E220-pin || /usr/sbin/chat -f /etc/ppp/chat-E220-nopin'

Notice that we defined both an username and a password. Even if the values of these parameters are irrelevant, their presence seems to make the whole login procedure run smoother. Notice also that the previous file needs two chat scripts. This is due to the fact that the first time that the device is plugged in, one need to provide it the card PIN code. For subsequent connection this generate an error. Then create the needed scripts

File: /etc/ppp/chat-E220-pin
  ABORT BUSY
  ABORT ERROR
  ABORT 'NO CARRIER'
  REPORT CONNECT
  TIMEOUT 10
  "" "ATZ"
  OK "AT+CPIN=pin"
  OK AT+CGDCONT=1,"ip","internet"
  OK "ATE1V1&D2&C1S0=0+IFC=2,2"
  OK "AT+IPR=115200"
  OK "ATE1"
  TIMEOUT 60
  "" "ATD*99***1#"
  CONNECT \c

and

File: /etc/ppp/chat-E220-nopin
  ABORT BUSY
  ABORT ERROR
  ABORT 'NO CARRIER'
  REPORT CONNECT
  TIMEOUT 10
  "" "ATZ"
  OK AT+CGDCONT=1,"ip","internet"
  OK "ATE1V1&D2&C1S0=0+IFC=2,2"
  OK "AT+IPR=115200"
  OK "ATE1"
  TIMEOUT 60
  "" "ATD*99***1#"
  CONNECT \c

where pin is the PIN of your card (typically a four digit code) and internet is the Access Point Name (APN) of the service you use (for instance mine is "web.omnitel.it"). If you don't know the Internet APN, ask your service provider.

At this point you should be able to start the PPP connection using

pon E220

and stop it with

poff E220

DNS problems

I've noticed that The first time it is invoked, the connection script generate wrong names for the DNS servers. The same behaviour is reported here. If this is the case for you too, probably it is better to rely on some external DNS service. An excellent solution is provided by the Open DNS project. Simply remove from /usr/ppp/peers/E220 the option usepeerdns (or comment it prepending a '#'). Then, edit your /etc/resolv.conf and just add these lines somewhere near the top

File: /etc/resolv.conf
# Open DNS server
nameserver 208.67.222.222
nameserver 208.67.220.220

If you have several network device configured, however, it is likely that your /etc/resolv.conf get overwritten by the system. In this case the safest approach is to configure the DNS server in /etc/conf.d/net. Assuming the name of your interface is ppp0 add the following lines at the end of the file

File: /etc/conf.d/net
config_ppp0=( "ppp" )
dns_servers_ppp0=( "208.67.222.222" "208.67.220.220")

In this way a correct /etc/resolv.conf is generated automatically when the interface is switched on.

Warning: recently I've noticed that with Vodafone Italy the previous procedure does not work any longer. It seems you are somehow forced to use the DNS server provided by the peer.

Signal Quality

There is a small program on SourceForge which can be used to obtain various information, for instance the signal strength, from the modem Linux UMTS/GPRS command-line tool. However I have not tested it extensively.

Comments

In order to make this work, you have to initialize the modem once using a Windows machine, alternativly you may have some luck with Vodafone's open source driver I for my part was not able to get the E220 activated using this tutorial unless I entered the pin and puk using Windows. After that the chat-E220-nopin works fine. The chat-E220-pin script does not work for me at all, sorry to have to say this.

The scripts provided work perfectly for me, the script even handles the pincode well.

Retrieved from "http://www.gentoo-wiki.info/Huawei_E220"

Last modified: Wed, 01 Oct 2008 21:20:00 +0000 Hits: 24,707