Archive

Posts Tagged ‘3gmodem’

Setup ZTE MF622 USB Modem in Linux

December 2, 2008 4 comments

Recently I found myself needing to install a 3g Modem for a Portuguese Service Provider (TMN). When i tried plug in the modem in all it did was deploy a new USB drive showing me the contents of what seemed to be the windows installer for the manager application. After a little digging around i found the solutions for my troubles. This post shows the solution i found. this is how i got it to work, I’m not saying its the best and I’m sure its not the only one.

Getting Linux to detect the 3g modem side of the device instead of the USB pen side

This device works as two devices in one. In windows when you plug the modem in it first mounts a hard-drive/cdrom in order to install the drivers and applications for the modem. it later removes this drive and installs itself as a modem. this last part is done by the installer so in Linux this last part never happens when you plug in the modem. What you need to do is force the system to ignore the usb pen drive side of the device.

In order to do this you need to create a file named “15-zte-mf622.rules” and put it in : “/dev/udev/rules.d” (warning you need root privileges in order to do this)

Put the following content in this file you just created:

ACTION!=“add”, GOTO=“ZTE_End”

# Is this the ZeroCD device?

SUBSYSTEM==“usb”, SYSFS{idProduct}==“2000”,

SYSFS{idVendor}==“19d2”, GOTO=“ZTE_ZeroCD”

# Is this the actual modem?

SUBSYSTEM==“usb”, SYSFS{idProduct}==“0001”,

SYSFS{idVendor}==“19d2”, GOTO=“ZTE_Modem”

LABEL=“ZTE_ZeroCD”

# This is the ZeroCD part of the card, remove

# the usb_storage kernel module so

# it does not get treated like a storage device

RUN+=“/sbin/rmmod usb_storage”

LABEL=“ZTE_Modem”

# This is the Modem part of the card, let’s

# load usbserial with the correct vendor

# and product ID’s so we get our usb serial devices

RUN+=“/sbin/modprobe usbserial vendor=0x19d2 product=0x0001”,

# Make users belonging to the dialout group

# able to use the usb serial devices.

MODE=“660”, GROUP=“dialout”

LABEL=“ZTE_End”

Note: this is the configuration for the ZTE MF622 modem.

After you have created this file run the following command, this will reload the device rules:

udevcontrol reload_rules

This rules file prevents the system from mounting the USB drive side of the device, but this constitutes a problem. Now your system wont be able to recognize USB hard drives. Don’t fret this can be solved by removing the file and reloading the rules. More on this further down the road.

If you connect your modem at this point you will see that the system now installs it as a modem and you can find it in “/dev/ttyUSB0“.

You can now use your favorite dialer (wvdial, UMTSmon, …) to connect using this device.

The ability to connect thumb drives again.

After deploy the above rules file and reloading your rules you will lose the ability to connect thumb drives to the system. All you have to do to be able to use them is remove the file and reload the rules. I got the following solution from a comment by Dorothy Hyde to the post i mention in the reference part of this article:

1. Create a folder called “/udv-rls” and put the above rules file inside it

2. Create a bash script called 3up with the following code:

#!/bin/bash

cp -v /udv-rls/15-zte-mf622.rules /etc/udev/rules.d/

devcontrol reload_rules

# end of script.

3. Create a bash script called usf with the following code:

#!/bin/bash

rm -v -f /etc/udev/rules.d/15-zte-mf622.rules

udevcontrol reload_rules

#end of script

Now before you plug in the modem run 3up, and after the system has detected the modem run usf.

Connecting to the web:

After the system has detected your modem you now have to be able to connect. I tried using wvdial and all i managed was to get my modem blocked. No matter what i tried i could never get it to connect. So i resorted to UMTSmon. You can get binaries and source from here .

After you install it you can run UMTSmon to dial in. I ran into some trouble at this point:

  • UMTSmon did not detect the modem unless i ran it with root privileges – basically in order to use the installed devices you need to add your self to the uucp group. So you need the run the following commands:

usermod -a -G uucp username

  • If you run UMTSmon without root privileges pppd will ask for root when trying to connect – You need to SUID pppd. I found the following on this matter (Reference).

Because PPP needs to set up networking devices, change the kernel routing table and so forth, it requires root privileges to do this.

If users other than root are to set up PPP connections, the pppd program should be setuid root

-rwsr-xr-x 1 root root 95225 Jul 11 00:27 /usr/sbin/pppd

If /usr/sbin/pppd is not set up this way, then as root issue the command:-

chmod u+s /usr/sbin/pppd

You should now be able to connect to the Internet using your ZTE MF622 modem.

These are the configurations i had to use in UMTSmon in order to connect (these configurations work for TMN – Portuguese Service Provider).

UMTSmon Preferences

UMTSmon Preferences

I created the following bash script which i run before plug in in the modem, it basically automates the above process. Mind that you might be required to run it using root privileges.

#!/bin/bash

rulesFileName=”15-zte-mf622.rules”
rulesFileOriginalPath=”/udv-rls/${rulesFileName}”
rulesFileDir=”/etc/udev/rules.d/”

clear
echo “******************************”
echo “* ZTE MF622 – Startup Script *”
echo “*                            *”
echo “* Developed by NFurtado      *”
echo “* Date: 02/12/2008           *”
echo “******************************”
echo “”
#copy the rules and reload the udev
echo “Copying the rules file to $rulesFileDir”

cp $rulesFileOriginalPath $rulesFileDir || { echo “ERROR: Rules file could not be copied. Script exiting.”;  exit 1; }
echo “Reloading Rules”
/sbin/udevcontrol reload_rules || { echo “ERROR: Rules could not be reloaded. Script Exiting.”; exit 1;}

#output connect modem
echo “Please connect 3g Modem.”
echo “Waiting for modem…”

#loop and wait for modem to be connected
while [ -z $ttyGrep ]
do

ttyGrep=`ls  /dev/ |grep ttyUSB0`

done

echo “Modem Detected”
echo “Cleaning up:”

#remove rules file and reload rules
echo “Removing rules file from ${rulesFileDir}”
rmCommand=”${rulesFileDir}/${rulesFileName}”

rm -v -f $rmCommand || { echo “ERROR: Rules file could not be Removed. Remove it manually.”;}
echo “Reloading Rules”
/sbin/udevcontrol reload_rules  || { echo “ERROR: Rules could not be reloaded. Script Exiting.”; exit 1;}
echo “”

echo “Modem is Setup. Use your favorite Dialer to connect.”

exit 0

As i said before I’m a newbie in these affairs so take the above instructions and scripts with a grain of salt. If you see any inconsistencies or errors just let me know

References

  1. http://tldp.org/HOWTO/PPP-HOWTO/root.html
  2. http://blog.ufsoft.org/2007/11/30/zte-mf622-usb-modem-under-linux
Categories: Linux Tags: , ,