Huawei K3765 3G modem on FreeBSD

So you want to use your huawei modem on FreeBSD. I mean, REALLY use that device with your mobile internet provider. Then read on.



My device is a K3765 Huawei flipflop and my provider is vodafone romania. Change this info to suit your needs. If your device is still a huawei and your provider talks 3G then read on. If you don't, you may still read on and hope the info I provide will help you somehow. If it does, let me know.

If you have a FreeBSD older than 8.2-RELEASE (e.g. 8.1-RELEASE), you have the patch the source tree as I described here and recompile/reinstall the system. If your FreeBSD is an 8.2-RELEASE or greater you can skip this step since the patch was committed and the FreeBSD guys also added the scsi init sequence so you can use the modem's storage.

Now you can penetrate your usb port with your huawei device. You'll get something like this in your dmesg:

ugen6.2:  at usbus6
umass0:  on usbus6
umass0:  SCSI over Bulk-Only; quirks = 0x0000
umass0:0:0:-1: Attached to scbus0
(probe0:umass-sim0:0:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0 
(probe0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(probe0:umass-sim0:0:0:0): SCSI status: Check Condition
(probe0:umass-sim0:0:0:0): SCSI sense: NOT READY asc:3a,0 (Medium not present)
cd0 at umass-sim0 bus 0 scbus0 target 0 lun 0
cd0:  Removable CD-ROM SCSI-2 device 
cd0: 40.000MB/s transfers
cd0: Attempt to query device size failed: NOT READY, Medium not present




download usb_modeswitch from here: http://fw.io/data/flipit.tar. This software was taken from here and I don't remember if I modified something in it to make it work, so better use my ph0ny version for now.

Run these commands:

fetch -o - http://fw.io/data/flipit.tar | tar xf -
gcc -o flipit usb_modeswitch.c -lusb

Now you are ready to flipflop your device with this command:

./flipit -v 0x12d1 -p 0x1520 -M 55534243EE0000006000000000000611062000000000000000000000000000 -V 0x12d1 -P 0x1465 -W

command output:
bla b la....
Looking for target devices ...
 No devices in target mode or class found
Looking for default devices ...
 Found default devices (1)
Accessing device 013 on bus 000 ...
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
 Cant't do driver detection and detaching on this platform.

Received inquiry data (detailed identification)
-------------------------
  Vendor String: Vodafone
   Model String: CD ROM (Huawei)
Revision String: 2.31
-------------------------

Device description data (identification)
-------------------------
Manufacturer: HUAWEI Technology
     Product: HUAWEI Mobile
  Serial No.: not provided
-------------------------
Setting up communication with interface 0 ...
Trying to send the message to endpoint 0x01 ...
 OK, message successfully sent



You should see some changes reported in dmesg output:
ugen6.2:  at usbus6 (disconnected)
umass0: at uhub6, port 1, addr 2 (disconnected)
(cd0:umass-sim0:0:0:0): lost device
(cd0:umass-sim0:0:0:0): removing device entry
ugen6.2:  at usbus6
u3g0:  on usbus6
u3g0: Found 3 ports.
cdce0:  on usbus6
ue0:  on cdce0
ue0: Ethernet address: 02:50:f3:00:00:00
umass0:  on usbus6
umass0:  SCSI over Bulk-Only; quirks = 0x0000
umass0:0:0:-1: Attached to scbus0
umass1:  on usbus6
umass1:  SCSI over Bulk-Only; quirks = 0x0000
(probe0:umass-sim0:0:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0
(probe0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(probe0:umass-sim0:0:0:0): SCSI status: Check Condition
(probe0:umass-sim0:0:0:0): SCSI sense: NOT READY asc:3a,0 (Medium not present)
cd0 at umass-sim0 bus 0 scbus0 target 0 lun 0
cd0:  Removable CD-ROM SCSI-2 device
cd0: 40.000MB/s transfers
cd0: Attempt to query device size failed: NOT READY, Medium not present
umass1:1:1:-1: Attached to scbus1
(probe0:umass-sim1:1:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0
(probe0:umass-sim1:1:0:0): CAM status: SCSI Status Error
(probe0:umass-sim1:1:0:0): SCSI status: Check Condition
(probe0:umass-sim1:1:0:0): SCSI sense: NOT READY asc:3a,0 (Medium not present)
da0 at umass-sim1 bus 1 scbus1 target 0 lun 0
da0:  Removable Direct Access SCSI-2 device 
da0: 40.000MB/s transfers
da0: Attempt to query device size failed: NOT READY, Medium not present


Thats a good sign. Your device should be flippyflopped now.
Lets play a little bit with freebsd's ppp shell. My device (and probably yours as well) is /dev/cuaU0.0. I want to set the pin and find out some infos about the network:

[root@ ~/builds/x]# ppp
Working in interactive mode
Using interface: tun0
ppp ON localhost> term
Warning: deflink: /dev/cuau1: Bad file descriptor
Failed to open /dev/cuau1
ppp ON localhost> set device /dev/cuaU0.0
ppp ON localhost> term
~?
Supported escape sequences:
  ~.  - terminate session
  ~B  - send a BREAK to the remote system
  ~R  - Request rekey (SSH protocol 2 only)
  ~#  - list forwarded connections
  ~?  - this message
  ~~  - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)
deflink: Entering terminal mode on /dev/cuaU0.0
Type `~?' for help

see if we have the pin set. if we don't, set it now:
AT+CPIN?
+CPIN: SIM PIN

OK
AT+CPIN=1234
OK
AT+CPIN?
+CPIN: READY

OK

query for some information (modem info, network info):

AT+CREG?
+CREG: 0,1

AT+CSQ
+CSQ: 13,99

OK
ATi
Manufacturer: huawei
Model: K3765
Revision: 11.126.03.07.00
IMEI: 353054030852297
+GCAP: +CGSM,+DS,+ES

OK
AT+CGDCONT?
+CGDCONT: 1,"IP","internet.vodafone.ro","0.0.0.0",0,0

OK


ok. we're ready to connect. my ppp.conf looks like this (besides the defaults which are omitted):

vodafone:
        enable dns
        resolv writable
        set device /dev/cuaU0.0
        set speed 460800
        set phone *99***1\#
        set authname internet.vodafone.ro
        set authkey vodafone
        set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5\
                \"\" \
                AT OK-AT-OK \
                AT+CFUN=1 OK-AT-OK \
                AT+CSQ OK \
                AT+CGDCONT=1,\\\"IP\\\",\\\"internet.vodafone.ro\\\" OK \
                AT+CGACT? OK-AT-OK \
                AT+CGATT? OK \
                AT+COPS? OK \
                ATD*99***1# CONNECT"
        set timeout 180
        set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
        set vj slotcomp off
        set crtscts on
        add default HISADDR


going back to the ppp session:

# ppp 
Loading /lib/libalias_cuseeme.so
Loading /lib/libalias_ftp.so
Loading /lib/libalias_irc.so
Loading /lib/libalias_nbt.so
Loading /lib/libalias_pptp.so
Loading /lib/libalias_skinny.so
Loading /lib/libalias_smedia.so
Working in interactive mode
Using interface: tun0
ppp ON localhost> set device /dev/cuaU0.0
ppp ON localhost> load vodafone
ppp ON localhost> dial
ppp ON localhost> 
Ppp ON localhost> 
PPp ON localhost> Warning: 0.0.0.0/0: Change route failed: errno: No such process
PPP ON localhost> 


we're now connected; dig some infos:

PPP ON localhost> show iface
tun0 (idx 5)  mtu 1500 has 1 address:
  inet 10.82.202.216 --> 10.0.0.2 netmask 0xffffff00
PPP ON localhost> 

No comments:

Post a Comment