Tuesday, March 29, 2011

OpenBSD NC4200: Using Celcom ZTE MF190 USB Modem.

I just registered with Celcom Broadband with no contract. Received a ZTE MF190 USB modem with sim card and working fine in XP. As usual, making it work in OpenBSD is the goal. OpenBSD's umsm listed a few ZTE USB modem as supported USB 3g modem but currently using cu -l cuaU0 will just display "Connected" and hangs there. Tried using cuaU0 to cuaU2 with no avail. I've posted a question in misc@ and a guy have replied and forwarded related emails regarding ZTE USB 3g modem. Thanks for that!. It seems that this type of USB Modem share similar properties as a supported ZTE modem, so no patching is required.


1) Getting info about the USB Modem.
Here's the dmesg after I inserted the usb 3g modem.

umsm0 at uhub0 port 3 configuration 1 interface 0 "ZTE,Incorporated ZTE WCDMA Technologies MSM" rev 2.00/0.00 addr 5
umsm0 detached
umsm0 at uhub0 port 3 configuration 1 interface 0 "ZTE,Incorporated ZTE WCDMA Technologies MSM" rev 2.00/0.00 addr 5
ucom0 at umsm0
umsm1 at uhub0 port 3 configuration 1 interface 1 "ZTE,Incorporated ZTE WCDMA Technologies MSM" rev 2.00/0.00 addr 5
ucom1 at umsm1
umass1 at uhub0 port 3 configuration 1 interface 2 "ZTE,Incorporated ZTE WCDMA Technologies MSM" rev 2.00/0.00 addr 5
umass1: using SCSI over Bulk-Only
scsibus1 at umass1: 2 targets, initiator 0
cd1 at scsibus1 targ 1 lun 0: <ZTE, USB SCSI CD-ROM, 2.31> SCSI2 5/cdrom removable
umsm2 at uhub0 port 3 configuration 1 interface 3 "ZTE,Incorporated ZTE WCDMA Technologies MSM" rev 2.00/0.00 addr 5
ucom2 at umsm2


Here's the usbdevs -v outputs:

Controller /dev/usb0:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), Intel(0x8086), rev 1.00
port 1 powered
port 2 powered
port 3 addr 5: high speed, power 500 mA, config 1, ZTE WCDMA Technologies MSM(0x0031), ZTE,Incorporated(0x19d2), rev 0.00, iSerialNumber P671A1CELD010000
port 4 powered
port 5 addr 2: high speed, self powered, config 1, USB2 Hub(0x6560), Cypress Semiconductor(0x04b4), rev 0.0b
port 1 addr 3: high speed, self powered, config 1, USB Multibay IDE 2.466(0x031d), Hewlett Packard(0x03f0), rev 2.46, iSerialNumber HH63MC0BLTC1
port 2 powered
port 3 powered
port 4 addr 4: low speed, power 98 mA, config 1, USB-PS/2 Optical Mouse(0xc03d), Logitech(0x046d), rev 20.00
port 6 powered
port 7 powered
port 8 powered
Controller /dev/usb1:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x8086), rev 1.00
port 1 powered
port 2 powered
Controller /dev/usb2:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x8086), rev 1.00
port 1 powered
port 2 powered
Controller /dev/usb3:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x8086), rev 1.00
port 1 powered
port 2 powered



2) Set up the logging environment.
I create /var/log/ppp.log file. Then I vim /etc/syslog.conf and add:

!ppp
*.*         /var/log/ppp.log



3) Testing using userland ppp.
So the logging part is done. Now to test the ppp environment. I found that /dev/cuaU2 is the working device for this. I tried /dev/cuaU0 but didn't work. /dev/cuaU1 on the other hand don't have Carrier Detect. Here's my ppp testing result. Bolded texts are my input:

# ppp
Working in interactive mode
Using interface: tun0
ppp ON karlaphp> set device /dev/cuaU2
ppp ON karlaphp> set speed 384000
ppp ON karlaphp> show physical
Name: deflink
State: closed
Device: N/A
Link Type: interactive
Connect Count: 0
Queued Packets: 0
Phone Number: N/A

Defaults:
Device List: "/dev/cuaU2"
Characteristics: 384000bps, cs8, no parity, CTS/RTS on
CD check delay: device specific

Connect time: 0:00:00
0 octets in, 0 octets out
0 packets in, 0 packets out
Overall 0 bytes/sec
ppp ON karlaphp> term
deflink: Entering terminal mode on /dev/cuaU2
Type `~?' for help
AT
OK
ATZ
OK
AT+CGDCONT=1,"IP","celcom3g"
OK
ATDT*99#
CONNECT 7200000


So basically interactive ppp is working, but I haven't got the chance to test my /etc/ppp/ppp.conf script thoroughly as I'm currently at work (yeah I do this at work...). But, for the pleasure of the eyes, here's my current /etc/ppp/ppp.conf script:

default:
 set log Phase tun connect
 set device /dev/cuaU2
 set speed 384000
 disable ipv6cp

celcom:
 set dial "ABORT BUSY ABORT NO\sCARRIER TIMEOUT 5 \"\" ATZ OK-ATZ-OK AT+CGDCONT=1,\\\"IP\\\",\\\"celcom3g\\\" OK \\dATDT\\T TIMEOUT 40 CONNECT"
# dial number are *99# or *99***1#
 set phone "*99#"
 set login
 set authname ""
 set authkey ""
 set timeout 0
 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
 add default HISADDR
 enable dns


If I dialed to celcom, I'll get this warning:

Warning: 0.0.0.0/0: Change route failed: errno: No such process
Warning: ff01:6::/32: Change route failed: errno: Network is unreachable
Warning: ff02:6::/32: Change route failed: errno: Network is unreachable
Warning: ff02:6::/32: Change route failed: errno: Network is unreachable


But I was told (by googling) that it's just a warning and non-fatal. The 2nd to 4th warning is just mentioning about IPV6 so it's nothing.


4) Set up pppd for Celcom 3G.*hip hip, hurray!. hip hip, hurray!*
This is the final part. Instead of using userland ppp, I'll go for pppd. Do man both for informations. Ok for this, I will create 2 files. Here's the steps:

First I'll create and edit /etc/ppp/peers/celcom3g file. On my system, there's no /etc/ppp/peers folder so I mkdir it first. Here's what my /etc/ppp/peers/celcom file looks like:

/dev/ttyU2
debug
384000
noauth
noipdefault
ipcp-restart 10
ipcp-accept-local
ipcp-accept-remote
0.0.0.0:10.64.64.64
defaultroute
novj
connect "chat -v -f /etc/ppp/peers/celcom3g.chat"


Then I created /etc/ppp/peers/celcom3g.chat file. Here's what mine looks like:

ABORT "BUSY"
ABORT "NO CARRIER"
ABORT "ERROR"
ABORT "VOICE"
ABORT "NO DIALTONE"
SAY "Calling Celcom3G...\n"
"" AT
OK ATV1
OK ATE0
OK AT&F&D2&C1S0=0
OK ATS7=60S30=0
OK ATS0=0
OK AT
OK ATV1
OK ATE0
OK AT&F&D2&C1S0=0
OK ATS7=60S30=0
OK ATDT*99#
TIMEOUT 45
CONNECT \d\c


Where the hell did I get the idea for all the AT commands?. Well, I took a peek at the USB Modem's log in XP. If you google for Celcom 3G ppp script, you'll most probably notice that I don't have the familiar AT+CGDCONT=1,"IP","celcom3g" command. Do I need it? For now, I don't think so, because I'm updating this while I'm on Celcom 3G! Using that chat script. Why don't I need it? I don't know, honestly. But it's working. You'll also notice that ATDT*99# means that I'm dialing *99#, if you want to use *99***1#, just replace that test appropriately. Oh, I almost forgot how to dial using pppd. First, I created ppp0 links:

# sudo ifconfig ppp0 create

Then dial using pppd:

# pppd call celcom3g

If your script is named other than celcom3g, replace the celcom3g to your file name. To check the log, use tail -f /var/log/daemon to see if there's anything weird, or if reading log files is one of your fetish. How to disconnect from the connection? I just use ps aux | grep ppp and then kill pid and finally ifconfig ppp0 destroy. Do search for scripts that simplifies it.

After I disabled my http_proxy, I can browse the net with no issue. So I set my Firefox to Use system proxy settings. Speaking of which, I need to find a way to automate turning on/off http_proxy depending on whether I'm in the office (proxy) or at home (no proxy). That'll be my next project. As usual, any tips is much appreciated. Later and enjoy!

Edit: I've replace /dev/cuaU2 to /dev/ttyU2. man 4 tty for more info.

1 comment:

igi said...

Hi Karl,
I'm trying to set an option USB 3g Modem on an Alix6e1 board runing openbsd 4.9 and have some questions.
Do you think you can help me? please email me at
igorkolt@gmail.com

6.5 amd64: Modify existing certbot certificates.

Hi, It's been quite some time eh. As you can see, I still upgrade my OpenBSD system regularly but currently I do not have the time to ...