Huawei E160 and Linux
Saturday, 27. September 2008 10:40 - daniel - Other - 7 Comments
I recently got a Huawei E160 3G modem and use it on my Asus EEE 701 for mobile browsing. Since the E160 has two modes. In the default mode it acts like a read only USB drive, in the second mode, the modem is available. To change between these modes, you need a tool called usb_modeswtich.
The solution I'm describing here works on my EEE with fluxflux (a PCLinuxOS-remaster). It should work with other distributions too, but I havn't tested it. This solutions is based on Thomas Schönhütl's post about how to get the E169 working with fluxflux (german).
First, we need to get usb_modeswitch and compile it. You need libusb-dev (or libusb-devel on some distros) installed for this.
Now install ivman. Ivman is a daemon to auto-mount and manage media devices. We'll use ivman to run usb_modeswitch when the E160 is connected. I tried to do this with udev but failed. If anyone is successfull by doing it with udev, let me know.wget http://www.draisberghof.de/usb_modeswitch/usb_modeswitch-0.9.4.tar.bz2
tar -xjf usb_modeswitch-0.9.4.tar.bz2
cd usb_modeswitch-0.9.4
./compile.sh
cp usb_modeswitch /usr/local/bin/
Add ivman to you autostart. In ubuntu you can do this by going to System->Preferences->Sessions and adding a new Startup Program.apt-get install ivman
ivman
Now, lets adjust the ivman config file. Open $HOME/.ivman/IvmConfigActions.xml and add this befor </ivm:ActionsConfig>
<!-- Change Huawei E160 Mode -->
<ivm:Match name="hal.storage.physical_device" value="/org/freedesktop/Hal/devices/usb_device_12d1_1003_noserial_if0">
<ivm:Option name="exec" value="xterm -e $HOME/.e160.sh" />
</ivm:Match>
Now create a file named .e160.sh in you home folder and open it with you favourite text editor. Paste this to the file
!/bin/bash
if [ -z "`/bin/ls /dev/ttyUSB0`" ]; then
if [ "`/usr/sbin/lsusb | grep 12d1 | cut -d : -f3 | cut -b -4`" = "1003" ]; then
/usr/local/bin/usb_modeswitch -v 12d1 -p 1003 -d 1
/usr/local/bin/usb_modeswitch -v 12d1 -p 1003 -H 1
fi
fi
Save the file and make it executable.
chmod +x .e160.sh
Restart ivman (or reboot) and the next time you connect you E160 3G modem, it should be switched to the correct mode automatically. Comments
Dan Finnimore - Tuesday, 6. January 2009 7:53
Many thanks for the above help.
I have a e160g and am using debian 2.04 etch. I have managed to do all of the above except pasting the script into /ivm:ActionsConfig>, as I cannot locate the correct place to paste.
Your extra help would be appreciated
Dan
Daniel - Tuesday, 6. January 2009 11:47
In your home folder should be a file named .ivman/IvmConfigActions.xml containing some xml code. Just past the above snipped at the bottom of the file but before the last xml tag (</ivm:ActionsConfig>) and you should be fine.
Mubarak Adam - Monday, 9. February 2009 5:15
Hi,
Was refered here by Mr. Alan Orth of alaninkenya.org.
Same scenario, did what you have said here and voila... works like a charm.
Good day.
tix tux - Tuesday, 17. May 2011 15:06
To get your USB dongle (Huawei E160) to work: (Slackware Linux 13.0 - kernel 2.6.38.6 but may work on other linux versions)
Step 1: Ensure PPP is compiled into your kernel
Step 2: Ensure that you kernel does not spew any errors or does not panic (see kernel compilation howto in /usr/doc/Linux-HOWTOs)
Step 3: Ensure that your kernel supports USB storage
Step 3a: Ensure that kernel supports USB-Serial (generic usb_serial driver should work)
Step 4: Obtain software called comgt (http://sourceforge.net/projects/comgt/)
Step 5: Boot your computer (LOL!)
Step 6: At command prompt login (duh!)
Step 7: su as root user (login as regular user, issue command "su" and put root password - risky to login directly as root)
Step 8: Uncompress comgt.032.tgz (tar -xvzf comgt.032.tgz)
Step 9: Build the comgt and install comgt
Step 10: Insert Huawei modem
Step 11: Huawei modem shall be detected as CD-ROM drive (/dev/sr1 or /dev/sdb) instead of a 3g modem (check using "dmesg")
Step 12: To switch modes of modem from CD-ROM to a modem, you need to eject the Huawei CD-ROM device using the command (eject /dev/sr1 or eject /dev/sdb or eject /dev/)
Step 13: To switch modes of Huawei modem, use comgt "comgt -x -d /dev/-usb device-" where -usb device- is ttyUSB0 or ttyUSB1 -- e.g. "comgt -x -d /dev/ttyUSB0" Some message should display giving you the network provide name and the signal strength!
Step 14: Point /dev/modem to your Huawei modem at e.g. /dev/ttyUSB0. If /dev/modem does not exist, then create it LOL! "ln -s /dev/ttyUSB0 /dev/modem"
Step 15: Exit as root user and login as regular user! (if using "su" simply type exit)
Step 16: Start your dialer program - wvdial or kppp
Step 17: Konfigure your dialer and dial! :)
Step 18: A new device "ppp0" will be listed in list of networking hardware (check this using "ifconfig")
Step 19: Make sure your put your DNS server addresses in "/etc/resolv.conf" in format "nameserver -DNS server-" where -DNS server- is ip address of DNS server of your ISP
Step 20: Enjoy surfing! -END-
ty tower - Monday, 17. October 2011 8:06
I run puppy 5.28 as operating system It loads and connects properly to the 3G USB Huawei E160E modem but I want to include the necessary commands in an Arduino sketch and use an arduino and a usb host to send an sms on a specified event..My question is what do I put in my C++ sketch to switch the device to modem as it starts as a storage device?
April - Wednesday, 2. November 2011 6:16
For a ZTE MF626 and others With access on a windows machine in hyperterminal send disable/enable flashdrive AT+ZCDRUN=8 enable AT+ZCDRUN=9 disable
With CD disabled modem should be available
April - Wednesday, 2. November 2011 6:18
That is disable/enable flashdrive AT+ZCDRUN=8 (enable) AT+ZCDRUN=9 (disable)