LinuxUSB

This page is a doco about setting up Linux USB modem on a multi boot Linux/Windows machine system I have put together.
 Linux Ubuntu Karmic Koala 9.10 ! note problem fixed on Ubuntu 10.10 you don't have to use that one I only use that one as i didn't have the server version of 10.10 but I strongly recommend the server version for this if you want to use the build your own laptop router section that follows this page ) !

 Click below for larger image sizes, also don't forget you are liable for any damage or loss of data that occurs to your system by following the procedures below remember this is a highly technical process only for professional computer users ) I take no credit for the information in these files they were obtained from many forums and sources on the internet.
My main page or some more screenshots  and  Linux info page here



1.


Some assumptions.

A. You have a USB modem with working  sim card installed and payed connection to your provider ( hopefully you have also tested it it working with another system like Windows XP etc). 

B.  You have superuser access to your system ( test with  sudo su then enter your password ).

C.  You have Linux Ubuntu or understand the difference    between this and your version of Linux.

Programs used.
minicom
usb_modeswitch, gedit, lsusb, dmesg, apt-get, sudo su, ls, rmmod, modprobe, nm-applet and Firefox or other browser you prefer to test.

Disaster recovery precautions.
 
Backup your system.

Make backups of files like 10-modem.fdi  That may cause your system to become unstable. This helps you recover later as you may not have access to gedit in text mode recovery.



Start

Firstly this is quite a medium difficulty hack in that it needs some skill in editing scripts and user access levels,  also a recent version of Linux like Karmic Koala or newer.
 
I just came from a long ( for me stint on windows programming at home and of 3 years no Linux ) and it took me a couple of days to finally crack it  ( i think its fixed in Ubuntu codename Lucid Lynx )

Download
this page from my filestore it contains the version of usb_modeswitch and some scripts i used to help me run the modem its called archiveUSB.tar.gz

Colour Codes  ( note you have to have Firefox set with no override for colours for this to show in your browser )

 
red      background caveats warnings etc
brown background
Linux command text are with
green  background scripts to be added/created

Ok here is the hardware used i am on a Athlon Dual Core CPU using 32 bit Ubuntu and a USB modem by 3 broadband

Note on modem purchases

I think it is on the CDMA spectrum as this one is really good at connecting better then the latter model Huawei E1553 (AKA E620) I bought for my mum and drops out sometimes hee hee I told mum to buy into the CDMA spectrum modems but she thought I was being pushy so decided to wait )
The latest model i have is the E188 modem lsusb number 1c05

 The model i used to have is MF627 HSDPA (CDMA) Modem
 ( Lists in terminal as Onda Communications S.p.a but I think some come up as 19d2:0031 for USB Modem version in the UK  this help file is for the Australian model
is numbered 19d2:0064 but this FAQ should work for UK with some tweaking of all the scripts to the other numbers )

 lsusb for the MF627 ( comes up with this line in the terminal after its hacked successfully )


Before it is fixed you will have this picture and line below


You can use Minicom here to switch the CDROM part of the modem off if you are not usign the windows software use this codes 
AT^U2DIAG=0 (makes the device modem-only in future)
AT^U2DIAG=255           (makes the device fully-featured in future)
(other variations on the parameters will enable different permutations of the device components). ArchLinux (ref below) reckons:
AT^U2DIAG=0 - the device is only Modem
AT^U2DIAG=1 - device is in modem mode + CD ROM
AT^U2DIAG=255 - the device in modem mode + CD ROM + Card Reader
AT^U2DIAG=256 - the device in modem mode + Card Reader
got the codes from here thanks for your great site !!! 
http://www.techmind.org/3Gmbb/index.html
Bus 001 Device 003: ID 19d2:2000 Onda Communications

Also make sure if you have a external usb hub that its not connected to that note the links to root hub in the list as a direct connection to the USB port of your computer to the modem seems necessary, also no USB flash memory drives as this can put it off too  ( just to simplify the system for now until we get it connected and also if you are using the laptop/router solution  you probably don't need the extra bits :).

I think all modems by Huawei come up with 19d2 as this is some manufacturers code and the product ID ( ie what the product does ) is 0064 ( a USB modem )
and 2000 is ( a storage device ) but i could be wrong here

To check this start a Terminal you will need su later so type   sudo su put in password and type lsusb at the prompt
Now to get started with changing this we need a program called usb_modeswitch ( note don't get confused its not USB Modem switch but Mode switch.  I often type the other by mistake ) if its not there you need it so use apt-get install the file you may need to mount your ubuntu cd-rom with apt-cdrom.

usage: usb_modeswitch [-hvpVPmMrdHn] [-c filename]

 -h, --help                    this help
 -v, --default-vendor [nr]     vendor ID to look for (mandatory)
 -p, --default-product [nr]    product ID to look for (mandatory)

Add these lines to the /etc/usb_modeswitchOnda.conf  text configuration file.

# /etc/usb_modeswitchOnda.conf
#
# Last modified: 20010-06-09
#
# Configuration for usb_modeswitch, a mode switching tool  # for controlling flip flop (multiple device) USB gear
#
# Main purpose is to trigger the switching of several known #ONDA modems
# from storage device mode ("ZeroCD TM" for use with MS #Windows) to modem
# (serial) device mode
#
# Detailed instructions and a friendly forum on homepage:
# http://www.draisberghof.de/usb_modeswitch

;DefaultProduct= 0x2000

# choose one of these:

#HuaweiMode=0

DefaultVendor= 0x19d2
DefaultProduct= 0x2000
 TargetVendor= 0x19d2
TargetProduct= 0x0064
 # only for reference and 0.x versions
MessageEndpoint=0x01
 MessageContent="55534243123456782000000080000c85010101180101010101000000000000"

There may be some extra information in here that you don't need but i had enough of testing it to leave it alone its ok
and works for me but you can test and remove the message content string this may not be needed but most forums have a message string of some sort in the modems setup so your on your own there. Message strings are just sent to the modem and not the Internet itself as far as i know, so i don't think your are opening any security holes in your system but look on the Internet to find out I may be wrong.

 dpkg -l usb-modeswitch usb-modeswitch-data modemmanager 
Info below 





2.

output from sudo usb_modeswitch *note don't forget the sudo before the usb_modeswitch command as you wont get a proper output otherwise (or make sure you are in superuser mode by doing sudo su)

* usb_modeswitch: tool for controlling "flip flop" mode USB devices
 * Version 1.0.2 (C) Josua Dietze 2009
 * Works with libusb 0.1.12 and probably other versions

Looking for target devices ...
 Found devices in target mode or class (1)
Looking for default devices ...
 No default device found. Is it connected? Bye.

hee hee very helpful......... but yours should say your data
mine isn't responsive to the script after its switched over
to the other mode.

Newbie alert!! (some next data for those not knowing Linux commands just jump to part 3 if you want)

Now we need to edit the file that tells the system that this is
going to be switched on and off at startup this is a Bash script (file that can run many commands at once).  You can use sudo also the sudo command is used to give superuser status to a program such as gedit type this

sudo gedit
/usr/local/bin/start_e620Onda.sh

This will edit a file that is used by the OS called bash.
Another helpful command is tail the prints out the end of a text file try it with sudo tail -f /var/log/messages

also the dmesg command ( output of interest to serial here end of dmesg output you could use tail here to get that )

[    5.666310] USB Serial support registered for generic
[    5.666343] usbcore: registered new interface driver usbserial_generic
[    5.666346] usbserial: USB Serial Driver core
[    5.668287] USB Serial support registered for GSM modem (1-port)
[    5.668317] option 1-5:1.0: GSM modem (1-port) converter detected
[    5.668405] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB0
[    5.668426] option 1-5:1.2: GSM modem (1-port) converter detected
[    5.670569] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB1
[    5.670596] usbcore: registered new interface driver option
[    5.670599] option: v0.7.2:USB Driver for GSM modems
[    5.685829] __ratelimit: 3 callbacks suppressed


To check if ttyUSB0 and ttyUSB1 are connected use
ls /dev
and check the list for these interfaces in the list.
Note they may not appear until later stages have been competed in this task list (i just checked /dev on my system
after proper installation) also the option driver we will remove this using rmmod (remove module command)



3.

Edit a bash script like this below and put it in the bin directory or where ever you put scripts.

#/usr/local/bin/start_e620Onda.sh
#!/bin/bash


umount /media/3MobileBroadband
sleep 2
rmmod -f usb_storage
sleep 2
rmmod option
sleep 2
rmmod -f usbserial
sleep 2
modprobe usbserial vendor=0x12d1 product=0x0064

this unmounts the drive then sleeps 2 seconds then removes the module from the kernel using rmmod then sleeps again.


4.

Next edit the rules file 90-zte.rules in /etc/udev/rules.d to get the system to do it all the time ie when you reboot you get the
scripts running automatically when it finds the device with the wrong id ie 2000 then runs modeswitch to set it back
to correct mode using modeprobe



SYSFS{idVendor}=="19d2", SYSFS{idProduct}=="2000", RUN+="/usr/sbin/usb_modeswitch -W -c /etc/usb_modeswitchOnda.conf", OPTIONS+="last_rule"

SYSFS{idVendor}=="19d2", SYSFS{idProduct}=="0064", RUN+="/sbin/modprobe usbserial vendor=0x19d2 product=0x0064", OPTIONS+="last_rule"


5.

Do sudo gedit to the file listed below
Edit the Hardware Abstraction Layer for short (HAL are you there HAL? daisy......  daisy .......... give me your answer true)

/usr/share/hal/fdi/information/10freedesktop/10-modem.fdi

in betwee the 2 listings for the models in between (626 and 628) add the 627 lines


 <!-- ZTE MF626 HSDPA USB dongle -->
        <match key="@info.parent:usb.product_id" int="0x2000">
          <match key="@info.parent:usb.interface.number" int="0">
            <append key="modem.command_sets" type="strlist">GSM-07.07</append>
            <append key="modem.command_sets" type="strlist">GSM-07.05</append>
          </match>
        </match>
    <!-- ZTE MF627 HSDPA USB dongle -->
        <match key="@info.parent:usb.product_id" int="0x0064">
          <match key="@info.parent:usb.interface.number" int="0">
            <append key="modem.command_sets" type="strlist">GSM-07.07</append>
            <append key="modem.command_sets" type="strlist">GSM-07.05</append>
          </match>
        </match>
        <!-- ZTE MF628 HSDPA USB dongle -->
        <match key="@info.parent:usb.product_id" int="0x0015">
          <match key="@info.parent:usb.interface.number" int="3">
            <append key="modem.command_sets" type="strlist">GSM-07.07</append>
            <append key="modem.command_sets" type="strlist">GSM-07.05</append>
          </match>
        </match>


see also text about network manager  and MF627 here

https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/310025
and for a package using ppa
http://www.greenhughes.com/content/zte-mf627-easy-way

*note some of these docs refer to the MF627 as having a different number to 0x0064 above ( oh figured out this later the 64 is the UK variant this fac is for the Australia varient )
 use my configuration if your not sure or do a lsusb as in the above example part 1 of this help page.



Now the network manager should  allow you to edit the next step to make the DNS work too after
you create the connection




6.

Next i had a problem with the network manager connection
working then on reboot it would connect again but dns was trashed so do this to create a new entry (I think all the stopping and starting in the script cause problems with DNS startup although this fix seems to work)

A) Right click the network manager icon in the system tray, choose "Edit connections"

B) Go to the "Mobile Broadband" tab and add the relevant connection to your provider (in my case 3 Broadband)

D) Go to 3rd "IPv4 Settings" tab, change "Method" drop-down to "Automatic (PPP) addresses only"

E) Enter "208.67.222.222, 208.67.220.220" in the "DNS Servers" box, click "Apply" and then "Close"



This changes the nameserver to OpenDNS organisation so you don't have to use 3 Broadband's slower ones you could use another close to your location on the planet but these should work.
Now click on the panel and if you haven't set the autoconnect on your settings in the last part you can connect now.

7 ( other things before and after connecting )

Close all root access programs  that you have started such as gedit etc they are safe to use while the Internet is running but its a good security habit to not leave su level programs running and backed up everything before you reboot. 

The network manager applet for starting and closing connections is at the top right hand part of the screen next to the date on my version of Linux Ubuntu.

It may come up that now your connection is wanting access
to the inner ring or some such place just hit ok ( if you give it a password then you have to enter that in every time you connect as network manager doesn't have root access )


Back to my main page or for further network hacking try FreeNAS and LinuxVNC or USB tricks at here
and MF627 working under Vista here or another one working under Busybox and Alfa router

Page updated 30th Jan 2011 to include link to Vista installation oh and update pictures
here it is setup on the R60 IBM Thinkpad running Ubuntu 9.10 server.  To get the old
laptop running I needed to remove the battery for some reason a unchargeable dead battery ( one that can't be recharged anymore ) interferes with the power supply to the laptop causing freeze ups in Ubuntu and XP ( Probably the switchmode power supply is turning off and on too much ) so I just got rid of it and it works fine as a router for my small network with no battery installed.
You have to setup the computer to log into itself using ( click on the link for more pictures and help ) networkmanager.




Some specs for the IBM laptop and 3G system


( Power output.  For laptop, modem and small laptop style fan underneath
                          the computer is 20 watts )

( Penetration.     Will go through reinforced concrete tested on 16 story building  walls
                          part of the reason not to use weaker router based system )
 
Pros and Cons

Pros

1.  Much easier to maintain with a dedicated system monitor screen
     for dropouts and system booting etc.

2.  Recycled hardware cheap and easy to obtain doesn't need wireless N cards
     dedicated routers or extra 3g Modems can use laptops internal wireless card.

3. Can be used as a home alarm system as its always on ( need to create this
    application Steve )
    or other small regularly used system such as a temperature warning device
    note I don't accept any liability if your router stuffs your alarm system etc.

Cons

1.  Router is less energy consuming than a laptop computer.

2.   Needs a dedicated laptop machine preferably on all the time ( extra ware on hardware probably would be good with
      a solid state hard drive for this as the noise may be a issue if the router/laptop is in your bedroom as mine is ).

2.5 Noise may be a issue see note above.

3,   Needs some knowledge of Linux.






( click on underline to get captcha email )


Email ven....@gmail.com

Main page  ....... or FileStore or huawei x1 ideos android emulator
 e220  modem works out of the box on 10.04 Ubuntu howto for E188 how to disable autorun services on e220 modem








Comments