Sunday, June 21, 2009

Huawei E160 and Ubuntu | E160 Linux Howto | Sun Broadband

huawei e160Tech Blog - I have been a subscription of Sun Broadband for couple of months now its a 3g Internet service in the Philippines, anyway with the subscription it came with a SIM and Huawei E160 3g USB modem dongle, the problem is I have couple of laptops that is running Mepis Linux and Ubuntu Linux as you might have known the program that came with the dongle doesn't work on Linux, another problem is that the Huawei E160 modem is quite unique as it act as a mass storage device like a flash disk which also one of the reason that Linux is having problem working with it.

This is a howto on getting the Huawei E160 modem to work on your Ubuntu and Mepis Linux or almost any Linux distribution, with this howto you are expected to have right to "root" priviledges, and you are expected to use the command for majority of this howto, a good undertsanding of shell command and basic scripting will also be very covenient for you int the long run, but is not a requirement lets begin.

What you will need:

libusb(developer) - You will need to make sure that libusb is installed on your Linux system, if your using Ubuntu or Mepis or Linux with Synaptic Package manager you can search and install libusb using it or use "apt-get" alternatively, you might also need to install libc++ in my case when I installed libusb it automatically installed libc++(developer) as dependencies, if your using rpm based Linux distri bution you might can search it using yum or up2date depends which one your using or you might want to download the tarball version or rpm version of it.

usb_modeswitch - You will need to download usb_modeswitch tarball package, this will be used to switch mode of your usb dongle from mass stroage mode to gsm modem mode, for you to connect to your carrier.

usb_modeswitch.conf - You will also need to download usb_modeswitch.conf the latest configuration file for usb_modeswitch.

wvdial - You will need a ppp dialing program that support ppp/chap, so download and install.


Step to making your Huawei E160 connect on you Linux systems

Step 1 - Plugin the Huawei E160 modem and After downloading usb_modeswitch.tar.bz you will need to extract the package and install.

$ tar -xjvf usb_modeswitch-0.9.7.tar.bz2
$ cd usb_modesswitch-0.9.7

Now to install, you can do

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

or install using ( this one works for me as well)

$ make install

Step 2 - Now that you have installed usb_modeswitch its time to configure it, first we copy the usb_modeswitch.conf file we downloaded

$ cp usb_modeswitch.conf /etc/

then we need to edit usb_modeswitch.conf using a text editor, look for "Huawei E220" then edit it to make it look like the text or screenshot below

# 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

e160













After configuring that save then run usb_modeswitch

$ usb_modeswitch

Then your done with usb_modeswitch

Step 3 - I you haven't install wvdial you need to install it now then run wvdialconf if you have configured usb_modeswitch correctly and run usb_modeswitch wvdial will be able to detect your Huawei E160 modem.

$ wvdialconf

After running the above command, you will need to edit /etc/wvdial.conf make sure it look like the screenshot below, put ";" on username and password if its supposed to be blank as wvdial doesn't allow blank username and password.

huawei e160 modem













Once changes hav been made just save the file and then run wvdial.

$ wvdial

If configured properly it should start to connect like the screenshot below

3g modem













NOTE: During the waiting for prompt part, be patient as it is establishing connection, once it says its connected try to ping google.com

e160 3g modem














Then your done, the configuration for the wvdial is for Sun broadband, if your using other provider service, you will need to change it to your providers details.

NOTE: Everytime you unplugged and plug your Huawei E160 Modem you will need to run "usb_modeswitch" before running "wvdial", I suggest creating a bash/sh connection script something like the one below, just hit ctrl+c to disconnect.

------------------------------
#!/bin/bash
/usr/sbin/usb_modeswitch
sleep 30
wvdial
------------------------------


Tech Blog Quick List of howto's:

19 comments:

Alan said...

Is the usb_modeswitch program even necessary on these devices anymore? I am testing an e160 on Linux kernel 2.6.30 and all I needed was the usbserial and option kernel modules. The modem was automatically mapped to /dev/ttyUSB0 and with a small hacking of my wvdial.conf I was online.

I used a Huawei e220 back in 2008 and I had to use huaweiAktBbo.c to reveal the modem port, but these newer devices work fine with the proper kernel modules I think.

Anyways, thanks for the write up. For reference, I am using Debian Lenny with a vanilla 2.6.30 kernel on Kenya's Safaricom provider.

Thanks!

Genius24k said...

I'm not sure about the newer kernel, as at the time of writing I had Mepis 7 running on my Laptop which wasn't able to switch between disk and modem automatically, Mepis 7 is based on Debian Etch using 2.6.22 kernel.

Anonymous said...

tnx 4 d tutorial. another Q - is there a way to PortForward thru this E160 Dongle? Im also a Sun Wireless Broadband Subscriber and have the very same dongle. BTW, how's your speed these days? mine, it's slower already. :(

Genius24k said...

I don't think port forwarding would be possible or making your computer accessible on the net possible as I believe Sun wirless broadband is running behing natted network, unless Sun would port forward it from their routers/firewall, so far the speed in my are is still the same, however if I did experience slower speed on diffrent areas, I guess speed depend on how congested the cell site your on.

Anonymous said...

hey great tutorial, i also have the same usb but different linux, just wondering will this work in Tiny Core?

thanks so much!!!!!!!

Genius24k said...

You could try connecting your dongle to it and see if your Linux was able to detect it, since Tiny Core has very limited hardware support I doubt it supports the Huawei E160, but better to try it you never know ::)

paul said...

very nice.

in case that i don't have huawei modem,
would this be possible using a phone? i'm using my nokia 5310 or (doesn't really matter) and i can see from my 'dmesg' that it's a modem (/dev/ttyACM0).can't make it work from log:

Sep 3 15:25:01 XCom1 pppd[6681]: pppd 2.4.4 started by root, uid 0
Sep 3 15:25:01 XCom1 pppd[6681]: Using interface ppp0
Sep 3 15:25:01 XCom1 pppd[6681]: Connect: ppp0 <--> /dev/ttyACM0
Sep 3 15:25:01 XCom1 pppd[6681]: PAP authentication succeeded
Sep 3 15:25:01 XCom1 pppd[6681]: LCP terminated by peer
Sep 3 15:25:04 XCom1 pppd[6681]: Connection terminated.
Sep 3 15:25:04 XCom1 pppd[6681]: Modem hangup
Sep 3 15:25:04 XCom1 pppd[6681]: Exit.

wvdial conf:
[Dialer sun]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
ISDN = 0
Username = ;
New PPPD = yes
Password = ;
Phone = *99#
Modem = /dev/ttyACM0
Baud = 460800


did i missed something here? :) hope you can share. Thanks very much!

Genius24k said...

Paul,

I think the wvdial.conf is not your problem, from what I have found out on google seems like GPRS phones don't reply to LCP echo's, which mean you might have missed a step configuring your ppp, also the logs you posted would also confirm this(see below), based on your logs your also able to authenticate and therefore connect to your provider.

Sep 3 15:25:01 XCom1 pppd[6681]: LCP terminated by peer
Sep 3 15:25:04 XCom1 pppd[6681]: Connection terminated.

Here is the solution I have found you might want to try it

Steps ---------

vi /etc/ppp/peers/wvdial

copy and paste these 2 lines onto the end of the file, try the 65535 value first if it didn't work changes it to 0

lcp-echo-failure 65535
lcp-echo-interval 65535

The whole file should look like this

noauth
name wvdial
usepeerdns
lcp-echo-failure 65535
lcp-echo-interval 65535

Save and try to start the connection again see if it works.

Good luck, I don;t gurantee it would work as I have not tested it and I don't use my phone as modem but its worth a try let me know if it work.

paul said...

sorry dude. can't make it work. i will try to make some research on my free time (and probably post it here).will have to research about the protocol too. :)

i'm just trying to hack this tool because using Nokia PC Suite in windows, i was to able to use it then. I don't believe that this won't work.

maybe, i just need to find the right setting.

Thanks very much! :)

Anonymous said...

to:
Genius24k said...

You could try connecting your dongle to it and see if your Linux was able to detect it, since Tiny Core has very limited hardware support I doubt it supports the Huawei E160, but better to try it you never know ::)

im Tiny Core guy post :>
-> one very stupid question how would i know if its detected???? sorry i come from windows and no background in basic linux commands

very much thank you for your reply!!!!!

Genius24k said...

Once you connect the dongle to your PC/Laptop usb slot check /var/log/messages

You could open another terminal then type the following

tail -f /var/log/messages

The command above will allow you to see the logs in realtime, so when you connect your dongle you should see logs that a new device has been connected and what device it is.

Mike said...

I have followed this great howto.
I'm using a sheevaplug (ubuntu 9.04)
I installed usb_modeswitch-1.1.0.tar.bz2 instead of 0.9.7.

wvdial.conf is as follows:
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone = *99#
ISDN = 0
Password = web
New PPPD = yes
Username = web
Modem = /dev/ttyUSB0
Baud = 460800

I'm getting:
root@ubuntu:/etc# wvdial
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
wvdial: utils/wvtask.cc:198: WvTaskMan::WvTaskMan(): Assertion `getcontext(&get_
stack_return) == 0' failed.
Aborted

Any idea why this is happening ?

Any help would be great, thanks.
Mike.

Anonymous said...

Thanks for the info. I'm using Ubuntu Lynx 10.4 and I'm surfing now through Sun Broadband.

@Alan: I still use his usb_modswitch. Kernel is 2.6.32-22-generic. USB dongle is recognized by lsusb but it cant be accessed without using usb_modeswitch first. Though, the new filename for the conf file is usb_modeswitch.setup

I also advise mobile users to add defaultroute and replacedefaultroute lines to their /etc/ppp/peers/wvdial to avoid conflict with eth0 or other network adapters upon connecting. =)

Anonymous said...

all you have to do is firmware update E160E to E160G, works fine all distr..

Anonymous said...

Can I boot Linux from E160? Since the E160 have a MicroSD card, I can store my Linux there and boot form it than acquire the HSDPA for internet without interference with the PC. Is it possible?

Genius24k said...

it would depend if your BIOS would recognize your E160 as a USB storage device that it can boot from, however even if you can boot Linux from the E160, you would have to to switch from USB mode to Modem mode which will hinder operation of the Linux.

The poster about the E160 firmware is real I have never tried it then it should work as you wanted to booting from Linux and using it as Modem at the same time, but if your following my tutorial you it wont be possible.

lavezarez said...

ubuntu 9.04, 9.10, and 10.04 - as well as my current distro knoppix 6.2 - all automatically detect my huawei e160 modem without the need for wvdialconf, etc. and terminal commands.

would you know a tool for sms send & receive, though?

Kian Hua said...

Try smstools3

Paulo said...

hi there! i recently installed ubuntu 11.04 and i can't make my huawei e160 3G modem work. i tried the solution above but still, it doesn't work. any thoughts? thank you!

For suggestion and concerns E-mail