Friday, January 08, 2010

Using the ZTE MF 110 with 3g Movistar (Argentina) on Linux

Hello all,
Today I'm going to explain how to do something really simple. As some of you might already know, I got this year a EEE PC netbook (1000HA). I have to admit that this baby is going great, I'm running the latest Kwort on it and it's really resource saving if you know how to set it up correctly.
If I add this netbook a 3g connection, I can say that I'm online everywhere almost all of the time. Well, this is what happened... As most of you already know, I've been working for Accenture for over a year now and they provided me (and some of my co-workers) a 3g modem with internet connection, which is pretty nice.
So, on january 1st after all the people who came my home to celebrate the new year left I sitted on the computer to figure out how to make it work.
This is a ZTE MF 110, and I found some people who made it work (kinda) or those who plugged it in at ubuntu and said that it works OoTB. Well, this is true kind of, but I hate when you don't really know how things works. Also, I found some people who made it parcially work with wvdial, which is a nice tool also.
So, my quest was to make it work with plain pppd. And this isn't really hard to do if you know a little how to play with the AT commands.

Ok, let's put the hands in the mud, first of all, I'm one of those people who likes to have a latest kernel tuned for my device, so this implies that yeah, I compile my own kernel with almost every release... In this case we are compiling 2.6.32.2.
So, for this you'll need the usb mass storage system in order to be able to switch from it to the modem mode.
Device Drivers -> USB Support -> (Select your usb version, ehci, uhci or ohci) USB Mass Storage support

Now, this GSM modem (as several others) needs the serial support... Well, actually, this is a serial GSM modem that you want to jack into the USB bus. So you need:
Device Drivers -> USB Support -> USB Serial Converter support

This will create the usbserial module. And now, you need the GSM modem support. So for this, you have to select:
Device Drivers -> USB Support -> USB Serial Converter support -> USB driver for GSM and CDMA modems

I would recommend you to compile them as modules (M) instead of built in, as this isn't a feature that you will be running all the time, so you can unload modules and free some memory (not too much, but everything counts nowadays).

I'm assumming that you already have the PPP support, if not, it's in the device drivers and Network Devices. But if you're reading this, you might already know.

Now, everything is ready for us to set it up.

We need usb_modeswitch, this tool will allow us to switch from the "ZeroCD" mode to the modem mode in order to allow us to call our provider. Basically we need this config (/etc/usb_modeswitch.conf):
DefaultVendor=0x19d2
DefaultProduct=0x2000

TargetVendor=0x19d2
TargetProduct=0x0031

MessageEndpoint=0x1
MessageContent="55534243b8fe6681000000000000061b000000020000000000000000000000"

This config file will make the usb_modeswtich to swtich the device 0x2000, of the vendor 0x19d2, to 0x0031 sending the message pointed by MessageContent. If the usb_storage module is loaded and you run:
usb_modeswtich -c /etc/usb_modeswitch.conf

And then you run lsusb you'll see the product id changed from 2000 to 0031.

If you got here, now it comes to nice part.
In order for us to not use wvdial, we need a call script (also called chat script). I'm going to show you you the script I wrote (/etc/ppp/peers/chats/movistar):
ABORT BUSY ABORT 'NO CARRIER'
ABORT VOICE ABORT 'NO DIALTONE'
ABORT 'NO DIAL TONE' ABORT 'NO ANSWER'
ABORT DELAYED
'' ATZ
OK ATQ0\sV1\sE1\sS0=0\s&C1\s&D2\s+FCLASS=0
OK AT+CGDCONT=1,"IP","internet"
OK-AT-OK ATX3DT*99#
CONNECT \d\c

This basically it reads like this: abort in any of the conditions above (no carrier, no dialtone, etc...), then reset the modem waiting for nothing, initialize the modem, find out the CID for an APN GPRS, dial and connect. There's information about Hayes AT commands all over the web, so if you're interested you can google it yourself. :-)

Well, now we have to set up our user and password:
echo -e "internet\t*\tinternet" >> /etc/ppp/chap-secrets

And finally, the ppp configuration itself (/etc/ppp/peers/movistar):
lock
hide-password
noauth
connect "/usr/sbin/chat -v -f /etc/ppp/peers/chats/movistar"
/dev/ttyUSB2
460800
defaultroute
noipdefault
user "internet"
mtu 1492
ipparam movistar

Most of this options are self explanatory, but the importants one are the connect line and the "/dev/ttyUSB2" one. The first one tells pppd to use the chat program to connect the other point and the chat script that will be used (/etc/ppp/peers/chats/movistar, that we created before), if, for example, you set up a pptp connection you'll see this line pointing to the pptp client program. The second one tells pppd the modem device, maybe you have to play a little bit with this one trying /dev/ttyUSB2 or /dev/ttyUSB3 (if you don't wan't to try you can use minicom to find out, good luck with that :-P).

Well, now everything is ready to connect, you just need to run:
pppd call movistar

From now one, if you restart your laptop/netbook or normal PC, all you have to do is:
usb_modeswitch
sleep 1 # Let the device sync with the switch
pppd call movistar

9 comments:

pepe said...

Problem, i don't understand, help me please thanks

Jan 1 00:16:05 OpenWrt local2.info chat[1545]: abort on (BUSY)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: abort on (NO CARRIER)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: abort on (ERROR)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: report (CONNECT)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: timeout set to 10 seconds
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: send (AT&F^M)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: expect (OK)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: AT&F^M^M
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: OK
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: -- got it
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: send (ATE1^M)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: expect (OK)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: ^M
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: ATE1^M^M
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: OK
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: -- got it
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: send (AT+CGDCONT=1,"IP","movistar.es"^M)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: timeout set to 30 seconds
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: expect (OK)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: ^M
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: AT+CGDCONT=1,"IP","movistar.es"^M^M
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: OK
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: -- got it
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: send (ATD*99***1#^M)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: expect (CONNECT)
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: ^M
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: ATD*99***1#^M^M
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: NO CARRIER
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: -- failed
Jan 1 00:16:05 OpenWrt local2.info chat[1545]: Failed (NO CARRIER)
Jan 1 00:16:05 OpenWrt daemon.err pppd[1474]: Connect script failed

Nomius said...

pepe, it seems that you're using the wrong usb device. Check it

Anonymous said...

Excellent !!

maybe you could add the option usepeerdns...

Claudiu CISMARU said...

You can only eject /dev/sr1 or whatever cd device the modem is and will switch automatically to modem.

After switching to modem, you can issue: AT+ZCDRUN=8 command and AT&W to write the settings and from now on when you plug the device will go automatically in modem mode.

Or you just can add in udev to eject the device once is plugged in with:
SUBSYSTEM=="block", SYSFS{idProduct}=="2000", SYSFS{idVendor}=="19d2", RUN="/bin/eject %k"

Nomius said...

Great idea Claudiu

Anonymous said...

Hmm i found this page while struggling with my newly bought router. It is a TP-Link TL-MR3420, it suppose to support my 3G USB Modem ZTE MF626 because it is written in the box and in the website.

However when I plugged in my USB Modem into it, the router page says Unknown Modem! I have contacted the technical support and they send me a beta firmwire with WRONG INSTRUCTION (they asked me to upload bin file instead of upgrade firmwire, while the file they send is a firmwire file not a bin file), and I try both method, uploading bin file and also upgrade firmwire and it still won't detect my USB Modem. The router log is like this :
1 1st day 00:00:04 OTHER INFO System started
2 1st day 00:00:08 DHCP NOTICE DHCP server started
3 1st day 00:00:08 SECURITY INFO PPTP Passthrough enabled
4 1st day 00:00:08 SECURITY INFO L2TP Passthrough enabled
5 1st day 00:00:08 SECURITY INFO IPSEC Passthrough enabled
6 1st day 00:00:08 SECURITY INFO FTP ALG enabled
7 1st day 00:00:08 SECURITY INFO TFTP ALG enabled
8 1st day 00:00:08 SECURITY INFO H323 ALG enabled
9 1st day 00:00:28 DHCP NOTICE DHCPS:Recv REQUEST from 00:1E:C9:06:42:A5
10 1st day 00:00:30 DHCP NOTICE DHCPS:Send ACK to 192.168.1.100
11 1st day 00:00:31 3G EMERG 3G Modem vendorID: 0x19d2; productID: 0x2000
12 1st day 00:00:34 DHCP NOTICE DHCPS:Recv INFORM from 00:1E:C9:06:42:A5
13 1st day 00:02:08 3G NOTICE 3G USB Modem Settings command table is empty.

Do you know anything? Please help me. Thank you.

xmichaelm said...

Hi David,

I am trying to run usb_modeswitch on my KWORT installation and would appreciate your help.

First, I didn't find a pre-compiled package, so compiled my own from sources (1.0.2) with libusb sources (0.1.12).

Running: ./usb_modeswitch -v 1bbb -p f000 --config ./usb_modeswitch.conf

Results in the following error:

Inquiring device details; driver will be detached ...
Cant't do driver detection and detaching on this platform.
Could not claim interface (error -16). Skipping device inquiry

Further more, it appears that the usbserial driver is missing from my distribution. Do you know where can I find a compiled package?

Many thanks,
Michael

xmichaelm said...

Hi David,

I am trying to run usb_modeswitch on my KWORT installation and would appreciate your help.

First, I didn't find a pre-compiled package, so compiled my own from sources (1.0.2) with libusb sources (0.1.12).

Running: ./usb_modeswitch -v 1bbb -p f000 --config ./usb_modeswitch.conf

Results in the following error:

Inquiring device details; driver will be detached ...
Cant't do driver detection and detaching on this platform.
Could not claim interface (error -16). Skipping device inquiry

Further more, it appears that the usbserial driver is missing from my distribution. Do you know where can I find a compiled package?

Many thanks,
Michael

Anonymous said...

Thank You very much